diff options
Diffstat (limited to 'scene/main/window.cpp')
-rw-r--r-- | scene/main/window.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp index ebe9587b31..f7099f3765 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -389,9 +389,24 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) { _propagate_window_notification(this, NOTIFICATION_WM_DPI_CHANGE); emit_signal(SNAME("dpi_changed")); } break; + case DisplayServer::WINDOW_EVENT_TITLEBAR_CHANGE: { + emit_signal(SNAME("titlebar_changed")); + } break; } } +void Window::update_mouse_cursor_shape() { + // The default shape is set in Viewport::_gui_input_event. To instantly + // see the shape in the viewport we need to trigger a mouse motion event. + Ref<InputEventMouseMotion> mm; + Vector2 pos = get_mouse_position(); + Transform2D xform = get_global_canvas_transform().affine_inverse(); + mm.instantiate(); + mm->set_position(pos); + mm->set_global_position(xform.xform(pos)); + push_input(mm); +} + void Window::show() { set_visible(true); } @@ -1248,6 +1263,19 @@ void Window::popup(const Rect2i &p_screen_rect) { set_transient(true); set_visible(true); + + Rect2i parent_rect; + if (is_embedded()) { + parent_rect = _get_embedder()->get_visible_rect(); + } else { + int screen_id = DisplayServer::get_singleton()->window_get_current_screen(get_window_id()); + parent_rect = DisplayServer::get_singleton()->screen_get_usable_rect(screen_id); + } + if (parent_rect != Rect2i() && !parent_rect.intersects(Rect2i(position, size))) { + ERR_PRINT(vformat("Window %d spawned at invalid position: %s.", get_window_id(), position)); + set_position((parent_rect.size - size) / 2); + } + _post_popup(); notification(NOTIFICATION_POST_POPUP); } @@ -1782,6 +1810,7 @@ void Window::_bind_methods() { ADD_SIGNAL(MethodInfo("visibility_changed")); ADD_SIGNAL(MethodInfo("about_to_popup")); ADD_SIGNAL(MethodInfo("theme_changed")); + ADD_SIGNAL(MethodInfo("titlebar_changed")); BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED); BIND_CONSTANT(NOTIFICATION_THEME_CHANGED); |