diff options
Diffstat (limited to 'Userland')
6 files changed, 30 insertions, 7 deletions
diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 8c962e7aae..67cd50daaa 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -295,6 +295,7 @@ void Application::set_drag_hovered_widget_impl(Widget* widget, Gfx::IntPoint con m_drag_hovered_widget->dispatch_event(enter_event, m_drag_hovered_widget->window()); if (enter_event.is_accepted()) set_pending_drop_widget(m_drag_hovered_widget); + ConnectionToWindowServer::the().async_set_accepts_drag(enter_event.is_accepted()); } } diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index c702bf5c3c..3c50949aff 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -824,6 +824,13 @@ Messages::WindowServer::StartDragResponse ConnectionFromClient::start_drag(Strin return true; } +void ConnectionFromClient::set_accepts_drag(bool accepts) +{ + auto& wm = WindowManager::the(); + VERIFY(wm.dnd_client()); + wm.set_accepts_drag(accepts); +} + Messages::WindowServer::SetSystemThemeResponse ConnectionFromClient::set_system_theme(String const& theme_path, String const& theme_name, bool keep_desktop_background) { bool success = WindowManager::the().update_theme(theme_path, theme_name, keep_desktop_background); diff --git a/Userland/Services/WindowServer/ConnectionFromClient.h b/Userland/Services/WindowServer/ConnectionFromClient.h index 222c8f1a7d..9ac48ea202 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.h +++ b/Userland/Services/WindowServer/ConnectionFromClient.h @@ -142,6 +142,7 @@ private: virtual void dismiss_menu(i32) override; virtual void set_window_icon_bitmap(i32, Gfx::ShareableBitmap const&) override; virtual Messages::WindowServer::StartDragResponse start_drag(String const&, HashMap<String, ByteBuffer> const&, Gfx::ShareableBitmap const&) override; + virtual void set_accepts_drag(bool) override; virtual Messages::WindowServer::SetSystemThemeResponse set_system_theme(String const&, String const&, bool keep_desktop_background) override; virtual Messages::WindowServer::GetSystemThemeResponse get_system_theme() override; virtual Messages::WindowServer::SetSystemThemeOverrideResponse set_system_theme_override(Core::AnonymousBuffer const&) override; diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index f4d7f674a1..93c9f654cc 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -1016,14 +1016,13 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event) m_dnd_overlay->cursor_moved(); // We didn't let go of the drag yet, see if we should send some drag move events.. - for_each_visible_window_from_front_to_back([&](Window& window) { - if (!window.rect().contains(event.position())) - return IterationDecision::Continue; + if (auto* window = current_window_stack().window_at(event.position(), WindowStack::IncludeWindowFrame::No)) { event.set_drag(true); event.set_mime_data(*m_dnd_mime_data); - deliver_mouse_event(window, event, false); - return IterationDecision::Break; - }); + deliver_mouse_event(*window, event, false); + } else { + set_accepts_drag(false); + } } if (!(event.type() == Event::MouseUp && event.button() == MouseButton::Primary)) @@ -1918,8 +1917,11 @@ ConnectionFromClient const* WindowManager::active_client() const Cursor const& WindowManager::active_cursor() const { - if (m_dnd_client) + if (m_dnd_client) { + if (m_dnd_accepts_drag) + return *m_drag_copy_cursor; return *m_drag_cursor; + } if (m_move_window) return *m_move_cursor; @@ -2061,6 +2063,14 @@ void WindowManager::end_dnd_drag() m_dnd_client = nullptr; m_dnd_text = {}; m_dnd_overlay = nullptr; + m_dnd_accepts_drag = false; +} + +void WindowManager::set_accepts_drag(bool accepts) +{ + VERIFY(m_dnd_client); + m_dnd_accepts_drag = accepts; + Compositor::the().invalidate_cursor(); } void WindowManager::invalidate_after_theme_or_font_change() diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index 9d532d8215..93b3a8b402 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -96,6 +96,8 @@ public: void start_dnd_drag(ConnectionFromClient&, String const& text, Gfx::Bitmap const*, Core::MimeData const&); void end_dnd_drag(); + void set_accepts_drag(bool); + Window* active_window() { VERIFY(m_current_window_stack); @@ -480,6 +482,7 @@ private: OwnPtr<DndOverlay> m_dnd_overlay; WeakPtr<ConnectionFromClient> m_dnd_client; String m_dnd_text; + bool m_dnd_accepts_drag { false }; RefPtr<Core::MimeData> m_dnd_mime_data; diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index a9f46fd367..20542a518d 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -123,6 +123,7 @@ endpoint WindowServer set_window_custom_cursor(i32 window_id, Gfx::ShareableBitmap cursor) =| start_drag([UTF8] String text, HashMap<String,ByteBuffer> mime_data, Gfx::ShareableBitmap drag_bitmap) => (bool started) + set_accepts_drag(bool accepts) =| set_system_theme(String theme_path, [UTF8] String theme_name, bool keep_desktop_background) => (bool success) get_system_theme() => ([UTF8] String theme_name) |