refactor + add request set selection handles
This commit is contained in:
parent
0d84bd388c
commit
68b1890d61
21
cursor.c
21
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
2
diyac.c
2
diyac.c
@ -4,8 +4,6 @@
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||
#include "output.h"
|
||||
#include "xdg.h"
|
||||
#include "cursor.h"
|
||||
|
3
diyac.h
3
diyac.h
@ -12,6 +12,8 @@
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
|
26
seat.c
26
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)
|
||||
|
17
xdg.c
17
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;
|
||||
|
Loading…
Reference in New Issue
Block a user