[Spice-commits] Branch '0.6' - 6 commits - client/application.cpp client/red_channel.cpp client/red_client.cpp client/x11 server/red_worker.c

Hans de Goede jwrdegoede at kemper.freedesktop.org
Thu Dec 16 07:25:57 PST 2010


 client/application.cpp    |    6 ++++++
 client/red_channel.cpp    |   12 +++++++-----
 client/red_client.cpp     |    2 +-
 client/x11/red_window.cpp |   19 +++++++++++++++++--
 client/x11/red_window_p.h |    1 +
 server/red_worker.c       |    2 +-
 6 files changed, 33 insertions(+), 9 deletions(-)

New commits:
commit c55e5a5be3d870f43e3100357af77023bfe6a84f
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Wed Dec 15 15:25:07 2010 +0100

    spicec-x11: Let the window manager place our window the 1st time (rhbz#662407)
    
    The problem is that RedWindow::show calls the XLib MoveWindow function
    on the window after it has been mapped, moving it to the location in
    _show_pos. This is seen by the window manager as the application saying
    I know exactly where I want my window to be placed, don't do placing for
    me. Which causes the client window to always be shown at pos 0x0, even
    though that may not be the best location.
    
    What this patch does is:
    1) It makes RedWindow::show not call MoveWindow when a window is
       first created normally and then shown
    2) It makes RedWindow::show still call MoveWindow when:
       -when the window has been shown before, and was hidden for some
        reason (controller interface), and is now being re-shown
        so that it ends up being re-shown at its old position
       -when the window is a fullscreen window (screen.cpp always
        calls move on the window before showing it to set its position)
       -when the user switch from windowed mode -> fullscreen ->
        windowed mode again, to make sure that the windowed mode window
        is shown in the same position as before switching to fullscreen
        mode

diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 569cf4e..d7b19f9 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -1123,6 +1123,7 @@ Cursor RedWindow_p::create_invisible_cursor(Window window)
 
 RedWindow_p::RedWindow_p()
     : _win (None)
+    , _show_pos_valid (false)
 #ifdef USE_OGL
     , _glcont_copy (NULL)
 #endif // USE_OGL
@@ -1565,7 +1566,9 @@ void RedWindow::show(int screen_id)
     move_to_current_desktop();
     _expect_parent = wait_parent;
     wait_for_map();
-    move(_show_pos.x, _show_pos.y);
+    if (_show_pos_valid) {
+        move(_show_pos.x, _show_pos.y);
+    }
 }
 
 static bool get_prop_32(Window win, Atom prop, uint32_t &val)
@@ -1644,6 +1647,7 @@ void RedWindow::hide()
     on_focus_out();
     XUnmapWindow(x_display, _win);
     _show_pos = get_position();
+    _show_pos_valid = true;
     wait_for_unmap();
     ASSERT(!_focused);
     ASSERT(!_pointer_in_window);
@@ -1672,6 +1676,7 @@ void RedWindow::move_and_resize(int x, int y, int width, int height)
     XMoveResizeWindow(x_display, _win, x, y, width, height);
     _show_pos.x = x;
     _show_pos.y = y;
+    _show_pos_valid = true;
     if (_visibale) {
         send_expose(_win, width, height);
     }
@@ -1682,6 +1687,7 @@ void RedWindow::move(int x, int y)
     XMoveWindow(x_display, _win, x, y);
     _show_pos.x = x;
     _show_pos.y = y;
+    _show_pos_valid = true;
 }
 
 void RedWindow::resize(int width, int height)
diff --git a/client/x11/red_window_p.h b/client/x11/red_window_p.h
index 777a855..6f05a90 100644
--- a/client/x11/red_window_p.h
+++ b/client/x11/red_window_p.h
@@ -66,6 +66,7 @@ protected:
     bool _visibale;
     bool _expect_parent;
     SpicePoint _show_pos;
+    bool _show_pos_valid;
 #ifdef USE_OGL
     GLXContext _glcont_copy;
 #endif // USE_OGL
