mirror of
https://github.com/labwc/labwc.git
synced 2026-02-28 01:40:29 -05:00
Handle request_set_selection
This commit is contained in:
parent
48e47fe8f9
commit
9597aeffec
4 changed files with 31 additions and 20 deletions
8
deco.c
8
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 };
|
struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
|
||||||
if (!view)
|
if (!view)
|
||||||
return;
|
return box;
|
||||||
switch (deco_part) {
|
switch (deco_part) {
|
||||||
case LAB_DECO_PART_TOP:
|
case LAB_DECO_PART_TOP:
|
||||||
box.x = view->x - XWL_WINDOW_BORDER;
|
box.x = view->x - XWL_WINDOW_BORDER;
|
||||||
box.y = view->y - XWL_TITLEBAR_HEIGHT - 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;
|
box.height = XWL_TITLEBAR_HEIGHT + XWL_WINDOW_BORDER;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return box;
|
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_PART_TOP;
|
||||||
return LAB_DECO_NONE;
|
return LAB_DECO_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
labwc.h
7
labwc.h
|
|
@ -62,6 +62,7 @@ struct server {
|
||||||
struct wlr_seat *seat;
|
struct wlr_seat *seat;
|
||||||
struct wl_listener new_input;
|
struct wl_listener new_input;
|
||||||
struct wl_listener request_cursor;
|
struct wl_listener request_cursor;
|
||||||
|
struct wl_listener request_set_selection;
|
||||||
struct wl_list keyboards;
|
struct wl_list keyboards;
|
||||||
enum cursor_mode cursor_mode;
|
enum cursor_mode cursor_mode;
|
||||||
struct view *grabbed_view;
|
struct view *grabbed_view;
|
||||||
|
|
@ -83,10 +84,7 @@ struct output {
|
||||||
|
|
||||||
enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW };
|
enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW };
|
||||||
|
|
||||||
enum deco_part {
|
enum deco_part { LAB_DECO_NONE, LAB_DECO_PART_TOP };
|
||||||
LAB_DECO_NONE,
|
|
||||||
LAB_DECO_PART_TOP
|
|
||||||
};
|
|
||||||
|
|
||||||
struct view {
|
struct view {
|
||||||
enum view_type type;
|
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 server_new_input(struct wl_listener *listener, void *data);
|
||||||
void seat_request_cursor(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(struct wl_listener *listener, void *data);
|
||||||
void server_cursor_motion_absolute(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);
|
void server_cursor_button(struct wl_listener *listener, void *data);
|
||||||
|
|
|
||||||
18
main.c
18
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
|
* room for you to dig your fingers in and play with their behavior if
|
||||||
* you want.
|
* you want.
|
||||||
*/
|
*/
|
||||||
server.compositor = wlr_compositor_create(server.wl_display,
|
server.compositor =
|
||||||
server.renderer);
|
wlr_compositor_create(server.wl_display, server.renderer);
|
||||||
if (!server.compositor) {
|
if (!server.compositor) {
|
||||||
wlr_log(WLR_ERROR, "unable to create the wlroots compositor");
|
wlr_log(WLR_ERROR, "unable to create the wlroots compositor");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -156,6 +156,9 @@ int main(int argc, char *argv[])
|
||||||
server.request_cursor.notify = seat_request_cursor;
|
server.request_cursor.notify = seat_request_cursor;
|
||||||
wl_signal_add(&server.seat->events.request_set_cursor,
|
wl_signal_add(&server.seat->events.request_set_cursor,
|
||||||
&server.request_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 */
|
/* Init xdg-shell */
|
||||||
server.xdg_shell = wlr_xdg_shell_create(server.wl_display);
|
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,
|
wl_signal_add(&server.xwayland->events.new_surface,
|
||||||
&server.new_xwayland_surface);
|
&server.new_xwayland_surface);
|
||||||
|
|
||||||
server.cursor_mgr = wlr_xcursor_manager_create(XCURSOR_DEFAULT,
|
server.cursor_mgr =
|
||||||
XCURSOR_SIZE);
|
wlr_xcursor_manager_create(XCURSOR_DEFAULT, XCURSOR_SIZE);
|
||||||
if (!server.cursor_mgr) {
|
if (!server.cursor_mgr) {
|
||||||
wlr_log(WLR_ERROR, "cannot create xwayland xcursor manager");
|
wlr_log(WLR_ERROR, "cannot create xwayland xcursor manager");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setenv("DISPLAY", server.xwayland->display_name, true) < 0)
|
if (setenv("DISPLAY", server.xwayland->display_name, true) < 0)
|
||||||
wlr_log_errno(WLR_ERROR, "Unable to set DISPLAY for XWayland."
|
wlr_log_errno(WLR_ERROR, "unable to set DISPLAY for xwayland");
|
||||||
" Clients may not be able to connect");
|
|
||||||
else
|
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);
|
server.xwayland->display_name);
|
||||||
|
|
||||||
if (wlr_xcursor_manager_load(server.cursor_mgr, 1))
|
if (wlr_xcursor_manager_load(server.cursor_mgr, 1))
|
||||||
wlr_log(WLR_ERROR, "cannot load xwayland xcursor theme");
|
wlr_log(WLR_ERROR, "cannot load xwayland xcursor theme");
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor;
|
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);
|
XCURSOR_DEFAULT, 1);
|
||||||
if (xcursor) {
|
if (xcursor) {
|
||||||
struct wlr_xcursor_image *image = xcursor->images[0];
|
struct wlr_xcursor_image *image = xcursor->images[0];
|
||||||
|
|
|
||||||
18
server.c
18
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)
|
static void process_cursor_move(struct server *server, uint32_t time)
|
||||||
{
|
{
|
||||||
/* Move the grabbed view to the new position. */
|
/* 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,
|
server->grabbed_view->y,
|
||||||
view->xwayland_surface->width,
|
view->xwayland_surface->width,
|
||||||
view->xwayland_surface->height);
|
view->xwayland_surface->height);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,7 +410,8 @@ void server_new_output(struct wl_listener *listener, void *data)
|
||||||
* TODO: support user configuration
|
* TODO: support user configuration
|
||||||
*/
|
*/
|
||||||
if (!wl_list_empty(&wlr_output->modes)) {
|
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_set_mode(wlr_output, mode);
|
||||||
wlr_output_enable(wlr_output, true);
|
wlr_output_enable(wlr_output, true);
|
||||||
if (!wlr_output_commit(wlr_output)) {
|
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
|
* sophisticated compositor would let the user configure the arrangement
|
||||||
* of outputs in the layout.
|
* of outputs in the layout.
|
||||||
*
|
*
|
||||||
* The output layout utility automatically adds a wl_output global to the
|
* The output layout utility automatically adds a wl_output global to
|
||||||
* display, which Wayland clients can see to find out information about the
|
* the display, which Wayland clients can see to find out information
|
||||||
* output (such as DPI, scale factor, manufacturer, etc).
|
* about the output (such as DPI, scale factor, manufacturer, etc).
|
||||||
*/
|
*/
|
||||||
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue