diff --git a/cursor.c b/cursor.c index 5823d1c..0ed68e9 100644 --- a/cursor.c +++ b/cursor.c @@ -11,10 +11,10 @@ void diyac_cursor_focus(struct diyac_server *server) double sx, sy; struct wlr_surface *surface = NULL; struct diyac_node_descriptor *desc = diyac_node_at(server, - server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy); - struct diyac_layer_surface * layer; - struct diyac_view * root = NULL; - if(!desc) + server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy); + struct diyac_layer_surface *layer; + struct diyac_view *root = NULL; + if (!desc) { return; } @@ -23,7 +23,7 @@ void diyac_cursor_focus(struct diyac_server *server) { case DIYAC_NODE_VIEW: root = diyac_get_root_view(desc->data); - if(root) + if (root) { diyac_focus_view(root, true); } @@ -36,7 +36,7 @@ void diyac_cursor_focus(struct diyac_server *server) layer = desc->data; assert(layer); assert(layer->scene_layer_surface); - diyac_seat_focus_layer(&server->seat,layer->scene_layer_surface->layer_surface); + diyac_seat_focus_layer(&server->seat, layer->scene_layer_surface->layer_surface); break; default: break; @@ -54,7 +54,7 @@ static void process_cursor_move(struct diyac_server *server, uint32_t time) { /* Move the grabbed toplevel to the new position. */ struct diyac_view *toplevel = server->grabbed_view; - if(toplevel->state != DIYAC_VIEW_NORMAL) + if (toplevel->state != DIYAC_VIEW_NORMAL) { // cancel maximize or fullscreen state wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, false); @@ -65,7 +65,7 @@ static void process_cursor_move(struct diyac_server *server, uint32_t time) toplevel->state = DIYAC_VIEW_NORMAL; toplevel->original.y = server->seat.cursor->y - server->grab_y; toplevel->original.x = server->seat.cursor->x - server->grab_x; - + diyac_view_update_geometry(toplevel, true); /* wlr_scene_node_set_position(&toplevel->scene_tree->node, @@ -163,7 +163,7 @@ static void process_cursor_motion(struct diyac_server *server, uint32_t time) struct wlr_seat *seat = server->seat.wlr_seat; struct wlr_surface *surface = NULL; struct diyac_node_descriptor *desc = diyac_node_at(server, - server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy); + server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy); if (!desc) { /* If there's no toplevel under the cursor, set the cursor image to a @@ -239,7 +239,7 @@ static void server_cursor_button(struct wl_listener *listener, void *data) /* Notify the client with pointer focus that a button press has occurred */ wlr_seat_pointer_notify_button(seat->wlr_seat, event->time_msec, event->button, event->state); - + if (event->state == WLR_BUTTON_RELEASED) { /* If you released any buttons, we exit interactive move/resize mode. */ @@ -248,7 +248,6 @@ static void server_cursor_button(struct wl_listener *listener, void *data) else { diyac_cursor_focus(seat->server); - } } diff --git a/diyac.c b/diyac.c index a646eb1..a1494b5 100644 --- a/diyac.c +++ b/diyac.c @@ -4,8 +4,6 @@ #include #include #include -#include -#include #include "output.h" #include "xdg.h" #include "cursor.h" diff --git a/diyac.h b/diyac.h index ea9948d..23031a2 100644 --- a/diyac.h +++ b/diyac.h @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #define LAYER_TREE_SZ 4 @@ -62,6 +64,7 @@ struct diyac_seat struct wl_listener new_input; struct wl_listener request_cursor; struct wl_listener request_set_selection; + struct wl_listener request_set_primary_selection; struct wl_list keyboards; }; diff --git a/seat.c b/seat.c index 1ebb4d5..b3a35ca 100644 --- a/seat.c +++ b/seat.c @@ -216,6 +216,24 @@ static void seat_request_set_selection(struct wl_listener *listener, void *data) wlr_seat_set_selection(seat->wlr_seat, event->source, event->serial); } +static void request_set_selection_notify(struct wl_listener *listener, void *data) +{ + struct diyac_seat *seat = wl_container_of( + listener, seat, request_set_selection); + struct wlr_seat_request_set_selection_event *event = data; + wlr_seat_set_selection(seat->wlr_seat, event->source, + event->serial); +} + +static void request_set_primary_selection_notify(struct wl_listener *listener, void *data) +{ + struct diyac_seat *seat = wl_container_of( + listener, seat, request_set_primary_selection); + struct wlr_seat_request_set_primary_selection_event *event = data; + wlr_seat_set_primary_selection(seat->wlr_seat, event->source, + event->serial); +} + /* * Configures a seat, which is a single "seat" at which a user sits and * operates the computer. This conceptually includes up to one keyboard, @@ -235,6 +253,14 @@ void diyac_init_seat(struct diyac_server *server) server->seat.request_set_selection.notify = seat_request_set_selection; wl_signal_add(&server->seat.wlr_seat->events.request_set_selection, &server->seat.request_set_selection); + server->seat.request_set_selection.notify = request_set_selection_notify; + wl_signal_add(&server->seat.wlr_seat->events.request_set_selection, + &server->seat.request_set_selection); + + server->seat.request_set_primary_selection.notify = + request_set_primary_selection_notify; + wl_signal_add(&server->seat.wlr_seat->events.request_set_primary_selection, + &server->seat.request_set_primary_selection); } static void seat_focus(struct diyac_seat *seat, struct wlr_surface *surface, bool is_lock_surface) diff --git a/xdg.c b/xdg.c index cf97a0a..24f3c4b 100644 --- a/xdg.c +++ b/xdg.c @@ -55,8 +55,15 @@ static void begin_interactive(struct diyac_view *toplevel, static void xdg_toplevel_map(struct wl_listener *listener, void *data) { + /* Called when the surface is mapped, or ready to display on-screen. */ struct diyac_view *toplevel = wl_container_of(listener, toplevel, map); + /* + wlr_xdg_toplevel_set_wm_capabilities(toplevel->xdg_toplevel, + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE | + WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE); + //WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN + */ wlr_xdg_surface_get_geometry(toplevel->xdg_toplevel->base, &toplevel->original); wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true); toplevel->mapped = true; @@ -157,13 +164,6 @@ static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void * { struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_fullscreen); - wlr_log(WLR_INFO, "Cursor state %d", toplevel->server->seat.cursor_mode); - if (toplevel->server->seat.cursor_mode != DIYAC_CURSOR_PASSTHROUGH) - { - wlr_log(WLR_INFO, "The view is under move/resize, disable fullcreen event"); - wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false); - return; - } if (!toplevel->mapped) { wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false); @@ -175,7 +175,6 @@ static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void * diyac_reset_cursor_mode(toplevel->server); wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false); /* - if (toplevel->state == DIYAC_VIEW_FULL_SCREEN) { toplevel->state = DIYAC_VIEW_NORMAL; @@ -386,7 +385,7 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data) wlr_log(WLR_INFO, "diyac_new_xdg_surface: Creating new application windows"); wlr_xdg_surface_ping(xdg_surface); /* Allocate a diyac_view for this surface */ - struct diyac_view *toplevel = calloc(1, sizeof(*toplevel)); + struct diyac_view *toplevel = calloc(1, sizeof(*toplevel)); toplevel->state = DIYAC_VIEW_NORMAL; toplevel->server = server; toplevel->xdg_toplevel = xdg_surface->toplevel;