Add WINDOW_FLAG_MOUSE_PASSTHROUGH flag and enabled it for tooltips. Expose window_set_mouse_passthrough to Window.

This commit is contained in:
bruvzg 2023-01-15 12:05:25 +02:00
parent 0f0b853c98
commit 34b34b104c
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
13 changed files with 127 additions and 12 deletions

View file

@ -1694,7 +1694,10 @@
Use [method window_get_safe_title_margins] to determine area under the title bar that is not covered by decorations. Use [method window_get_safe_title_margins] to determine area under the title bar that is not covered by decorations.
[b]Note:[/b] This flag is implemented on macOS. [b]Note:[/b] This flag is implemented on macOS.
</constant> </constant>
<constant name="WINDOW_FLAG_MAX" value="7" enum="WindowFlags"> <constant name="WINDOW_FLAG_MOUSE_PASSTHROUGH" value="7" enum="WindowFlags">
All mouse event as passed to the underlying window of the same application.
</constant>
<constant name="WINDOW_FLAG_MAX" value="8" enum="WindowFlags">
Max value of the [enum WindowFlags]. Max value of the [enum WindowFlags].
</constant> </constant>
<constant name="WINDOW_EVENT_MOUSE_ENTER" value="0" enum="WindowEvent"> <constant name="WINDOW_EVENT_MOUSE_ENTER" value="0" enum="WindowEvent">

View file

@ -527,6 +527,39 @@
Set's the window's current mode. Set's the window's current mode.
[b]Note:[/b] Fullscreen mode is not exclusive full screen on Windows and Linux. [b]Note:[/b] Fullscreen mode is not exclusive full screen on Windows and Linux.
</member> </member>
<member name="mouse_passthrough" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], all mouse event as passed to the underlying window of the same application. See also [member mouse_passthrough_polygon].
[b]Note:[/b] This property is implemented on Linux (X11), macOS and Windows.
</member>
<member name="mouse_passthrough_polygon" type="PackedVector2Array" setter="set_mouse_passthrough_polygon" getter="get_mouse_passthrough_polygon" default="PackedVector2Array()">
Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through.
Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior).
[codeblocks]
[gdscript]
# Set region, using Path2D node.
$Window.mouse_passthrough_polygon = $Path2D.curve.get_baked_points()
# Set region, using Polygon2D node.
$Window.mouse_passthrough_polygon = $Polygon2D.polygon
# Reset region to default.
$Window.mouse_passthrough_polygon = []
[/gdscript]
[csharp]
// Set region, using Path2D node.
GetNode&lt;Window&gt;("Window").MousePassthrough = GetNode&lt;Path2D&gt;("Path2D").Curve.GetBakedPoints();
// Set region, using Polygon2D node.
GetNode&lt;Window&gt;("Window").MousePassthrough = GetNode&lt;Polygon2D&gt;("Polygon2D").Polygon;
// Reset region to default.
GetNode&lt;Window&gt;("Window").MousePassthrough = new Vector2[] {};
[/csharp]
[/codeblocks]
[b]Note:[/b] This property is ignored if [member mouse_passthrough] is set to [code]true[/code].
[b]Note:[/b] On Windows, the portion of a window that lies outside the region is not drawn, while on Linux (X11) and macOS it is.
[b]Note:[/b] This property is implemented on Linux (X11), macOS and Windows.
</member>
<member name="popup_window" type="bool" setter="set_flag" getter="get_flag" default="false"> <member name="popup_window" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the [Window] will be considered a popup. Popups are sub-windows that don't show as separate windows in system's window manager's window list and will send close request when anything is clicked outside of them (unless [member exclusive] is enabled). If [code]true[/code], the [Window] will be considered a popup. Popups are sub-windows that don't show as separate windows in system's window manager's window list and will send close request when anything is clicked outside of them (unless [member exclusive] is enabled).
</member> </member>
@ -695,7 +728,9 @@
Window content is expanded to the full size of the window. Unlike borderless window, the frame is left intact and can be used to resize the window, title bar is transparent, but have minimize/maximize/close buttons. Set with [member extend_to_title]. Window content is expanded to the full size of the window. Unlike borderless window, the frame is left intact and can be used to resize the window, title bar is transparent, but have minimize/maximize/close buttons. Set with [member extend_to_title].
[b]Note:[/b] This flag is implemented on macOS. [b]Note:[/b] This flag is implemented on macOS.
</constant> </constant>
<constant name="FLAG_MAX" value="7" enum="Flags"> <constant name="FLAG_MOUSE_PASSTHROUGH" value="7" enum="Flags">
</constant>
<constant name="FLAG_MAX" value="8" enum="Flags">
Max value of the [enum Flags]. Max value of the [enum Flags].
</constant> </constant>
<constant name="CONTENT_SCALE_MODE_DISABLED" value="0" enum="ContentScaleMode"> <constant name="CONTENT_SCALE_MODE_DISABLED" value="0" enum="ContentScaleMode">

