瀏覽代碼

WindowServer+LibGUI: Remove awkward roundtrip for set wallpaper response

Previously we would wait for a separate message confirming that a
wallpaper got set instead of just calling a synchronous api.

I'm guessing that this was a limitation of the IPC system when
WindowServer got ported to using it.

This patch removes the SetWallpaperFinished message and updates the
set_wallpaper api to synchronously return a success boolean.
networkException 3 年之前
父節點
當前提交
ad060befad

+ 0 - 5
Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp

@@ -368,11 +368,6 @@ void ConnectionToWindowServer::applet_area_rect_changed(Gfx::IntRect const& rect
     });
 }
 
-void ConnectionToWindowServer::set_wallpaper_finished(bool)
-{
-    // This is handled manually by Desktop::set_wallpaper().
-}
-
 void ConnectionToWindowServer::drag_dropped(i32 window_id, Gfx::IntPoint const& mouse_position, String const& text, HashMap<String, ByteBuffer> const& mime_data)
 {
     if (auto* window = Window::from_window_id(window_id)) {

+ 0 - 1
Userland/Libraries/LibGUI/ConnectionToWindowServer.h

@@ -47,7 +47,6 @@ private:
     virtual void menu_visibility_did_change(i32, bool) override;
     virtual void screen_rects_changed(Vector<Gfx::IntRect> const&, u32, u32, u32) override;
     virtual void applet_area_rect_changed(Gfx::IntRect const&) override;
-    virtual void set_wallpaper_finished(bool) override;
     virtual void drag_dropped(i32, Gfx::IntPoint const&, String const&, HashMap<String, ByteBuffer> const&) override;
     virtual void drag_accepted() override;
     virtual void drag_cancelled() override;

+ 4 - 4
Userland/Libraries/LibGUI/Desktop.cpp

@@ -67,14 +67,14 @@ bool Desktop::set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<Strin
         return false;
 
     TemporaryChange is_setting_desktop_wallpaper_change(m_is_setting_desktop_wallpaper, true);
-    ConnectionToWindowServer::the().async_set_wallpaper(wallpaper_bitmap ? wallpaper_bitmap->to_shareable_bitmap() : Gfx::ShareableBitmap {});
-    auto ret_val = ConnectionToWindowServer::the().wait_for_specific_message<Messages::WindowClient::SetWallpaperFinished>()->success();
+    auto result = ConnectionToWindowServer::the().set_wallpaper(wallpaper_bitmap ? wallpaper_bitmap->to_shareable_bitmap() : Gfx::ShareableBitmap {});
 
-    if (ret_val && path.has_value()) {
+    if (result && path.has_value()) {
         dbgln("Saving wallpaper path '{}' to ConfigServer", *path);
         Config::write_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, *path);
     }
 
-    return ret_val;
+    return result;
 }
+
 }

+ 2 - 3
Userland/Services/WindowServer/ConnectionFromClient.cpp

@@ -305,10 +305,9 @@ void ConnectionFromClient::set_window_opacity(i32 window_id, float opacity)
     it->value->set_opacity(opacity);
 }
 
-void ConnectionFromClient::set_wallpaper(Gfx::ShareableBitmap const& bitmap)
+Messages::WindowServer::SetWallpaperResponse ConnectionFromClient::set_wallpaper(Gfx::ShareableBitmap const& bitmap)
 {
-    Compositor::the().set_wallpaper(bitmap.bitmap());
-    async_set_wallpaper_finished(true);
+    return Compositor::the().set_wallpaper(bitmap.bitmap());
 }
 
 void ConnectionFromClient::set_background_color(String const& background_color)

+ 1 - 1
Userland/Services/WindowServer/ConnectionFromClient.h

@@ -126,7 +126,7 @@ private:
     virtual void set_fullscreen(i32, bool) override;
     virtual void set_frameless(i32, bool) override;
     virtual void set_forced_shadow(i32, bool) override;
-    virtual void set_wallpaper(Gfx::ShareableBitmap const&) override;
+    virtual Messages::WindowServer::SetWallpaperResponse set_wallpaper(Gfx::ShareableBitmap const&) override;
     virtual void set_background_color(String const&) override;
     virtual void set_wallpaper_mode(String const&) override;
     virtual Messages::WindowServer::GetWallpaperResponse get_wallpaper() override;

+ 0 - 2
Userland/Services/WindowServer/WindowClient.ipc

@@ -32,8 +32,6 @@ endpoint WindowClient
 
     applet_area_rect_changed(Gfx::IntRect rect) =|
 
-    set_wallpaper_finished(bool success) =|
-
     drag_accepted() =|
     drag_cancelled() =|
 

+ 1 - 1
Userland/Services/WindowServer/WindowServer.ipc

@@ -104,7 +104,7 @@ endpoint WindowServer
     popup_menu(i32 menu_id, Gfx::IntPoint screen_position) =|
     dismiss_menu(i32 menu_id) =|
 
-    set_wallpaper(Gfx::ShareableBitmap wallpaper_bitmap) =|
+    set_wallpaper(Gfx::ShareableBitmap wallpaper_bitmap) => (bool success)
 
     set_background_color(String background_color) =|
     set_wallpaper_mode(String mode) =|