diff --git a/core/input/input.h b/core/input/input.h index 8fc1b9c5dac..8d3b7ae3b9c 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -85,7 +85,7 @@ public: typedef void (*EventDispatchFunc)(const Ref &p_event); private: - BitField mouse_button_mask; + BitField mouse_button_mask = MouseButtonMask::NONE; RBSet key_label_pressed; RBSet physical_keys_pressed; diff --git a/core/input/input_enums.h b/core/input/input_enums.h index 16ddd0c474b..d4efb3d81dc 100644 --- a/core/input/input_enums.h +++ b/core/input/input_enums.h @@ -136,3 +136,11 @@ inline MouseButtonMask mouse_button_to_mask(MouseButton button) { return MouseButtonMask(1 << ((int)button - 1)); } + +constexpr MouseButtonMask operator|(MouseButtonMask p_a, MouseButtonMask p_b) { + return static_cast(static_cast(p_a) | static_cast(p_b)); +} + +constexpr MouseButtonMask &operator|=(MouseButtonMask &p_a, MouseButtonMask p_b) { + return p_a = p_a | p_b; +} diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 6e8cdc4b8e4..85c35c05b3a 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -230,7 +230,7 @@ void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModif } BitField InputEventWithModifiers::get_modifiers_mask() const { - BitField mask; + BitField mask = {}; if (is_ctrl_pressed()) { mask.set_flag(KeyModifierMask::CTRL); } @@ -385,11 +385,11 @@ bool InputEventKey::is_echo() const { } Key InputEventKey::get_keycode_with_modifiers() const { - return keycode | (int64_t)get_modifiers_mask(); + return keycode | get_modifiers_mask(); } Key InputEventKey::get_physical_keycode_with_modifiers() const { - return physical_keycode | (int64_t)get_modifiers_mask(); + return physical_keycode | get_modifiers_mask(); } Key InputEventKey::get_key_label_with_modifiers() const { diff --git a/core/input/input_event.h b/core/input/input_event.h index 3aa2ad8afba..6e308f6c120 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -208,7 +208,7 @@ public: class InputEventMouse : public InputEventWithModifiers { GDCLASS(InputEventMouse, InputEventWithModifiers); - BitField button_mask; + BitField button_mask = MouseButtonMask::NONE; Vector2 pos; Vector2 global_pos; diff --git a/core/templates/bit_field.h b/core/templates/bit_field.h new file mode 100644 index 00000000000..d8155f13ed6 --- /dev/null +++ b/core/templates/bit_field.h @@ -0,0 +1,73 @@ +/**************************************************************************/ +/* bit_field.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#pragma once + +#include "core/typedefs.h" + +#include + +// TODO: Replace `typename` with enum concept once C++20 concepts/constraints are allowed. + +template +class BitField { + static_assert(std::is_enum_v); + uint64_t value; + +public: + _ALWAYS_INLINE_ constexpr void set_flag(BitField p_flag) { value |= p_flag.value; } + _ALWAYS_INLINE_ constexpr bool has_flag(BitField p_flag) const { return value & p_flag.value; } + _ALWAYS_INLINE_ constexpr bool is_empty() const { return value == 0; } + _ALWAYS_INLINE_ constexpr void clear_flag(BitField p_flag) { value &= ~p_flag.value; } + _ALWAYS_INLINE_ constexpr void clear() { value = 0; } + + [[nodiscard]] _ALWAYS_INLINE_ constexpr BitField get_combined(BitField p_other) const { return BitField(value | p_other.value); } + [[nodiscard]] _ALWAYS_INLINE_ constexpr BitField get_shared(BitField p_other) const { return BitField(value & p_other.value); } + [[nodiscard]] _ALWAYS_INLINE_ constexpr BitField get_different(BitField p_other) const { return BitField(value ^ p_other.value); } + + _ALWAYS_INLINE_ constexpr BitField() = default; + _ALWAYS_INLINE_ constexpr BitField(T p_value) : + value(static_cast(p_value)) {} + _ALWAYS_INLINE_ constexpr operator T() const { return static_cast(value); } + + // TODO: Unify as single constructor once C++20 `explicit` conditionals are allowed. + + template && std::is_convertible_v, int> = 0> + _ALWAYS_INLINE_ constexpr BitField(V p_value) : + value(static_cast(p_value)) {} + template && !std::is_convertible_v, int> = 0> + _ALWAYS_INLINE_ constexpr explicit BitField(V p_value) : + value(static_cast(p_value)) {} + template , int> = 0> + _ALWAYS_INLINE_ constexpr explicit operator V() const { return static_cast(value); } +}; + +// Implicitly zero-constructible as a trivially-constructible type. +static_assert(is_zero_constructible_v>); diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h index fa1917c6c92..67b68d30b60 100644 --- a/core/variant/binder_common.h +++ b/core/variant/binder_common.h @@ -123,32 +123,6 @@ VARIANT_ENUM_CAST(Key); VARIANT_BITFIELD_CAST(KeyModifierMask); VARIANT_ENUM_CAST(KeyLocation); -static inline Key &operator|=(Key &a, BitField b) { - a = static_cast(static_cast(a) | static_cast(b.operator int64_t())); - return a; -} - -static inline Key &operator&=(Key &a, BitField b) { - a = static_cast(static_cast(a) & static_cast(b.operator int64_t())); - return a; -} - -static inline Key operator|(Key a, BitField b) { - return (Key)((int)a | (int)b.operator int64_t()); -} - -static inline Key operator&(Key a, BitField b) { - return (Key)((int)a & (int)b.operator int64_t()); -} - -static inline Key operator+(BitField a, Key b) { - return (Key)((int)a.operator int64_t() + (int)b); -} - -static inline Key operator|(BitField a, Key b) { - return (Key)((int)a.operator int64_t() | (int)b); -} - template <> struct VariantCaster { static _FORCE_INLINE_ char32_t cast(const Variant &p_variant) { diff --git a/core/variant/type_info.h b/core/variant/type_info.h index 145dba94e05..b9d75823828 100644 --- a/core/variant/type_info.h +++ b/core/variant/type_info.h @@ -209,29 +209,6 @@ inline StringName __constant_get_enum_name(T param, const String &p_constant) { return GetTypeInfo::get_class_info().class_name; } -template -class BitField { - int64_t value = 0; - -public: - _FORCE_INLINE_ BitField &set_flag(T p_flag) { - value |= (int64_t)p_flag; - return *this; - } - _FORCE_INLINE_ bool has_flag(T p_flag) const { return value & (int64_t)p_flag; } - _FORCE_INLINE_ bool is_empty() const { return value == 0; } - _FORCE_INLINE_ void clear_flag(T p_flag) { value &= ~(int64_t)p_flag; } - _FORCE_INLINE_ void clear() { value = 0; } - _FORCE_INLINE_ constexpr BitField() = default; - _FORCE_INLINE_ constexpr BitField(int64_t p_value) { value = p_value; } - _FORCE_INLINE_ constexpr BitField(T p_value) { value = (int64_t)p_value; } - _FORCE_INLINE_ operator int64_t() const { return value; } - _FORCE_INLINE_ BitField operator^(const BitField &p_b) const { return BitField(value ^ p_b.value); } -}; - -template -struct is_zero_constructible> : std::true_type {}; - #define MAKE_BITFIELD_TYPE_INFO(m_enum) \ template <> \ struct GetTypeInfo { \ diff --git a/core/variant/variant.h b/core/variant/variant.h index e0b2a14ff04..9e1963bb264 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -54,6 +54,7 @@ #include "core/os/keyboard.h" #include "core/string/node_path.h" #include "core/string/ustring.h" +#include "core/templates/bit_field.h" #include "core/templates/list.h" #include "core/templates/paged_allocator.h" #include "core/templates/rid.h" @@ -485,8 +486,8 @@ public: template , int> = 0> _FORCE_INLINE_ operator T() const { return static_cast(operator int64_t()); } - template , int> = 0> - _FORCE_INLINE_ operator BitField() const { return static_cast(operator int64_t()); } + template + _FORCE_INLINE_ operator BitField() const { return static_cast(operator uint64_t()); } Object *get_validated_object() const; Object *get_validated_object_with_check(bool &r_previously_freed) const; @@ -554,9 +555,9 @@ public: template , int> = 0> _FORCE_INLINE_ Variant(T p_enum) : Variant(static_cast(p_enum)) {} - template , int> = 0> + template _FORCE_INLINE_ Variant(BitField p_bitfield) : - Variant(static_cast(p_bitfield)) {} + Variant(static_cast(p_bitfield)) {} // If this changes the table in variant_op must be updated enum Operator { diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index a52430965a1..b964cb85b6f 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -3058,7 +3058,7 @@ Vector RenderingDeviceDriverD3D12::shader_compile_binary_from_spirv(Vec // Translate SPIR-V shaders to DXIL, and collect shader info from the new representation. HashMap> dxil_blobs; - BitField stages_processed; + BitField stages_processed = {}; { HashMap stages_nir_shaders; diff --git a/drivers/metal/metal_objects.mm b/drivers/metal/metal_objects.mm index 92e9e97ea85..22d88b15152 100644 --- a/drivers/metal/metal_objects.mm +++ b/drivers/metal/metal_objects.mm @@ -612,7 +612,7 @@ void MDCommandBuffer::_render_clear_render_area() { bool shouldClearStencil = (ds_index != RDD::AttachmentReference::UNUSED && pass.attachments[ds_index].shouldClear(subpass, true)); if (shouldClearDepth || shouldClearStencil) { MDAttachment const &attachment = pass.attachments[ds_index]; - BitField bits; + BitField bits = {}; if (shouldClearDepth && attachment.type & MDAttachmentType::Depth) { bits.set_flag(RDD::TEXTURE_ASPECT_DEPTH_BIT); } diff --git a/drivers/metal/rendering_device_driver_metal.mm b/drivers/metal/rendering_device_driver_metal.mm index 85848806584..cdae0f93331 100644 --- a/drivers/metal/rendering_device_driver_metal.mm +++ b/drivers/metal/rendering_device_driver_metal.mm @@ -2524,7 +2524,7 @@ RDD::ShaderID RenderingDeviceDriverMetal::shader_create_from_bytecode(const Vect su.writable = uniform.writable; su.length = uniform.length; su.binding = uniform.binding; - su.stages = uniform.stages; + su.stages = (ShaderStage)(uint8_t)uniform.stages; uset.write[i] = su; UniformInfo ui; @@ -2590,7 +2590,7 @@ RDD::ShaderID RenderingDeviceDriverMetal::shader_create_from_bytecode(const Vect sc.type = c.type; sc.constant_id = c.constant_id; sc.int_value = c.int_value; - sc.stages = c.stages; + sc.stages = (ShaderStage)(uint8_t)c.stages; r_shader_desc.specialization_constants.write[i] = sc; } diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 68cec3430da..b62d39d18f3 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -2593,7 +2593,7 @@ RDD::CommandQueueFamilyID RenderingDeviceDriverVulkan::command_queue_family_get( // Preferring a queue with less bits will get us closer to getting a queue that performs better for our requirements. // For example, dedicated compute and transfer queues are usually indicated as such. const VkQueueFlags option_queue_flags = queue_family_properties[i].queueFlags; - const bool includes_all_bits = (option_queue_flags & p_cmd_queue_family_bits) == p_cmd_queue_family_bits; + const bool includes_all_bits = p_cmd_queue_family_bits.get_shared(option_queue_flags) == p_cmd_queue_family_bits; const bool prefer_less_bits = option_queue_flags < picked_queue_flags; if (includes_all_bits && prefer_less_bits) { picked_family_index = i; diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index 01d49b4ea1a..f1dd34f15fe 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -606,7 +606,7 @@ void QuickOpenResultContainer::handle_search_box_input(const Ref &p_ case Key::RIGHT: { if (content_display_mode == QuickOpenDisplayMode::GRID) { // Maybe strip off the shift modifier to allow non-selecting navigation by character? - if (key_event->get_modifiers_mask() == 0) { + if (key_event->get_modifiers_mask().is_empty()) { move_selection = true; } } diff --git a/main/main.cpp b/main/main.cpp index d5c1349d3a2..25ed1404bee 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -3799,7 +3799,7 @@ int Main::start() { #ifdef TOOLS_ENABLED String doc_tool_path; bool doc_tool_implicit_cwd = false; - BitField gen_flags; + BitField gen_flags = {}; String _export_preset; Vector patches; bool export_debug = false; diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 32e3c9a02c7..7c5c6291228 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1803,7 +1803,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode * GDScriptParser::DataType parent_return_type; List parameters_types; int default_par_count = 0; - BitField method_flags; + BitField method_flags = {}; StringName native_base; if (!p_is_lambda && get_function_signature(p_function, false, base_type, function_name, parent_return_type, parameters_types, default_par_count, method_flags, &native_base)) { bool valid = p_function->is_static == method_flags.has_flag(METHOD_FLAG_STATIC); @@ -2276,7 +2276,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) { GDScriptParser::DataType return_type; List par_types; int default_arg_count = 0; - BitField method_flags; + BitField method_flags = {}; if (get_function_signature(p_for->list, false, list_type, CoreStringName(_iter_get), return_type, par_types, default_arg_count, method_flags)) { variable_type = return_type; variable_type.type_source = list_type.type_source; @@ -3567,7 +3567,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a } int default_arg_count = 0; - BitField method_flags; + BitField method_flags = {}; GDScriptParser::DataType return_type; List par_types; diff --git a/modules/openxr/extensions/openxr_hand_tracking_extension.cpp b/modules/openxr/extensions/openxr_hand_tracking_extension.cpp index 28f7c459b28..7552a44baa3 100644 --- a/modules/openxr/extensions/openxr_hand_tracking_extension.cpp +++ b/modules/openxr/extensions/openxr_hand_tracking_extension.cpp @@ -263,7 +263,7 @@ void OpenXRHandTrackingExtension::on_process() { Transform3D transform; Vector3 linear_velocity; Vector3 angular_velocity; - BitField flags; + BitField flags = {}; if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) { if (pose.orientation.x != 0 || pose.orientation.y != 0 || pose.orientation.z != 0 || pose.orientation.w != 0) { diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp index 0e9e4f41fc6..cf9a54a5085 100644 --- a/modules/openxr/openxr_interface.cpp +++ b/modules/openxr/openxr_interface.cpp @@ -1466,7 +1466,7 @@ OpenXRInterface::HandTrackedSource OpenXRInterface::get_hand_tracking_source(con } BitField OpenXRInterface::get_hand_joint_flags(Hand p_hand, HandJoints p_joint) const { - BitField bits; + BitField bits = HAND_JOINT_NONE; OpenXRHandTrackingExtension *hand_tracking_ext = OpenXRHandTrackingExtension::get_singleton(); if (hand_tracking_ext && hand_tracking_ext->get_active()) { diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index 859f4c3c1b3..ca63bcdf6a5 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -283,7 +283,7 @@ void AndroidInputHandler::_parse_mouse_event_info(BitField even } ev->set_pressed(p_pressed); ev->set_canceled(p_canceled); - BitField changed_button_mask = BitField(buttons_state.operator int64_t() ^ event_buttons_mask.operator int64_t()); + BitField changed_button_mask = buttons_state.get_different(event_buttons_mask); buttons_state = event_buttons_mask; @@ -395,7 +395,7 @@ void AndroidInputHandler::_wheel_button_click(BitField event_bu Ref evd = ev->duplicate(); _set_key_modifier_state(evd, Key::NONE); evd->set_button_index(wheel_button); - evd->set_button_mask(BitField(event_buttons_mask.operator int64_t() ^ int64_t(mouse_button_to_mask(wheel_button)))); + evd->set_button_mask(event_buttons_mask.get_different(mouse_button_to_mask(wheel_button))); evd->set_factor(factor); Input::get_singleton()->parse_input_event(evd); Ref evdd = evd->duplicate(); @@ -423,7 +423,7 @@ void AndroidInputHandler::process_pan(Point2 p_pos, Vector2 p_delta) { } MouseButton AndroidInputHandler::_button_index_from_mask(BitField button_mask) { - switch (MouseButtonMask(button_mask.operator int64_t())) { + switch (button_mask) { case MouseButtonMask::LEFT: return MouseButton::LEFT; case MouseButtonMask::RIGHT: @@ -440,7 +440,7 @@ MouseButton AndroidInputHandler::_button_index_from_mask(BitField AndroidInputHandler::_android_button_mask_to_godot_button_mask(int android_button_mask) { - BitField godot_button_mask; + BitField godot_button_mask = MouseButtonMask::NONE; if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) { godot_button_mask.set_flag(MouseButtonMask::LEFT); } diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h index a6f5be27cfa..7901b0665d5 100644 --- a/platform/android/android_input_handler.h +++ b/platform/android/android_input_handler.h @@ -62,7 +62,7 @@ public: int index = 0; // Can be either JoyAxis or JoyButton. bool pressed = false; float value = 0; - BitField hat; + BitField hat = HatMask::CENTER; }; private: @@ -71,7 +71,7 @@ private: bool control_mem = false; bool meta_mem = false; - BitField buttons_state; + BitField buttons_state = MouseButtonMask::NONE; Vector touch; MouseEventInfo mouse_event_info; diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 066cf86d1c2..24c9302b7a9 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -398,7 +398,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j AndroidInputHandler::JoypadEvent jevent; jevent.device = p_device; jevent.type = AndroidInputHandler::JOY_EVENT_HAT; - BitField hat; + BitField hat = HatMask::CENTER; if (p_hat_x != 0) { if (p_hat_x < 0) { hat.set_flag(HatMask::LEFT); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 49f2690e611..f76e54d74e1 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -73,7 +73,7 @@ JoypadLinux::Joypad::~Joypad() { } void JoypadLinux::Joypad::reset() { - dpad = 0; + dpad.clear(); fd = -1; for (int i = 0; i < MAX_ABS; i++) { abs_map[i] = -1; diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h index 387bcb38019..5f9f3d9e248 100644 --- a/platform/linuxbsd/joypad_linux.h +++ b/platform/linuxbsd/joypad_linux.h @@ -62,7 +62,7 @@ private: float curr_axis[MAX_ABS]; int key_map[MAX_KEY]; int abs_map[MAX_ABS]; - BitField dpad; + BitField dpad = HatMask::CENTER; int fd = -1; String devpath; diff --git a/platform/linuxbsd/wayland/display_server_wayland.h b/platform/linuxbsd/wayland/display_server_wayland.h index 66f62c3e7ba..bc798f955d8 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.h +++ b/platform/linuxbsd/wayland/display_server_wayland.h @@ -144,7 +144,7 @@ class DisplayServerWayland : public DisplayServer { // are the "take all input thx" windows while the `popup_stack` variable keeps // track of all the generic floating window concept. List popup_menu_list; - BitField last_mouse_monitor_mask; + BitField last_mouse_monitor_mask = MouseButtonMask::NONE; String ime_text; Vector2i ime_selection; diff --git a/platform/linuxbsd/wayland/wayland_thread.cpp b/platform/linuxbsd/wayland/wayland_thread.cpp index 30b90b7b4af..5d391ce4fc9 100644 --- a/platform/linuxbsd/wayland/wayland_thread.cpp +++ b/platform/linuxbsd/wayland/wayland_thread.cpp @@ -1779,7 +1779,7 @@ void WaylandThread::_wl_pointer_on_frame(void *data, struct wl_pointer *wl_point } if (old_pd.pressed_button_mask != pd.pressed_button_mask) { - BitField pressed_mask_delta = old_pd.pressed_button_mask ^ pd.pressed_button_mask; + BitField pressed_mask_delta = old_pd.pressed_button_mask.get_different(pd.pressed_button_mask); const MouseButton buttons_to_test[] = { MouseButton::LEFT, @@ -2746,7 +2746,7 @@ void WaylandThread::_wp_tablet_tool_on_frame(void *data, struct zwp_tablet_tool_ if (old_td.pressed_button_mask != td.pressed_button_mask) { td.button_time = time; - BitField pressed_mask_delta = BitField((int64_t)old_td.pressed_button_mask ^ (int64_t)td.pressed_button_mask); + BitField pressed_mask_delta = old_td.pressed_button_mask.get_different(td.pressed_button_mask); for (MouseButton test_button : { MouseButton::LEFT, MouseButton::RIGHT }) { MouseButtonMask test_button_mask = mouse_button_to_mask(test_button); diff --git a/platform/linuxbsd/wayland/wayland_thread.h b/platform/linuxbsd/wayland/wayland_thread.h index 09ace913a39..043b24aedb1 100644 --- a/platform/linuxbsd/wayland/wayland_thread.h +++ b/platform/linuxbsd/wayland/wayland_thread.h @@ -341,7 +341,7 @@ public: Vector2 relative_motion; uint32_t relative_motion_time = 0; - BitField pressed_button_mask; + BitField pressed_button_mask = MouseButtonMask::NONE; MouseButton last_button_pressed = MouseButton::NONE; Point2 last_pressed_position; @@ -371,7 +371,7 @@ public: Vector2 tilt; uint32_t pressure = 0; - BitField pressed_button_mask; + BitField pressed_button_mask = MouseButtonMask::NONE; MouseButton last_button_pressed = MouseButton::NONE; Point2 last_pressed_position; diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 71535fa6c55..985209bd082 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -622,7 +622,7 @@ BitField DisplayServerX11::mouse_get_button_state() const { int root_x, root_y, win_x, win_y; unsigned int mask; if (XQueryPointer(x11_display, XRootWindow(x11_display, i), &root, &child, &root_x, &root_y, &win_x, &win_y, &mask)) { - BitField last_button_state = 0; + BitField last_button_state = MouseButtonMask::NONE; if (mask & Button1Mask) { last_button_state.set_flag(MouseButtonMask::LEFT); @@ -643,7 +643,7 @@ BitField DisplayServerX11::mouse_get_button_state() const { return last_button_state; } } - return 0; + return MouseButtonMask::NONE; } void DisplayServerX11::clipboard_set(const String &p_text) { @@ -5318,7 +5318,7 @@ void DisplayServerX11::process_events() { pos = Point2i(windows[focused_window_id].size.width / 2, windows[focused_window_id].size.height / 2); } - BitField last_button_state = 0; + BitField last_button_state = MouseButtonMask::NONE; if (event.xmotion.state & Button1Mask) { last_button_state.set_flag(MouseButtonMask::LEFT); } diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 616eff4049a..3ec84872e66 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -1614,7 +1614,7 @@ Point2i DisplayServerMacOS::mouse_get_position() const { } BitField DisplayServerMacOS::mouse_get_button_state() const { - BitField last_button_state = 0; + BitField last_button_state = MouseButtonMask::NONE; NSUInteger buttons = [NSEvent pressedMouseButtons]; if (buttons & (1 << 0)) { diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index b11ccb6ecb4..5e1ded587db 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -922,7 +922,7 @@ Point2i DisplayServerWindows::mouse_get_position() const { } BitField DisplayServerWindows::mouse_get_button_state() const { - BitField last_button_state = 0; + BitField last_button_state = MouseButtonMask::NONE; if (GetKeyState(VK_LBUTTON) & (1 << 15)) { last_button_state.set_flag(MouseButtonMask::LEFT); @@ -4526,7 +4526,7 @@ void DisplayServerWindows::popup_close(WindowID p_window) { } BitField DisplayServerWindows::_get_mods() const { - BitField mask; + BitField mask = {}; static unsigned char keyboard_state[256]; if (GetKeyboardState((PBYTE)&keyboard_state)) { if ((keyboard_state[VK_LSHIFT] & 0x80) || (keyboard_state[VK_RSHIFT] & 0x80)) { @@ -5136,7 +5136,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mb.instantiate(); mb->set_window_id(window_id); - BitField last_button_state = 0; + BitField last_button_state = MouseButtonMask::NONE; if (IS_POINTER_FIRSTBUTTON_WPARAM(wParam)) { last_button_state.set_flag(MouseButtonMask::LEFT); mb->set_button_index(MouseButton::LEFT); @@ -5302,7 +5302,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_alt_pressed(mods.has_flag(WinKeyModifierMask::ALT)); mm->set_meta_pressed(mods.has_flag(WinKeyModifierMask::META)); - BitField last_button_state = 0; + BitField last_button_state = MouseButtonMask::NONE; if (IS_POINTER_FIRSTBUTTON_WPARAM(wParam)) { last_button_state.set_flag(MouseButtonMask::LEFT); } diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 15afaea6686..61386191896 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -479,7 +479,7 @@ void JoypadWindows::process_joypads() { } void JoypadWindows::post_hat(int p_device, DWORD p_dpad) { - BitField dpad_val; + BitField dpad_val = HatMask::CENTER; // Should be -1 when centered, but according to docs: // "Some drivers report the centered position of the POV indicator as 65,535. Determine whether the indicator is centered as follows: diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 076eb5638c9..30cff62a93b 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -122,7 +122,7 @@ class PopupMenu : public Popup { Timer *submenu_timer = nullptr; List autohide_areas; mutable Vector items; - BitField initial_button_mask; + BitField initial_button_mask = MouseButtonMask::NONE; bool during_grabbed_click = false; bool is_scrolling = false; int mouse_over = -1; diff --git a/scene/main/node.h b/scene/main/node.h index e7a8f046680..7427d4f150f 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -204,7 +204,7 @@ private: ProcessThreadGroup process_thread_group = PROCESS_THREAD_GROUP_INHERIT; Node *process_thread_group_owner = nullptr; int process_thread_group_order = 0; - BitField process_thread_messages; + BitField process_thread_messages = {}; void *process_group = nullptr; // to avoid cyclic dependency int multiplayer_authority = 1; // Server by default. diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 4ec8ca11c7a..cf331733d70 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -367,7 +367,7 @@ private: HashMap touch_focus; Control *mouse_focus = nullptr; Control *mouse_click_grabber = nullptr; - BitField mouse_focus_mask; + BitField mouse_focus_mask = MouseButtonMask::NONE; Control *key_focus = nullptr; Control *mouse_over = nullptr; LocalVector mouse_over_hierarchy; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index ce8739b8d54..0a54467280e 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -298,7 +298,7 @@ void Font::set_cache_capacity(int p_single_line, int p_multi_line) { Size2 Font::get_string_size(const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, BitField p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const { bool fill = (p_alignment == HORIZONTAL_ALIGNMENT_FILL); - ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0, fill ? p_jst_flags : TextServer::JUSTIFICATION_NONE, TextServer::BREAK_NONE, p_direction, p_orientation); + ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0, fill ? p_jst_flags : BitField(TextServer::JUSTIFICATION_NONE), TextServer::BREAK_NONE, p_direction, p_orientation); Ref buffer; if (cache.has(key)) { @@ -347,7 +347,7 @@ Size2 Font::get_multiline_string_size(const String &p_text, HorizontalAlignment void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, const Color &p_modulate, BitField p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const { bool fill = (p_alignment == HORIZONTAL_ALIGNMENT_FILL); - ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0, fill ? p_jst_flags : TextServer::JUSTIFICATION_NONE, TextServer::BREAK_NONE, p_direction, p_orientation); + ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0, fill ? p_jst_flags : BitField(TextServer::JUSTIFICATION_NONE), TextServer::BREAK_NONE, p_direction, p_orientation); Ref buffer; if (cache.has(key)) { @@ -410,7 +410,7 @@ void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const S void Font::draw_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_size, const Color &p_modulate, BitField p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const { bool fill = (p_alignment == HORIZONTAL_ALIGNMENT_FILL); - ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0, fill ? p_jst_flags : TextServer::JUSTIFICATION_NONE, TextServer::BREAK_NONE, p_direction, p_orientation); + ShapedTextKey key = ShapedTextKey(p_text, p_font_size, fill ? p_width : 0.0, fill ? p_jst_flags : BitField(TextServer::JUSTIFICATION_NONE), TextServer::BREAK_NONE, p_direction, p_orientation); Ref buffer; if (cache.has(key)) { diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 804885c5278..e42d8d70f0f 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -528,7 +528,7 @@ Point2i DisplayServer::mouse_get_position() const { } BitField DisplayServer::mouse_get_button_state() const { - ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server."); + ERR_FAIL_V_MSG(MouseButtonMask::NONE, "Mouse is not supported by this display server."); } void DisplayServer::clipboard_set(const String &p_text) { diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index ba601f1c994..1e25fc87210 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -4407,7 +4407,7 @@ RenderingDevice::DrawListID RenderingDevice::draw_list_begin(RID p_framebuffer, thread_local LocalVector clear_values; thread_local LocalVector resource_trackers; thread_local LocalVector resource_usages; - BitField stages; + BitField stages = {}; operations.resize(framebuffer->texture_ids.size()); clear_values.resize(framebuffer->texture_ids.size()); resource_trackers.clear(); @@ -6694,7 +6694,7 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ // Pick the main queue family. It is worth noting we explicitly do not request the transfer bit, as apparently the specification defines // that the existence of either the graphics or compute bit implies that the queue can also do transfer operations, but it is optional // to indicate whether it supports them or not with the dedicated transfer bit if either is set. - BitField main_queue_bits; + BitField main_queue_bits = {}; main_queue_bits.set_flag(RDD::COMMAND_QUEUE_FAMILY_GRAPHICS_BIT); main_queue_bits.set_flag(RDD::COMMAND_QUEUE_FAMILY_COMPUTE_BIT); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 61089ab592e..5eb89538ae6 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -170,7 +170,7 @@ private: int current = 0; uint32_t block_size = 0; uint64_t max_size = 0; - BitField usage_bits; + BitField usage_bits = {}; bool used = false; }; @@ -184,7 +184,7 @@ private: struct Buffer { RDD::BufferID driver_id; uint32_t size = 0; - BitField usage; + BitField usage = {}; RDG::ResourceTracker *draw_tracker = nullptr; int32_t transfer_worker_index = -1; uint64_t transfer_worker_operation = 0; @@ -315,8 +315,8 @@ public: bool is_discardable = false; bool has_initial_data = false; - BitField read_aspect_flags; - BitField barrier_aspect_flags; + BitField read_aspect_flags = {}; + BitField barrier_aspect_flags = {}; bool bound = false; // Bound to framebuffer. RID owner; @@ -872,7 +872,7 @@ private: String name; // Used for debug. RDD::ShaderID driver_id; uint32_t layout_hash = 0; - BitField stage_bits; + BitField stage_bits = {}; Vector set_formats; }; @@ -1149,7 +1149,7 @@ private: uint32_t shader_layout_hash = 0; Vector set_formats; RDD::PipelineID driver_id; - BitField stage_bits; + BitField stage_bits = {}; uint32_t push_constant_size = 0; }; diff --git a/servers/rendering/rendering_device_commons.h b/servers/rendering/rendering_device_commons.h index 8468eb25938..63f2b8792b4 100644 --- a/servers/rendering/rendering_device_commons.h +++ b/servers/rendering/rendering_device_commons.h @@ -962,7 +962,7 @@ public: UniformType type = UniformType::UNIFORM_TYPE_MAX; bool writable = false; uint32_t binding = 0; - BitField stages; + BitField stages = {}; uint32_t length = 0; // Size of arrays (in total elements), or ubos (in bytes * total elements). bool operator!=(const ShaderUniform &p_other) const { @@ -990,7 +990,7 @@ public: }; struct ShaderSpecializationConstant : public PipelineSpecializationConstant { - BitField stages; + BitField stages = {}; bool operator<(const ShaderSpecializationConstant &p_other) const { return constant_id < p_other.constant_id; } }; @@ -1009,7 +1009,7 @@ public: protected: struct ShaderReflection : public ShaderDescription { - BitField stages; - BitField push_constant_stages; + BitField stages = {}; + BitField push_constant_stages = {}; }; }; diff --git a/servers/rendering/rendering_device_driver.h b/servers/rendering/rendering_device_driver.h index a56c248874e..31517ea5820 100644 --- a/servers/rendering/rendering_device_driver.h +++ b/servers/rendering/rendering_device_driver.h @@ -267,14 +267,14 @@ public: }; struct TextureSubresourceLayers { - BitField aspect; + BitField aspect = {}; uint32_t mipmap = 0; uint32_t base_layer = 0; uint32_t layer_count = 0; }; struct TextureSubresourceRange { - BitField aspect; + BitField aspect = {}; uint32_t base_mipmap = 0; uint32_t mipmap_count = 0; uint32_t base_layer = 0; @@ -370,22 +370,22 @@ public: }; struct MemoryBarrier { - BitField src_access; - BitField dst_access; + BitField src_access = {}; + BitField dst_access = {}; }; struct BufferBarrier { BufferID buffer; - BitField src_access; - BitField dst_access; + BitField src_access = {}; + BitField dst_access = {}; uint64_t offset = 0; uint64_t size = 0; }; struct TextureBarrier { TextureID texture; - BitField src_access; - BitField dst_access; + BitField src_access = {}; + BitField dst_access = {}; TextureLayout prev_layout = TEXTURE_LAYOUT_UNDEFINED; TextureLayout next_layout = TEXTURE_LAYOUT_UNDEFINED; TextureSubresourceRange subresources; @@ -628,7 +628,7 @@ public: static const uint32_t UNUSED = 0xffffffff; uint32_t attachment = UNUSED; TextureLayout layout = TEXTURE_LAYOUT_UNDEFINED; - BitField aspect; + BitField aspect = {}; }; struct Subpass { @@ -644,10 +644,10 @@ public: struct SubpassDependency { uint32_t src_subpass = 0xffffffff; uint32_t dst_subpass = 0xffffffff; - BitField src_stages; - BitField dst_stages; - BitField src_access; - BitField dst_access; + BitField src_stages = {}; + BitField dst_stages = {}; + BitField src_access = {}; + BitField dst_access = {}; }; virtual RenderPassID render_pass_create(VectorView p_attachments, VectorView p_subpasses, VectorView p_subpass_dependencies, uint32_t p_view_count, AttachmentReference p_fragment_density_map_attachment) = 0; @@ -666,7 +666,7 @@ public: }; struct AttachmentClear { - BitField aspect; + BitField aspect = {}; uint32_t color_attachment = 0xffffffff; RenderPassClearValue value; }; diff --git a/servers/rendering/rendering_device_graph.h b/servers/rendering/rendering_device_graph.h index c0ec35be6cb..a83188caddd 100644 --- a/servers/rendering/rendering_device_graph.h +++ b/servers/rendering/rendering_device_graph.h @@ -114,9 +114,9 @@ public: int32_t buffer_barrier_count = 0; #endif int32_t label_index = -1; - BitField previous_stages; - BitField next_stages; - BitField self_stages; + BitField previous_stages = {}; + BitField next_stages = {}; + BitField self_stages = {}; }; struct RecordedBufferCopy { @@ -156,8 +156,8 @@ public: struct ResourceTracker { uint32_t reference_count = 0; int64_t command_frame = -1; - BitField previous_frame_stages; - BitField current_frame_stages; + BitField previous_frame_stages = {}; + BitField current_frame_stages = {}; int32_t read_full_command_list_index = -1; int32_t read_slice_command_list_index = -1; int32_t write_command_or_list_index = -1; @@ -166,7 +166,7 @@ public: int32_t compute_list_index = -1; ResourceUsage compute_list_usage = RESOURCE_USAGE_NONE; ResourceUsage usage = RESOURCE_USAGE_NONE; - BitField usage_access; + BitField usage_access = {}; RDD::BufferID buffer_driver_id; RDD::TextureID texture_driver_id; RDD::TextureSubresourceRange texture_subresources; @@ -241,7 +241,7 @@ private: LocalVector data; LocalVector command_trackers; LocalVector command_tracker_usages; - BitField stages; + BitField stages = {}; int32_t index = 0; void clear() { @@ -660,8 +660,8 @@ private: }; struct BarrierGroup { - BitField src_stages; - BitField dst_stages; + BitField src_stages = {}; + BitField dst_stages = {}; RDD::MemoryBarrier memory_barrier; LocalVector normalization_barriers; LocalVector transition_barriers; diff --git a/servers/rendering/storage/compositor_storage.h b/servers/rendering/storage/compositor_storage.h index 14e9f79a140..c11fee97710 100644 --- a/servers/rendering/storage/compositor_storage.h +++ b/servers/rendering/storage/compositor_storage.h @@ -44,7 +44,7 @@ private: RS::CompositorEffectCallbackType callback_type; Callable callback; - BitField flags; + BitField flags = {}; }; mutable RID_Owner compositor_effects_owner; diff --git a/servers/xr/xr_body_tracker.h b/servers/xr/xr_body_tracker.h index 00c9348bd87..dbf8b30a0a8 100644 --- a/servers/xr/xr_body_tracker.h +++ b/servers/xr/xr_body_tracker.h @@ -161,7 +161,7 @@ protected: private: bool has_tracking_data = false; - BitField body_flags; + BitField body_flags = {}; BitField joint_flags[JOINT_MAX]; Transform3D joint_transforms[JOINT_MAX]; diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 22336542565..a7c18923515 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -4148,10 +4148,10 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { Point2 caret_pos = code_edit->get_caret_draw_pos(); caret_pos.y += code_edit->get_line_height(); - SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); CHECK(code_edit->get_code_completion_selected_index() == 1); - SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); CHECK(code_edit->get_code_completion_selected_index() == 0); /* Single click selects. */ diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index 19db4f19e17..f6cce65b1d9 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -7727,28 +7727,28 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { // Scroll. int v_scroll = text_edit->get_v_scroll(); - SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); CHECK(text_edit->get_v_scroll() > v_scroll); - SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); CHECK(text_edit->get_v_scroll() == v_scroll); // smooth scroll speed. text_edit->set_smooth_scroll_enabled(true); v_scroll = text_edit->get_v_scroll(); - SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() >= v_scroll); - SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() == v_scroll); v_scroll = text_edit->get_v_scroll(); text_edit->set_v_scroll_speed(10000); - SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() >= v_scroll); - SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() == v_scroll); diff --git a/tests/scene/test_viewport.h b/tests/scene/test_viewport.h index cfccdadfcbc..5094f0e71c9 100644 --- a/tests/scene/test_viewport.h +++ b/tests/scene/test_viewport.h @@ -347,7 +347,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") { SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK(node_a->has_focus()); - SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::RIGHT, (int)MouseButtonMask::LEFT | (int)MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::RIGHT, MouseButtonMask::LEFT | MouseButtonMask::RIGHT, Key::NONE); CHECK(node_a->has_focus()); SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_b, MouseButton::RIGHT, MouseButtonMask::LEFT, Key::NONE); @@ -362,12 +362,12 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") { SEND_GUI_MOUSE_BUTTON_EVENT(on_background, MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); CHECK_FALSE(root->gui_get_focus_owner()); - SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, (int)MouseButtonMask::LEFT | (int)MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT | MouseButtonMask::RIGHT, Key::NONE); CHECK(node_a->has_focus()); SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::RIGHT, Key::NONE); CHECK(node_a->has_focus()); - SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::LEFT, (int)MouseButtonMask::LEFT | (int)MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::LEFT, MouseButtonMask::LEFT | MouseButtonMask::RIGHT, Key::NONE); CHECK(node_b->has_focus()); SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::RIGHT, Key::NONE); diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h index cf6c7ff779c..e28c28c3ed5 100644 --- a/tests/servers/test_text_server.h +++ b/tests/servers/test_text_server.h @@ -517,7 +517,7 @@ TEST_SUITE("[TextServer]") { struct TestCase { String text; PackedInt32Array breaks; - BitField flags; + BitField flags = TextServer::BREAK_NONE; }; TestCase cases[] = { { U"test \rtest", { 0, 4, 6, 10 }, TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_TRIM_START_EDGE_SPACES | TextServer::BREAK_TRIM_END_EDGE_SPACES }, diff --git a/tests/test_macros.h b/tests/test_macros.h index 51a4fdc170e..5354fcb96f5 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -211,12 +211,12 @@ int register_test_command(String p_command, TestFunc p_function); MessageQueue::get_singleton()->flush(); \ } -#define SEND_GUI_DOUBLE_CLICK(m_screen_pos, m_modifiers) \ - { \ - _CREATE_GUI_MOUSE_EVENT(m_screen_pos, MouseButton::LEFT, 0, m_modifiers); \ - event->set_double_click(true); \ - _SEND_DISPLAYSERVER_EVENT(event); \ - MessageQueue::get_singleton()->flush(); \ +#define SEND_GUI_DOUBLE_CLICK(m_screen_pos, m_modifiers) \ + { \ + _CREATE_GUI_MOUSE_EVENT(m_screen_pos, MouseButton::LEFT, MouseButtonMask::NONE, m_modifiers); \ + event->set_double_click(true); \ + _SEND_DISPLAYSERVER_EVENT(event); \ + MessageQueue::get_singleton()->flush(); \ } // We toggle _print_error_enabled to prevent display server not supported warnings.