View file

@ -1420,13 +1420,22 @@ void DisplayServerX11::window_set_mouse_passthrough(const Vector<Vector2> &p_reg
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window)); ERR_FAIL_COND(!windows.has(p_window));
const WindowData &wd = windows[p_window]; windows[p_window].mpath = p_region;
_update_window_mouse_passthrough(p_window);
}
void DisplayServerX11::_update_window_mouse_passthrough(WindowID p_window) {
ERR_FAIL_COND(!windows.has(p_window));
const Vector<Vector2> region_path = windows[p_window].mpath;
int event_base, error_base; int event_base, error_base;
const Bool ext_okay = XShapeQueryExtension(x11_display, &event_base, &error_base); const Bool ext_okay = XShapeQueryExtension(x11_display, &event_base, &error_base);
if (ext_okay) { if (ext_okay) {
Region region; Region region;
if (p_region.size() == 0) { if (windows[p_window].mpass) {
region = XCreateRegion();
} else if (region_path.size() == 0) {
region = XCreateRegion(); region = XCreateRegion();
XRectangle rect; XRectangle rect;
rect.x = 0; rect.x = 0;
@ -1435,15 +1444,15 @@ void DisplayServerX11::window_set_mouse_passthrough(const Vector<Vector2> &p_reg
rect.height = window_get_size_with_decorations(p_window).y; rect.height = window_get_size_with_decorations(p_window).y;
XUnionRectWithRegion(&rect, region, region); XUnionRectWithRegion(&rect, region, region);
} else { } else {
XPoint *points = (XPoint *)memalloc(sizeof(XPoint) * p_region.size()); XPoint *points = (XPoint *)memalloc(sizeof(XPoint) * region_path.size());
for (int i = 0; i < p_region.size(); i++) { for (int i = 0; i < region_path.size(); i++) {
points[i].x = p_region[i].x; points[i].x = region_path[i].x;
points[i].y = p_region[i].y; points[i].y = region_path[i].y;
} }
region = XPolygonRegion(points, p_region.size(), EvenOddRule); region = XPolygonRegion(points, region_path.size(), EvenOddRule);
memfree(points); memfree(points);
} }
XShapeCombineRegion(x11_display, wd.x11_window, ShapeInput, 0, 0, region, ShapeSet); XShapeCombineRegion(x11_display, windows[p_window].x11_window, ShapeInput, 0, 0, region, ShapeSet);
XDestroyRegion(region); XDestroyRegion(region);
} }
} }
@ -2312,6 +2321,7 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
window_set_size(window_get_size(p_window), p_window); window_set_size(window_get_size(p_window), p_window);
wd.borderless = p_enabled; wd.borderless = p_enabled;
_update_window_mouse_passthrough(p_window);
} break; } break;
case WINDOW_FLAG_ALWAYS_ON_TOP: { case WINDOW_FLAG_ALWAYS_ON_TOP: {
ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID, "Can't make a window transient if the 'on top' flag is active."); ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID, "Can't make a window transient if the 'on top' flag is active.");
@ -2345,6 +2355,10 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
case WINDOW_FLAG_NO_FOCUS: { case WINDOW_FLAG_NO_FOCUS: {
wd.no_focus = p_enabled; wd.no_focus = p_enabled;
} break; } break;
case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
wd.mpass = p_enabled;
_update_window_mouse_passthrough(p_window);
} break;
case WINDOW_FLAG_POPUP: { case WINDOW_FLAG_POPUP: {
XWindowAttributes xwa; XWindowAttributes xwa;
XSync(x11_display, False); XSync(x11_display, False);
@ -2398,6 +2412,9 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co
case WINDOW_FLAG_NO_FOCUS: { case WINDOW_FLAG_NO_FOCUS: {
return wd.no_focus; return wd.no_focus;
} break; } break;
case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
return wd.mpass;
} break;
case WINDOW_FLAG_POPUP: { case WINDOW_FLAG_POPUP: {
return wd.is_popup; return wd.is_popup;
} break; } break;

View file

@ -149,6 +149,8 @@ class DisplayServerX11 : public DisplayServer {
Callable input_text_callback; Callable input_text_callback;
Callable drop_files_callback; Callable drop_files_callback;
Vector<Vector2> mpath;
WindowID transient_parent = INVALID_WINDOW_ID; WindowID transient_parent = INVALID_WINDOW_ID;
HashSet<WindowID> transient_children; HashSet<WindowID> transient_children;
@ -169,6 +171,7 @@ class DisplayServerX11 : public DisplayServer {
bool maximized = false; bool maximized = false;
bool is_popup = false; bool is_popup = false;
bool layered_window = false; bool layered_window = false;
bool mpass = false;
Rect2i parent_safe_rect; Rect2i parent_safe_rect;
@ -245,6 +248,7 @@ class DisplayServerX11 : public DisplayServer {
Atom _process_selection_request_target(Atom p_target, Window p_requestor, Atom p_property, Atom p_selection) const; Atom _process_selection_request_target(Atom p_target, Window p_requestor, Atom p_property, Atom p_selection) const;
void _handle_selection_request_event(XSelectionRequestEvent *p_event) const; void _handle_selection_request_event(XSelectionRequestEvent *p_event) const;
void _update_window_mouse_passthrough(WindowID p_window);
String _clipboard_get_impl(Atom p_source, Window x11_window, Atom target) const; String _clipboard_get_impl(Atom p_source, Window x11_window, Atom target) const;
String _clipboard_get(Atom p_source, Window x11_window) const; String _clipboard_get(Atom p_source, Window x11_window) const;

View file

@ -114,6 +114,7 @@ public:
bool resize_disabled = false; bool resize_disabled = false;
bool no_focus = false; bool no_focus = false;
bool is_popup = false; bool is_popup = false;
bool mpass = false;
Rect2i parent_safe_rect; Rect2i parent_safe_rect;
}; };

View file

@ -2974,6 +2974,9 @@ void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, Win
case WINDOW_FLAG_NO_FOCUS: { case WINDOW_FLAG_NO_FOCUS: {
wd.no_focus = p_enabled; wd.no_focus = p_enabled;
} break; } break;
case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
wd.mpass = p_enabled;
} break;
case WINDOW_FLAG_POPUP: { case WINDOW_FLAG_POPUP: {
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup."); ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
ERR_FAIL_COND_MSG([wd.window_object isVisible] && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened."); ERR_FAIL_COND_MSG([wd.window_object isVisible] && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
@ -3013,6 +3016,9 @@ bool DisplayServerMacOS::window_get_flag(WindowFlags p_flag, WindowID p_window)
case WINDOW_FLAG_NO_FOCUS: { case WINDOW_FLAG_NO_FOCUS: {
return wd.no_focus; return wd.no_focus;
} break; } break;
case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
return wd.mpass;
} break;
case WINDOW_FLAG_POPUP: { case WINDOW_FLAG_POPUP: {
return wd.is_popup; return wd.is_popup;
} break; } break;
@ -3487,7 +3493,11 @@ void DisplayServerMacOS::process_events() {
for (KeyValue<WindowID, WindowData> &E : windows) { for (KeyValue<WindowID, WindowData> &E : windows) {
WindowData &wd = E.value; WindowData &wd = E.value;
if (wd.mpath.size() > 0) { if (wd.mpass) {
if (![wd.window_object ignoresMouseEvents]) {
[wd.window_object setIgnoresMouseEvents:YES];
}
} else if (wd.mpath.size() > 0) {
update_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]); update_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]);
if (Geometry2D::is_point_in_polygon(wd.mouse_pos, wd.mpath)) { if (Geometry2D::is_point_in_polygon(wd.mouse_pos, wd.mpath)) {
if ([wd.window_object ignoresMouseEvents]) { if ([wd.window_object ignoresMouseEvents]) {

View file

@ -735,6 +735,9 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod
if (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) { if (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) {
wd.no_focus = true; wd.no_focus = true;
} }
if (p_flags & WINDOW_FLAG_MOUSE_PASSTHROUGH_BIT) {
wd.mpass = true;
}
if (p_flags & WINDOW_FLAG_POPUP_BIT) { if (p_flags & WINDOW_FLAG_POPUP_BIT) {
wd.is_popup = true; wd.is_popup = true;
} }
@ -918,7 +921,7 @@ void DisplayServerWindows::window_set_mouse_passthrough(const Vector<Vector2> &p
void DisplayServerWindows::_update_window_mouse_passthrough(WindowID p_window) { void DisplayServerWindows::_update_window_mouse_passthrough(WindowID p_window) {
ERR_FAIL_COND(!windows.has(p_window)); ERR_FAIL_COND(!windows.has(p_window));
if (windows[p_window].mpath.size() == 0) { if (windows[p_window].mpass || windows[p_window].mpath.size() == 0) {
SetWindowRgn(windows[p_window].hWnd, nullptr, TRUE); SetWindowRgn(windows[p_window].hWnd, nullptr, TRUE);
} else { } else {
POINT *points = (POINT *)memalloc(sizeof(POINT) * windows[p_window].mpath.size()); POINT *points = (POINT *)memalloc(sizeof(POINT) * windows[p_window].mpath.size());
@ -1499,6 +1502,10 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
wd.no_focus = p_enabled; wd.no_focus = p_enabled;
_update_window_style(p_window); _update_window_style(p_window);
} break; } break;
case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
wd.mpass = p_enabled;
_update_window_mouse_passthrough(p_window);
} break;
case WINDOW_FLAG_POPUP: { case WINDOW_FLAG_POPUP: {
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup."); ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
ERR_FAIL_COND_MSG(IsWindowVisible(wd.hWnd) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened."); ERR_FAIL_COND_MSG(IsWindowVisible(wd.hWnd) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
@ -1530,6 +1537,9 @@ bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window
case WINDOW_FLAG_NO_FOCUS: { case WINDOW_FLAG_NO_FOCUS: {
return wd.no_focus; return wd.no_focus;
} break; } break;
case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
return wd.mpass;
} break;
case WINDOW_FLAG_POPUP: { case WINDOW_FLAG_POPUP: {
return wd.is_popup; return wd.is_popup;
} break; } break;
@ -2464,6 +2474,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
// Process window messages. // Process window messages.
switch (uMsg) { switch (uMsg) {
case WM_NCHITTEST: {
if (windows[window_id].mpass) {
return HTTRANSPARENT;
}
} break;
case WM_MOUSEACTIVATE: { case WM_MOUSEACTIVATE: {
if (windows[window_id].no_focus) { if (windows[window_id].no_focus) {
return MA_NOACTIVATEANDEAT; // Do not activate, and discard mouse messages. return MA_NOACTIVATEANDEAT; // Do not activate, and discard mouse messages.

View file

@ -370,6 +370,7 @@ class DisplayServerWindows : public DisplayServer {
bool window_has_focus = false; bool window_has_focus = false;
bool exclusive = false; bool exclusive = false;
bool context_created = false; bool context_created = false;
bool mpass = false;
// Used to transfer data between events using timer. // Used to transfer data between events using timer.
WPARAM saved_wparam; WPARAM saved_wparam;

View file

@ -1256,6 +1256,7 @@ void Viewport::_gui_show_tooltip() {
panel->set_transient(true); panel->set_transient(true);
panel->set_flag(Window::FLAG_NO_FOCUS, true); panel->set_flag(Window::FLAG_NO_FOCUS, true);
panel->set_flag(Window::FLAG_POPUP, false); panel->set_flag(Window::FLAG_POPUP, false);
panel->set_flag(Window::FLAG_MOUSE_PASSTHROUGH, true);
panel->set_wrap_controls(true); panel->set_wrap_controls(true);
panel->add_child(base_tooltip); panel->add_child(base_tooltip);
panel->gui_parent = this; panel->gui_parent = this;

View file

@ -489,6 +489,7 @@ void Window::_make_window() {
ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID); ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID);
DisplayServer::get_singleton()->window_set_max_size(Size2i(), window_id); DisplayServer::get_singleton()->window_set_max_size(Size2i(), window_id);
DisplayServer::get_singleton()->window_set_min_size(Size2i(), window_id); DisplayServer::get_singleton()->window_set_min_size(Size2i(), window_id);
DisplayServer::get_singleton()->window_set_mouse_passthrough(mpath, window_id);
String tr_title = atr(title); String tr_title = atr(title);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (window_id == DisplayServer::MAIN_WINDOW_ID) { if (window_id == DisplayServer::MAIN_WINDOW_ID) {
@ -1235,6 +1236,18 @@ DisplayServer::WindowID Window::get_window_id() const {
return window_id; return window_id;
} }
void Window::set_mouse_passthrough_polygon(const Vector<Vector2> &p_region) {
mpath = p_region;
if (window_id == DisplayServer::INVALID_WINDOW_ID) {
return;
}
DisplayServer::get_singleton()->window_set_mouse_passthrough(mpath, window_id);
}
Vector<Vector2> Window::get_mouse_passthrough_polygon() const {
return mpath;
}
void Window::set_wrap_controls(bool p_enable) { void Window::set_wrap_controls(bool p_enable) {
wrap_controls = p_enable; wrap_controls = p_enable;
if (wrap_controls) { if (wrap_controls) {
@ -2163,6 +2176,9 @@ void Window::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &Window::set_use_font_oversampling); ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &Window::set_use_font_oversampling);
ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &Window::is_using_font_oversampling); ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &Window::is_using_font_oversampling);
ClassDB::bind_method(D_METHOD("set_mouse_passthrough_polygon", "polygon"), &Window::set_mouse_passthrough_polygon);
ClassDB::bind_method(D_METHOD("get_mouse_passthrough_polygon"), &Window::get_mouse_passthrough_polygon);
ClassDB::bind_method(D_METHOD("set_wrap_controls", "enable"), &Window::set_wrap_controls); ClassDB::bind_method(D_METHOD("set_wrap_controls", "enable"), &Window::set_wrap_controls);
ClassDB::bind_method(D_METHOD("is_wrapping_controls"), &Window::is_wrapping_controls); ClassDB::bind_method(D_METHOD("is_wrapping_controls"), &Window::is_wrapping_controls);
ClassDB::bind_method(D_METHOD("child_controls_changed"), &Window::child_controls_changed); ClassDB::bind_method(D_METHOD("child_controls_changed"), &Window::child_controls_changed);
@ -2243,6 +2259,8 @@ void Window::_bind_methods() {
} }
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen", PROPERTY_HINT_ENUM, screen_hints), "set_current_screen", "get_current_screen"); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen", PROPERTY_HINT_ENUM, screen_hints), "set_current_screen", "get_current_screen");
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "mouse_passthrough_polygon"), "set_mouse_passthrough_polygon", "get_mouse_passthrough_polygon");
ADD_GROUP("Flags", ""); ADD_GROUP("Flags", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls");
@ -2255,6 +2273,7 @@ void Window::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unfocusable"), "set_flag", "get_flag", FLAG_NO_FOCUS); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unfocusable"), "set_flag", "get_flag", FLAG_NO_FOCUS);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "popup_window"), "set_flag", "get_flag", FLAG_POPUP); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "popup_window"), "set_flag", "get_flag", FLAG_POPUP);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "extend_to_title"), "set_flag", "get_flag", FLAG_EXTEND_TO_TITLE); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "extend_to_title"), "set_flag", "get_flag", FLAG_EXTEND_TO_TITLE);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "mouse_passthrough"), "set_flag", "get_flag", FLAG_MOUSE_PASSTHROUGH);
ADD_GROUP("Limits", ""); ADD_GROUP("Limits", "");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "min_size", PROPERTY_HINT_NONE, "suffix:px"), "set_min_size", "get_min_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "min_size", PROPERTY_HINT_NONE, "suffix:px"), "set_min_size", "get_min_size");
@ -2302,6 +2321,7 @@ void Window::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_NO_FOCUS); BIND_ENUM_CONSTANT(FLAG_NO_FOCUS);
BIND_ENUM_CONSTANT(FLAG_POPUP); BIND_ENUM_CONSTANT(FLAG_POPUP);
BIND_ENUM_CONSTANT(FLAG_EXTEND_TO_TITLE); BIND_ENUM_CONSTANT(FLAG_EXTEND_TO_TITLE);
BIND_ENUM_CONSTANT(FLAG_MOUSE_PASSTHROUGH);
BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(FLAG_MAX);
BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_DISABLED); BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_DISABLED);

