]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Basic support for Move action
authorJohn Lindgren <john@jlindgren.net>
Fri, 26 Nov 2021 18:03:15 +0000 (13:03 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 26 Nov 2021 18:25:04 +0000 (18:25 +0000)
- Add Move as a default mouse binding for a Titlebar Press action
- Remove the hard-coded handling in cursor_button()

Example config snippet:

    <mouse>
      <context name="Titlebar">
        <mousebind button="Left" action="Press">
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Move"/>
        </mousebind>
      </context>
    </mouse>

include/labwc.h
src/action.c
src/config/rcxml.c
src/cursor.c
src/desktop.c

index a405a307a3ad2fa8c1ca1b7851717b6ef17437df..e3809fa2f0ea51c3a211b51a09b76a053d89631e 100644 (file)
@@ -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);
index 4c0ff03e999817ec59d7cd3bd091400582407263..690e6976333afc857362d02fd5b30e4fd46cf858 100644 (file)
@@ -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);
        }
index c70fd2fc09081b61525c828c3da5fddd681039c9..3392db0c500a1bd9f67e63a72ef30091912f0a0b 100644 (file)
@@ -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},
index ef650004a43ef640b7f08132dc05284f2f43cb53..3d75c040bffccb81b55fd2848070f814deec005e 100644 (file)
@@ -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);
        }
 }
 
index 9f3791c6a02705aeb97b92dce363cdec7c22237e..51a792765d83086f9605f170c74ba87197cf4fa1 100644 (file)
@@ -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);
+}