[Spice-commits] Branch '0.8' - 4 commits - client/application.cpp client/controller.cpp client/foreign_menu.cpp client/foreign_menu.h client/red_window.h client/screen.cpp client/screen.h client/windows client/x11

Uri Lublin uril at kemper.freedesktop.org
Wed Dec 21 10:09:53 PST 2011


 client/application.cpp        |    2 +-
 client/controller.cpp         |    2 +-
 client/foreign_menu.cpp       |    6 +++---
 client/foreign_menu.h         |    2 +-
 client/red_window.h           |    2 +-
 client/screen.cpp             |    7 ++++++-
 client/screen.h               |    1 +
 client/windows/red_window.cpp |   14 +++++++++++---
 client/x11/red_window.cpp     |    3 ++-
 9 files changed, 27 insertions(+), 12 deletions(-)

New commits:
commit df17a852fa23ab2bb47038313eda78f6614dd7f0
Author: Uri Lublin <uril at redhat.com>
Date:   Tue Dec 13 17:09:58 2011 +0200

    client: foreign-menu: pass "active" param when creating a ForeignMenu (#769020)
    
    The default stays the same -- false.
    
    A race could prevent setting ForeignMenu::_active correctly.
    That happened when Application::on_app_activated was called before
    _foriegn_menu was created. When foriegn_menu was created its
    _active defaults to false, and that has not changed, until focus
    was taken out and back in spice-client window.
    
    This caused usbrdr to sometimes not auto-share devices, unless
    the user switched focus to a different application and back to
    spicec.
    
    The fix updates ForiegnMenu::_active upon creation.
    (cherry picked from commit fdcef173645e564be71f1b73d476c0716e91663d)

diff --git a/client/application.cpp b/client/application.cpp
index 634fcdd..2a9ac79 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -594,7 +594,7 @@ int Application::run()
 
 void Application::on_start_running()
 {
-    _foreign_menu.reset(new ForeignMenu(this));
+    _foreign_menu.reset(new ForeignMenu(this, _active));
     if (_enable_controller) {
         _controller.reset(new Controller(this));
         return;
diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
index 988583a..ebe2d5c 100644
--- a/client/foreign_menu.cpp
+++ b/client/foreign_menu.cpp
@@ -33,9 +33,9 @@
 #define PIPE_NAME "/tmp/SpiceForeignMenu-%lu.uds"
 #endif
 
-ForeignMenu::ForeignMenu(ForeignMenuInterface *handler)
+ForeignMenu::ForeignMenu(ForeignMenuInterface *handler, bool active)
     : _handler (handler)
-    , _active (false)
+    , _active (active)
     , _refs (1)
 {
     char pipe_name[PIPE_NAME_MAX_LEN];
diff --git a/client/foreign_menu.h b/client/foreign_menu.h
index 2fc4e53..6138087 100644
--- a/client/foreign_menu.h
+++ b/client/foreign_menu.h
@@ -38,7 +38,7 @@ public:
 
 class ForeignMenu : public NamedPipe::ListenerInterface {
 public:
-    ForeignMenu(ForeignMenuInterface *handler);
+    ForeignMenu(ForeignMenuInterface *handler, bool active = false);
     virtual ~ForeignMenu();
 
     ForeignMenu* ref() { _refs++; return this;}
commit 7d8cc134bf0b2175cae69c08bfe07b859d45a306
Author: Uri Lublin <uril at redhat.com>
Date:   Tue Dec 20 14:46:50 2011 +0200

    client: update menu if needed when exiting full-screen mode (#758260)
    (cherry picked from commit a91b0b3ff712eb2a7d91a951f2af7842495357c3)

diff --git a/client/screen.cpp b/client/screen.cpp
index e085781..851c74d 100644
--- a/client/screen.cpp
+++ b/client/screen.cpp
@@ -97,6 +97,7 @@ RedScreen::RedScreen(Application& owner, int id, const std::string& name, int wi
     , _mouse_captured (false)
     , _active_layer_change_event (false)
     , _pointer_on_screen (false)
+    , _menu_needs_update (false)
 {
     region_init(&_dirty_region);
     set_name(name);
@@ -781,6 +782,9 @@ void RedScreen::exit_full_screen()
     _origin.x = _origin.y = 0;
     _window.set_origin(0, 0);
     show();
+    if (_menu_needs_update) {
+        update_menu();
+    }
     _full_screen = false;
     _out_of_sync = false;
     _frame_area = false;
@@ -872,7 +876,8 @@ void RedScreen::external_show()
 void RedScreen::update_menu()
 {
     AutoRef<Menu> menu(_owner.get_app_menu());
-    _window.set_menu(*menu);
+    int ret = _window.set_menu(*menu);
+    _menu_needs_update = (ret != 0); /* try again if menu update failed */
 }
 
 void RedScreen::on_exposed_rect(const SpiceRect& area)
diff --git a/client/screen.h b/client/screen.h
index e7db4ef..3b28aae 100644
--- a/client/screen.h
+++ b/client/screen.h
@@ -178,6 +178,7 @@ private:
     bool _key_interception;
     bool _update_by_timer;
     bool _size_locked;
+    bool _menu_needs_update;
     int _forec_update_timer;
     AutoRef<UpdateTimer> _update_timer;
     RedDrawable* _composit_area;
commit 67e785f4fc853985ae968b44280c8985651e41ac
Author: Uri Lublin <uril at redhat.com>
Date:   Tue Dec 20 16:36:13 2011 +0200

    client: menu: make RedWindow::set_menu() return an error-code (#758260)
    
    RedWindow::set_menu() can fail (on Windows when in fullscreen mode).
    For Windows spice-client, when in fullscreen mode, the system-menu
    is NULL.
    
    Returns 0 upon success, non-0 (currently only -1) upon failure.
    
    (cherry picked from commit 24d5852611c3d5be3ba824af64cd5a3356b82b9c)
    (seperator vs separator --> a small typo that got fixed)

diff --git a/client/red_window.h b/client/red_window.h
index 632564d..56a90cf 100644
--- a/client/red_window.h
+++ b/client/red_window.h
@@ -70,7 +70,7 @@ public:
     void release_mouse();
     void start_key_interception();
     void stop_key_interception();
-    void set_menu(Menu* menu);
+    int set_menu(Menu* menu);
 
 #ifdef USE_OGL
     void untouch_context();
diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp
index 43587e1..188c772 100644
--- a/client/windows/red_window.cpp
+++ b/client/windows/red_window.cpp
@@ -1066,18 +1066,26 @@ void RedWindow_p::release_menu(Menu* menu)
     }
 }
 
-void RedWindow::set_menu(Menu* menu)
+int RedWindow::set_menu(Menu* menu)
 {
     release_menu(_menu);
     _menu = NULL;
 
     if (!menu) {
-        return;
+        return 0;
     }
-    _menu = menu->ref();
+
     _sys_menu = GetSystemMenu(_win, FALSE);
+    if (! _sys_menu) {
+        return -1;
+    }
+
+    _menu = menu->ref();
+
     insert_seperator(_sys_menu);
     insert_menu(_menu, _sys_menu, _commands_map);
+
+    return 0;
 }
 
 static LRESULT CALLBACK MessageFilterProc(int nCode, WPARAM wParam, LPARAM lParam)
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index cfc10c5..3be53ad 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -2215,8 +2215,9 @@ void RedWindow::on_pointer_leave()
     }
 }
 
-void RedWindow::set_menu(Menu* menu)
+int RedWindow::set_menu(Menu* menu)
 {
+    return 0;
 }
 
 void RedWindow::init()
commit baa375e8b51de94ee44466fe416202c29ea43e23
Author: Uri Lublin <uril at redhat.com>
Date:   Tue Dec 6 15:36:38 2011 +0200

    client controller/foreign_menu: use memmove instead of memcpy in readers
    
    When src/dst memory areas may overlap, it's safer to use memmove.
    (cherry picked from commit 5d28d1662e6e415367bb283d051e0a690a8ec2f2)

diff --git a/client/controller.cpp b/client/controller.cpp
index 42abe20..3fed47f 100644
--- a/client/controller.cpp
+++ b/client/controller.cpp
@@ -213,7 +213,7 @@ bool ControllerConnection::read_msgs()
         pos += hdr->size;
     }
     if (nread > 0 && pos != _read_buf) {
-        memcpy(_read_buf, pos, nread);
+        memmove(_read_buf, pos, nread);
     }
     _read_pos = _read_buf + nread;
     return true;
diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
index e5d7459..988583a 100644
--- a/client/foreign_menu.cpp
+++ b/client/foreign_menu.cpp
@@ -234,7 +234,7 @@ bool ForeignMenuConnection::read_msgs()
         pos += hdr->size;
     }
     if (nread > 0 && pos != _read_buf) {
-        memcpy(_read_buf, pos, nread);
+        memmove(_read_buf, pos, nread);
     }
     _read_pos = _read_buf + nread;
     return true;


More information about the Spice-commits mailing list