View file

@ -59,6 +59,7 @@ public:
FLAG_NO_FOCUS = DisplayServer::WINDOW_FLAG_NO_FOCUS, FLAG_NO_FOCUS = DisplayServer::WINDOW_FLAG_NO_FOCUS,
FLAG_POPUP = DisplayServer::WINDOW_FLAG_POPUP, FLAG_POPUP = DisplayServer::WINDOW_FLAG_POPUP,
FLAG_EXTEND_TO_TITLE = DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE, FLAG_EXTEND_TO_TITLE = DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE,
FLAG_MOUSE_PASSTHROUGH = DisplayServer::WINDOW_FLAG_MOUSE_PASSTHROUGH,
FLAG_MAX = DisplayServer::WINDOW_FLAG_MAX, FLAG_MAX = DisplayServer::WINDOW_FLAG_MAX,
}; };
@ -101,6 +102,7 @@ private:
mutable Size2i size = Size2i(DEFAULT_WINDOW_SIZE, DEFAULT_WINDOW_SIZE); mutable Size2i size = Size2i(DEFAULT_WINDOW_SIZE, DEFAULT_WINDOW_SIZE);
mutable Size2i min_size; mutable Size2i min_size;
mutable Size2i max_size; mutable Size2i max_size;
mutable Vector<Vector2> mpath;
mutable Mode mode = MODE_WINDOWED; mutable Mode mode = MODE_WINDOWED;
mutable bool flags[FLAG_MAX] = {}; mutable bool flags[FLAG_MAX] = {};
bool visible = true; bool visible = true;
@ -281,6 +283,9 @@ public:
void set_use_font_oversampling(bool p_oversampling); void set_use_font_oversampling(bool p_oversampling);
bool is_using_font_oversampling() const; bool is_using_font_oversampling() const;
void set_mouse_passthrough_polygon(const Vector<Vector2> &p_region);
Vector<Vector2> get_mouse_passthrough_polygon() const;
void set_wrap_controls(bool p_enable); void set_wrap_controls(bool p_enable);
bool is_wrapping_controls() const; bool is_wrapping_controls() const;
void child_controls_changed(); void child_controls_changed();

