]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Support moving XWayland window
authorJohan Malm <jgm323@gmail.com>
Tue, 19 Nov 2019 20:45:59 +0000 (20:45 +0000)
committerJohan Malm <jgm323@gmail.com>
Tue, 19 Nov 2019 20:45:59 +0000 (20:45 +0000)
tinywl.c

index b818ce6d5b3d4672bec3d141dcd15ec1c91998cd..98c0f0a8ae04c830108edd4ed0df3ab721c3d66f 100644 (file)
--- a/tinywl.c
+++ b/tinywl.c
@@ -119,6 +119,9 @@ struct tinywl_keyboard {
 
 static struct tinywl_view *next_toplevel(struct tinywl_view *current);
 static bool is_toplevel(struct tinywl_view *view);
+static void process_cursor_move(struct tinywl_server *server, uint32_t time);
+static void begin_interactive(struct tinywl_view *view,
+                             enum tinywl_cursor_mode mode, uint32_t edges);
 
 /**
  * Request that this toplevel surface show itself in an activated or
@@ -380,6 +383,10 @@ static bool handle_keybinding(struct tinywl_server *server, xkb_keysym_t sym) {
                        execl("/bin/dmenu_run", "/bin/dmenu_run", (void *)NULL);
                }
                break;
+       case XKB_KEY_F6:
+               begin_interactive(first_toplevel(server),
+                       TINYWL_CURSOR_MOVE, 0);
+               break;
        case XKB_KEY_F12:
                debug_show_views(server);
                break;
@@ -1016,14 +1023,26 @@ static void begin_interactive(struct tinywl_view *view,
        struct tinywl_server *server = view->server;
        struct wlr_surface *focused_surface =
                server->seat->pointer_state.focused_surface;
-       if (view->xdg_surface->surface != focused_surface) {
+       if (view->surface != focused_surface) {
                /* Deny move/resize requests from unfocused clients. */
                return;
        }
        server->grabbed_view = view;
        server->cursor_mode = mode;
+
        struct wlr_box geo_box;
-       wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
+       switch (view->type) {
+       case LAB_XDG_SHELL_VIEW:
+               wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
+               break;
+       case LAB_XWAYLAND_VIEW:
+               geo_box.x = view->xwayland_surface->x;
+               geo_box.y = view->xwayland_surface->y;
+               geo_box.width = view->xwayland_surface->width;
+               geo_box.height = view->xwayland_surface->height;
+               break;
+       }
+
        if (mode == TINYWL_CURSOR_MOVE) {
                server->grab_x = server->cursor->x - view->x;
                server->grab_y = server->cursor->y - view->y;