commit f2eceb91c70ce6203a910084da5915eda8db95e9
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Wed Dec 15 16:43:19 2010 +0100

    spicec-x11: Add a class hint to our window managet hints
    
    This helps people who want to tell their windowmanager to do something special
    with spicec, like make it sticky, or whatever, see:
    https://bugzilla.redhat.com/show_bug.cgi?id=662452#c4

diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 6e8cd58..569cf4e 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -1213,6 +1213,7 @@ void RedWindow_p::create(RedWindow& red_window, PixelsSource_p& pix_source,
 
     try {
         int res;
+        XClassHint *class_hint;
 
         XLockDisplay(x_display);
         res = XSaveContext(x_display, window, user_data_context, (XPointer)&red_window);
@@ -1222,8 +1223,16 @@ void RedWindow_p::create(RedWindow& red_window, PixelsSource_p& pix_source,
         }
 
         XSetWMProtocols(x_display, window, &wm_delete_window_atom, 1);
-        XGCValues gc_vals;
+        class_hint = XAllocClassHint();
+        if (!class_hint) {
+            THROW("allocating class hint failed");
+        }
+        class_hint->res_name = (char *)"spicec";
+        class_hint->res_class = (char *)"spicec";
+        XSetClassHint(x_display, window, class_hint);
+        XFree(class_hint);
 
+        XGCValues gc_vals;
         XLockDisplay(x_display);
         gc = XCreateGC(x_display, window, 0, &gc_vals);
         XUnlockDisplay(x_display);
commit 4009747d2c901dda03996a2abeabefccfc450e0f
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Mon Dec 13 15:37:37 2010 +0100

    spicec: Add a --title cmdline option (rhbz#662452)

diff --git a/client/application.cpp b/client/application.cpp
index c380373..8d5264b 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -2177,6 +2177,7 @@ bool Application::process_cmd_line(int argc, char** argv)
         SPICE_OPT_DISPLAY_COLOR_DEPTH,
         SPICE_OPT_DISABLE_DISPLAY_EFFECTS,
         SPICE_OPT_CONTROLLER,
+        SPICE_OPT_TITLE,
     };
 
 #ifdef USE_GUI
@@ -2235,6 +2236,8 @@ bool Application::process_cmd_line(int argc, char** argv)
 
     parser.add(SPICE_OPT_CONTROLLER, "controller", "enable external controller");
 
+    parser.add(SPICE_OPT_TITLE, "title", "set window title", "title", true, 't');
+
     for (int i = SPICE_CHANNEL_MAIN; i < SPICE_END_CHANNEL; i++) {
         _peer_con_opt[i] = RedPeer::ConnectionOptions::CON_OP_INVALID;
     }
@@ -2340,6 +2343,9 @@ bool Application::process_cmd_line(int argc, char** argv)
             }
             _enable_controller = true;
             return true;
+        case SPICE_OPT_TITLE:
+            set_title(val);
+            break;
         case CmdLineParser::OPTION_HELP:
             parser.show_help();
             return false;
commit 367a5c8c3ae81dec30941586482c5168db6658e1
Author: Alon Levy <alevy at redhat.com>
Date:   Wed Dec 15 14:43:45 2010 +0200

    server/red_worker: fix worker->drawable_count
    
    drawable_count was becoming negative. It tracks the number of
    items in the worker->current_list ring. It was decremented correctly,
    but incremented only in several cases. The cases it wasn't incremented
    where:
     red_current_add_equal found an equivalent drawable
    by moving the increment to where the item is added to current_list, in
    __current_add_drawable, the accounting remains correct.
    
    This has no affect other then correct accounting, as drawable_count isn't
    used for anything.

diff --git a/server/red_worker.c b/server/red_worker.c
index d59726f..937e0aa 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -2136,6 +2136,7 @@ static inline void __current_add_drawable(RedWorker *worker, Drawable *drawable,
     surface = &worker->surfaces[surface_id];
     ring_add_after(&drawable->tree_item.base.siblings_link, pos);
     ring_add(&worker->current_list, &drawable->list_link);
+    worker->drawable_count++;
     ring_add(&surface->current_list, &drawable->surface_list_link);
     drawable->refs++;
 }
@@ -3501,7 +3502,6 @@ static inline void red_process_drawable(RedWorker *worker, RedDrawable *drawable
 
     if (red_current_add_qxl(worker, &worker->surfaces[surface_id].current, item,
                             drawable)) {
-        worker->drawable_count++;
         if (item->tree_item.effect != QXL_EFFECT_OPAQUE) {
             worker->transparent_count++;
         }
commit 9ca2be9047d9f8efb31b238c68fc5426a22ee462
Author: Arnon Gilboa <agilboa at redhat.com>
Date:   Tue Dec 7 12:44:34 2010 +0200

    spicec: do not call connect_secure when connect_unsecure fails due to protocol version mismatch (v2)
    
    If connect_unsecure failed due to protocol version mismatch, don't try to
    connect_secure with the same version, but retry (connect_secure or
    connect_unsecure) with older version. catch (...) is handled by caller
    at RedChannel::run().
    
    This solves the following bug: when "new" Spice client (protocol version 2)
    with given secure_port connects to "old" server which is not using the same
    secure_port (or not using a secure_port at all), the client exits immediately.
    
    In this scenario, the client first tries to use Spice protocol version 2 to
    connect the unsecure port, and altough this fails due to version mismatch, it
    tries to connect to the secure port with the same protocol version 2, which is
    a wrong behavior, fails due to socket error 10061 (WSAECONNREFUSED -
    Connection refused) and handled mistakenly by immediate exit, instead of
    retrying with protocol version 1.

diff --git a/client/red_channel.cpp b/client/red_channel.cpp
index 273b28d..f4cdf52 100644
--- a/client/red_channel.cpp
+++ b/client/red_channel.cpp
@@ -217,8 +217,10 @@ void RedChannelBase::connect(const ConnectionOptions& options, uint32_t connecti
                 RedPeer::connect_unsecure(host, options.unsecure_port);
                 link(connection_id, password, protocol);
                 return;
-            } catch (...) {
-                if (!options.allow_secure()) {
+            } catch (Exception& e) {
+                // On protocol version mismatch, don't connect_secure with the same version
+                if (e.get_error_code() == SPICEC_ERROR_CODE_VERSION_MISMATCH ||
+                                                        !options.allow_secure()) {
                     throw;
                 }
                 RedPeer::close();
@@ -228,9 +230,9 @@ void RedChannelBase::connect(const ConnectionOptions& options, uint32_t connecti
         RedPeer::connect_secure(options, host);
         link(connection_id, password, protocol);
     } catch (Exception& e) {
-        if (protocol == 2 &&
-            options.protocol == 0 &&
-            e.get_error_code() == SPICEC_ERROR_CODE_VERSION_MISMATCH) {
+        // On protocol version mismatch, retry with older version
+        if (e.get_error_code() == SPICEC_ERROR_CODE_VERSION_MISMATCH &&
+                                 protocol == 2 && options.protocol == 0) {
             RedPeer::cleanup();
             protocol = 1;
             goto retry;
commit c1880e8f322f98ae2bd0186c210531d8f8282b28
Author: Arnon Gilboa <agilboa at redhat.com>
Date:   Tue Nov 23 17:33:31 2010 +0200

    spicec: fix ASSERT to accept size == 0
    
    which is useful when calling RedClient::on_clipboard_notify(VD_AGENT_CLIPBOARD_NONE, NULL, 0);

diff --git a/client/red_client.cpp b/client/red_client.cpp
index 0fc4815..46d5602 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -888,7 +888,7 @@ void RedClient::on_clipboard_release()
 
 void RedClient::send_agent_clipboard_notify_message(uint32_t type, uint8_t *data, uint32_t size)
 {
-    ASSERT(size && data);
+    ASSERT(data || !size);
     if (!_agent_connected) {
         return;
     }


More information about the Spice-commits mailing list