[Spice-commits] 3 commits - client/application.cpp client/x11

Hans de Goede jwrdegoede at kemper.freedesktop.org
Thu Dec 16 05:50:24 PST 2010


 client/application.cpp    |    6 ++++++
 client/x11/red_window.cpp |   19 +++++++++++++++++--
 client/x11/red_window_p.h |    1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 3e37f2c1e876949a1ce63ab8a1a1b022b4037b69
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 4081d67162bd34dc5b6a3cc574abd9aba760acd5
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 e47fb5d74fb02f87c66a22105c08d6caa0571c1a
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 8f41ccf..1bd3ff4 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -2215,6 +2215,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_SMARTCARD
         SPICE_OPT_SMARTCARD,
         SPICE_OPT_NOSMARTCARD,
@@ -2279,6 +2280,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');
+
 #ifdef USE_SMARTCARD
     parser.add(SPICE_OPT_SMARTCARD, "smartcard", "enable smartcard channel");
     parser.add(SPICE_OPT_NOSMARTCARD, "nosmartcard", "disable smartcard channel");
@@ -2393,6 +2396,9 @@ bool Application::process_cmd_line(int argc, char** argv)
             }
             _enable_controller = true;
             return true;
+        case SPICE_OPT_TITLE:
+            set_title(val);
+            break;
 #ifdef USE_SMARTCARD
         case SPICE_OPT_SMARTCARD:
             _smartcard_options->enable= true;


More information about the Spice-commits mailing list