]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Handle request_set_selection
authorJohan Malm <jgm323@gmail.com>
Tue, 12 May 2020 20:00:33 +0000 (21:00 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 12 May 2020 20:00:33 +0000 (21:00 +0100)
deco.c
labwc.h
main.c
server.c

diff --git a/deco.c b/deco.c
index cf89f8d9583e009d4528151d9003cd45afbea4e2..e2175f98880569ae30985615f5a56a3c810fef12 100644 (file)
--- a/deco.c
+++ b/deco.c
@@ -16,14 +16,17 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
 {
        struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
        if (!view)
-               return;
+               return box;
        switch (deco_part) {
        case LAB_DECO_PART_TOP:
                box.x = view->x - XWL_WINDOW_BORDER;
                box.y = view->y - XWL_TITLEBAR_HEIGHT - XWL_WINDOW_BORDER;
-               box.width = view->surface->current.width + 2 * XWL_WINDOW_BORDER;
+               box.width =
+                       view->surface->current.width + 2 * XWL_WINDOW_BORDER;
                box.height = XWL_TITLEBAR_HEIGHT + XWL_WINDOW_BORDER;
                break;
+       default:
+               break;
        }
        return box;
 }
@@ -36,4 +39,3 @@ enum deco_part deco_at(struct view *view, double lx, double ly)
                return LAB_DECO_PART_TOP;
        return LAB_DECO_NONE;
 }
-
diff --git a/labwc.h b/labwc.h
index fa977b1fbea7f5583a17d4034c5ae9c4c06b1d88..fb1c3d7ef0fea380d2262ebf0bcfeab5553727f6 100644 (file)
--- a/labwc.h
+++ b/labwc.h
@@ -62,6 +62,7 @@ struct server {
        struct wlr_seat *seat;
        struct wl_listener new_input;
        struct wl_listener request_cursor;
+       struct wl_listener request_set_selection;
        struct wl_list keyboards;
        enum cursor_mode cursor_mode;
        struct view *grabbed_view;
@@ -83,10 +84,7 @@ struct output {
 
 enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW };
 
-enum deco_part {
-       LAB_DECO_NONE,
-       LAB_DECO_PART_TOP
-};
+enum deco_part { LAB_DECO_NONE, LAB_DECO_PART_TOP };
 
 struct view {
        enum view_type type;
@@ -151,6 +149,7 @@ struct view *first_toplevel(struct server *server);
 
 void server_new_input(struct wl_listener *listener, void *data);
 void seat_request_cursor(struct wl_listener *listener, void *data);
+void seat_request_set_selection(struct wl_listener *listener, void *data);
 void server_cursor_motion(struct wl_listener *listener, void *data);
 void server_cursor_motion_absolute(struct wl_listener *listener, void *data);
 void server_cursor_button(struct wl_listener *listener, void *data);
diff --git a/main.c b/main.c
index b0099f27ce3d7cb0203a731e31c393487d64ee32..f005d8511800d75150a5a58433f834ea6dffafcf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -92,8 +92,8 @@ int main(int argc, char *argv[])
         * room for you to dig your fingers in and play with their behavior if
         * you want.
         */
-       server.compositor = wlr_compositor_create(server.wl_display,
-                                                 server.renderer);
+       server.compositor =
+               wlr_compositor_create(server.wl_display, server.renderer);
        if (!server.compositor) {
                wlr_log(WLR_ERROR, "unable to create the wlroots compositor");
                return 1;
@@ -156,6 +156,9 @@ int main(int argc, char *argv[])
        server.request_cursor.notify = seat_request_cursor;
        wl_signal_add(&server.seat->events.request_set_cursor,
                      &server.request_cursor);
+       server.request_set_selection.notify = seat_request_set_selection;
+       wl_signal_add(&server.seat->events.request_set_selection,
+                     &server.request_set_selection);
 
        /* Init xdg-shell */
        server.xdg_shell = wlr_xdg_shell_create(server.wl_display);
@@ -187,25 +190,24 @@ int main(int argc, char *argv[])
        wl_signal_add(&server.xwayland->events.new_surface,
                      &server.new_xwayland_surface);
 
-       server.cursor_mgr = wlr_xcursor_manager_create(XCURSOR_DEFAULT,
-                                                      XCURSOR_SIZE);
+       server.cursor_mgr =
+               wlr_xcursor_manager_create(XCURSOR_DEFAULT, XCURSOR_SIZE);
        if (!server.cursor_mgr) {
                wlr_log(WLR_ERROR, "cannot create xwayland xcursor manager");
                return 1;
        }
 
        if (setenv("DISPLAY", server.xwayland->display_name, true) < 0)
-               wlr_log_errno(WLR_ERROR, "Unable to set DISPLAY for XWayland."
-                             " Clients may not be able to connect");
+               wlr_log_errno(WLR_ERROR, "unable to set DISPLAY for xwayland");
        else
-               wlr_log(WLR_DEBUG, "XWayland is running on display %s",
+               wlr_log(WLR_DEBUG, "xwayland is running on display %s",
                        server.xwayland->display_name);
 
        if (wlr_xcursor_manager_load(server.cursor_mgr, 1))
                wlr_log(WLR_ERROR, "cannot load xwayland xcursor theme");
 
        struct wlr_xcursor *xcursor;
-       xcursor = wlr_xcursor_manager_get_xcursor(server.cursor_mgr,
+       xcursor = wlr_xcursor_manager_get_xcursor(server.cursor_mgr,
                                                  XCURSOR_DEFAULT, 1);
        if (xcursor) {
                struct wlr_xcursor_image *image = xcursor->images[0];
index 1e80ae2ecc7b32513787b45995715a511fdd603b..a84809a0bd6f6af039c2fa7d429933692dbcc5f4 100644 (file)
--- a/server.c
+++ b/server.c
@@ -177,6 +177,14 @@ void seat_request_cursor(struct wl_listener *listener, void *data)
        }
 }
 
+void seat_request_set_selection(struct wl_listener *listener, void *data)
+{
+       struct server *server =
+               wl_container_of(listener, server, request_set_selection);
+       struct wlr_seat_request_set_selection_event *event = data;
+       wlr_seat_set_selection(server->seat, event->source, event->serial);
+}
+
 static void process_cursor_move(struct server *server, uint32_t time)
 {
        /* Move the grabbed view to the new position. */
@@ -190,7 +198,6 @@ static void process_cursor_move(struct server *server, uint32_t time)
                                               server->grabbed_view->y,
                                               view->xwayland_surface->width,
                                               view->xwayland_surface->height);
-
        }
 }
 
@@ -403,7 +410,8 @@ void server_new_output(struct wl_listener *listener, void *data)
         * TODO: support user configuration
         */
        if (!wl_list_empty(&wlr_output->modes)) {
-               struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
+               struct wlr_output_mode *mode =
+                       wlr_output_preferred_mode(wlr_output);
                wlr_output_set_mode(wlr_output, mode);
                wlr_output_enable(wlr_output, true);
                if (!wlr_output_commit(wlr_output)) {
@@ -425,9 +433,9 @@ void server_new_output(struct wl_listener *listener, void *data)
         * sophisticated compositor would let the user configure the arrangement
         * of outputs in the layout.
         *
-        * The output layout utility automatically adds a wl_output global to the
-        * display, which Wayland clients can see to find out information about the
-        * output (such as DPI, scale factor, manufacturer, etc).
+        * The output layout utility automatically adds a wl_output global to
+        * the display, which Wayland clients can see to find out information
+        * about the output (such as DPI, scale factor, manufacturer, etc).
         */
        wlr_output_layout_add_auto(server->output_layout, wlr_output);
 }