[Spice-devel] [PATCH spice] spicec-x11: Let the window manager place our window the 1st time (rhbz#662407)
Alon Levy
alevy at redhat.com
Thu Dec 16 02:17:22 PST 2010
On Wed, Dec 15, 2010 at 08:56:39PM +0100, Hans de Goede wrote:
> 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
ACK
> ---
> client/x11/red_window.cpp | 8 +++++++-
> client/x11/red_window_p.h | 1 +
> 2 files changed, 8 insertions(+), 1 deletions(-)
>
> 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
> --
> 1.7.3.2
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list