From: John Lindgren Date: Fri, 26 Nov 2021 18:03:15 +0000 (-0500) Subject: Basic support for Move action X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c01d1f124c1619477db0f3d1b19acd9e7fc5ed9f;p=proto%2Flabwc.git Basic support for Move action - Add Move as a default mouse binding for a Titlebar Press action - Remove the hard-coded handling in cursor_button() Example config snippet: --- diff --git a/include/labwc.h b/include/labwc.h index a405a307..e3809fa2 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -430,6 +430,8 @@ struct view *desktop_surface_and_view_at(struct server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy, int *view_area); +struct view *desktop_view_at_cursor(struct server *server); + void cursor_init(struct seat *seat); void keyboard_init(struct seat *seat); diff --git a/src/action.c b/src/action.c index 4c0ff03e..690e6976 100644 --- a/src/action.c +++ b/src/action.c @@ -72,6 +72,11 @@ action(struct server *server, const char *action, const char *command) if (view) { view_minimize(view, true); } + } else if (!strcasecmp(action, "Move")) { + struct view *view = desktop_view_at_cursor(server); + if (view) { + interactive_begin(view, LAB_INPUT_STATE_MOVE, 0); + } } else { wlr_log(WLR_ERROR, "action (%s) not supported", action); } diff --git a/src/config/rcxml.c b/src/config/rcxml.c index c70fd2fc..3392db0c 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -465,6 +465,7 @@ load_default_key_bindings(void) static struct { const char *context, *button, *event, *action, *command; } mouse_combos[] = { + { "TitleBar", "Left", "Press", "Move", NULL }, { "TitleBar", "Left", "DoubleClick", "ToggleMaximize", NULL }, { "Close", "Left", "Click", "Close", NULL }, { "Iconify", "Left", "Click", "Iconify", NULL}, diff --git a/src/cursor.c b/src/cursor.c index ef650004..3d75c040 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -574,15 +574,8 @@ cursor_button(struct wl_listener *listener, void *data) mousebindings: if (event->state == WLR_BUTTON_RELEASED) { handle_release_mousebinding(server, event->button, view_area); - return; } else if (event->state == WLR_BUTTON_PRESSED) { - if (handle_press_mousebinding(server, event->button, view_area)) { - return; - } - } - - if (view_area == LAB_SSD_PART_TITLEBAR) { - interactive_begin(view, LAB_INPUT_STATE_MOVE, 0); + handle_press_mousebinding(server, event->button, view_area); } } diff --git a/src/desktop.c b/src/desktop.c index 9f3791c6..51a79276 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -342,3 +342,14 @@ desktop_surface_and_view_at(struct server *server, double lx, double ly, } return NULL; } + +struct view * +desktop_view_at_cursor(struct server *server) { + double sx, sy; + struct wlr_surface *surface; + int view_area = LAB_SSD_NONE; + + return desktop_surface_and_view_at(server, + server->seat.cursor->x, server->seat.cursor->y, + &surface, &sx, &sy, &view_area); +}