[PATCH weston 6/6] xwm: set grabbing cursor for the frame grab

Tiago Vignatti tiago.vignatti at intel.com
Wed Jul 11 14:46:15 PDT 2012


This patch sets the cursor for the frame window only.

The other case left is when the client itself performs a grab instead the
titlebar drag. E.g. google-chrome without decoration does move a window (when
click-n-drag the bar on the side of the tabs) but the cursor doesn't set back
to the default one.

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 src/xwayland/window-manager.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index ec5ae0a..1b36a98 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -863,6 +863,7 @@ enum cursor_type {
 	XWM_CURSOR_TOP_RIGHT,
 	XWM_CURSOR_BOTTOM_LEFT,
 	XWM_CURSOR_BOTTOM_RIGHT,
+	XWM_CURSOR_GRABBING,
 	XWM_CURSOR_LEFT_PTR,
 };
 
@@ -875,6 +876,7 @@ static const char *cursors[] = {
 	"top_right_corner",
 	"bottom_left_corner",
 	"bottom_right_corner",
+	"grabbing",
 	"left_ptr"
 };
 
@@ -949,7 +951,7 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
 	struct weston_wm_window *window;
 	enum theme_location location;
 	struct theme *t = wm->theme;
-	int width, height;
+	int width, height, cursor;
 
 	weston_log("XCB_BUTTON_%s (detail %d)\n",
 		button->response_type == XCB_BUTTON_PRESS ?
@@ -967,6 +969,11 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
 
 		switch (location) {
 		case THEME_LOCATION_TITLEBAR:
+			/* desktop client shell will set the grabbing cursor
+			 * regardless but xwayland needs to be aware about the
+			 * cursor change as well so we repaint it */
+			weston_wm_window_set_cursor(wm, window->frame_id,
+						    XWM_CURSOR_GRABBING);
 			shell_interface->move(window->shsurf,
 					      wm->server->compositor->seat);
 			break;
@@ -985,6 +992,11 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
 		default:
 			break;
 		}
+	} else if (button->response_type == XCB_BUTTON_RELEASE &&
+		   button->detail == 1) {
+		cursor = get_cursor_for_location(t, width, height,
+				button->event_x, button->event_y);
+		weston_wm_window_set_cursor(wm, window->frame_id, cursor);
 	}
 }
 
@@ -992,6 +1004,7 @@ static void
 weston_wm_handle_motion(struct weston_wm *wm, xcb_generic_event_t *event)
 {
 	xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *) event;
+	struct weston_seat *seat = wm->server->compositor->seat;
 	struct weston_wm_window *window;
 	int cursor, width, height;
 
@@ -999,6 +1012,10 @@ weston_wm_handle_motion(struct weston_wm *wm, xcb_generic_event_t *event)
 	if (!window->frame_id)
 		return;
 
+	/* don't change the cursor when pointer is performing a grab */
+	if(seat->seat.pointer->focus != &window->surface->surface)
+		return;
+
 	weston_wm_window_get_frame_size(window, &width, &height);
 	cursor = get_cursor_for_location(wm->theme, width, height,
 					 motion->event_x, motion->event_y);
@@ -1011,12 +1028,17 @@ weston_wm_handle_leave(struct weston_wm *wm, xcb_generic_event_t *event)
 {
 	xcb_leave_notify_event_t *leave_notify =
 				(xcb_leave_notify_event_t *) event;
+	struct weston_seat *seat = wm->server->compositor->seat;
 	struct weston_wm_window *window;
 
 	window = hash_table_lookup(wm->window_hash, leave_notify->event);
 	if (!window)
 		return;
 
+	/* don't change the cursor when pointer is performing a grab */
+	if (seat->seat.pointer->button_count != 0)
+		return;
+
 	weston_wm_window_set_cursor(wm, window->frame_id, XWM_CURSOR_LEFT_PTR);
 }
 
-- 
1.7.9.5



More information about the wayland-devel mailing list