View file

@ -848,6 +848,7 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS); BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS);
BIND_ENUM_CONSTANT(WINDOW_FLAG_POPUP); BIND_ENUM_CONSTANT(WINDOW_FLAG_POPUP);
BIND_ENUM_CONSTANT(WINDOW_FLAG_EXTEND_TO_TITLE); BIND_ENUM_CONSTANT(WINDOW_FLAG_EXTEND_TO_TITLE);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MOUSE_PASSTHROUGH);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX); BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER); BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER);

View file

@ -311,6 +311,7 @@ public:
WINDOW_FLAG_NO_FOCUS, WINDOW_FLAG_NO_FOCUS,
WINDOW_FLAG_POPUP, WINDOW_FLAG_POPUP,
WINDOW_FLAG_EXTEND_TO_TITLE, WINDOW_FLAG_EXTEND_TO_TITLE,
WINDOW_FLAG_MOUSE_PASSTHROUGH,
WINDOW_FLAG_MAX, WINDOW_FLAG_MAX,
}; };
@ -323,6 +324,7 @@ public:
WINDOW_FLAG_NO_FOCUS_BIT = (1 << WINDOW_FLAG_NO_FOCUS), WINDOW_FLAG_NO_FOCUS_BIT = (1 << WINDOW_FLAG_NO_FOCUS),
WINDOW_FLAG_POPUP_BIT = (1 << WINDOW_FLAG_POPUP), WINDOW_FLAG_POPUP_BIT = (1 << WINDOW_FLAG_POPUP),
WINDOW_FLAG_EXTEND_TO_TITLE_BIT = (1 << WINDOW_FLAG_EXTEND_TO_TITLE), WINDOW_FLAG_EXTEND_TO_TITLE_BIT = (1 << WINDOW_FLAG_EXTEND_TO_TITLE),
WINDOW_FLAG_MOUSE_PASSTHROUGH_BIT = (1 << WINDOW_FLAG_MOUSE_PASSTHROUGH),
}; };
virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()); virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i());