2021-09-24 21:45:48 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2020-12-30 10:29:21 +00:00
|
|
|
#include "config.h"
|
2020-09-28 20:53:59 +01:00
|
|
|
#include <assert.h>
|
2022-10-05 08:43:56 +02:00
|
|
|
#include "common/list.h"
|
|
|
|
|
#include "common/scene-helpers.h"
|
2022-09-18 05:40:52 +02:00
|
|
|
#include "dnd.h"
|
2020-09-11 20:48:28 +01:00
|
|
|
#include "labwc.h"
|
2022-12-22 21:58:55 +00:00
|
|
|
#include "layers.h"
|
2022-03-02 21:07:04 +00:00
|
|
|
#include "node.h"
|
2021-03-21 20:54:55 +00:00
|
|
|
#include "ssd.h"
|
2022-11-21 10:10:39 -05:00
|
|
|
#include "view.h"
|
2022-06-15 02:02:50 +02:00
|
|
|
#include "workspaces.h"
|
2023-01-07 17:50:33 -05:00
|
|
|
#include "xwayland.h"
|
2020-09-11 20:48:28 +01:00
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
void
|
2021-12-06 21:23:49 +00:00
|
|
|
desktop_move_to_front(struct view *view)
|
2021-10-16 19:44:54 +01:00
|
|
|
{
|
|
|
|
|
if (!view) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-02-05 19:29:24 +00:00
|
|
|
if (view->impl->move_to_front) {
|
|
|
|
|
view->impl->move_to_front(view);
|
|
|
|
|
cursor_update_focus(view->server);
|
|
|
|
|
}
|
2021-10-16 19:44:54 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-06 21:23:49 +00:00
|
|
|
void
|
|
|
|
|
desktop_move_to_back(struct view *view)
|
|
|
|
|
{
|
|
|
|
|
if (!view) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wl_list_remove(&view->link);
|
2022-10-05 08:43:56 +02:00
|
|
|
wl_list_append(&view->server->views, &view->link);
|
2021-12-06 21:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-30 20:02:24 +02:00
|
|
|
void
|
|
|
|
|
desktop_arrange_all_views(struct server *server)
|
|
|
|
|
{
|
2023-02-15 12:52:57 -05:00
|
|
|
/*
|
|
|
|
|
* Adjust window positions/sizes. Skip views with no size since
|
|
|
|
|
* we can't do anything useful with them; they will presumably
|
|
|
|
|
* be initialized with valid positions/sizes later.
|
|
|
|
|
*
|
|
|
|
|
* We do not simply check view->mapped/been_mapped here because
|
|
|
|
|
* views can have maximized/fullscreen geometry applied while
|
|
|
|
|
* still unmapped. We do want to adjust the geometry of those
|
|
|
|
|
* views.
|
|
|
|
|
*/
|
2022-06-30 20:02:24 +02:00
|
|
|
struct view *view;
|
|
|
|
|
wl_list_for_each(view, &server->views, link) {
|
2023-02-15 12:52:57 -05:00
|
|
|
if (!wlr_box_empty(&view->pending)) {
|
|
|
|
|
view_adjust_for_layout_change(view);
|
|
|
|
|
}
|
2022-06-30 20:02:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-16 19:44:54 +01:00
|
|
|
void
|
|
|
|
|
desktop_focus_and_activate_view(struct seat *seat, struct view *view)
|
2020-09-14 17:35:44 +01:00
|
|
|
{
|
2020-09-18 20:28:48 +01:00
|
|
|
if (!view) {
|
2020-10-08 20:22:52 +01:00
|
|
|
seat_focus_surface(seat, NULL);
|
2020-09-14 17:35:44 +01:00
|
|
|
return;
|
2020-09-18 20:28:48 +01:00
|
|
|
}
|
2021-12-31 02:58:34 +00:00
|
|
|
|
2022-01-02 15:53:05 +00:00
|
|
|
/*
|
|
|
|
|
* Guard against views with no mapped surfaces when handling
|
|
|
|
|
* 'request_activate' and 'request_minimize'.
|
|
|
|
|
* See notes by isfocusable()
|
|
|
|
|
*/
|
|
|
|
|
if (!view->surface) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input_inhibit_blocks_surface(seat, view->surface->resource)) {
|
2021-08-25 19:59:49 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2021-08-21 17:12:02 +01:00
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
if (view->minimized) {
|
2021-10-16 19:44:54 +01:00
|
|
|
/*
|
|
|
|
|
* Unminimizing will map the view which triggers a call to this
|
|
|
|
|
* function again.
|
|
|
|
|
*/
|
2021-08-05 13:00:34 +01:00
|
|
|
view_minimize(view, false);
|
2020-10-08 20:08:41 +01:00
|
|
|
return;
|
2020-09-28 20:41:41 +01:00
|
|
|
}
|
2021-12-31 02:58:34 +00:00
|
|
|
|
2022-01-02 15:53:05 +00:00
|
|
|
if (!view->mapped) {
|
2021-10-16 19:44:54 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_surface *prev_surface;
|
|
|
|
|
prev_surface = seat->seat->keyboard_state.focused_surface;
|
|
|
|
|
|
|
|
|
|
/* Do not re-focus an already focused surface. */
|
|
|
|
|
if (prev_surface == view->surface) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-26 02:02:19 -04:00
|
|
|
view_set_activated(view);
|
2021-10-16 19:44:54 +01:00
|
|
|
seat_focus_surface(seat, view->surface);
|
2020-09-14 17:35:44 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-11 20:48:28 +01:00
|
|
|
/*
|
|
|
|
|
* Some xwayland apps produce unmapped surfaces on startup and also leave
|
2021-08-25 19:59:49 +01:00
|
|
|
* some unmapped surfaces kicking around on 'close' (for example leafpad's
|
2020-09-11 20:48:28 +01:00
|
|
|
* "about" dialogue). Whilst this is not normally a problem, we have to be
|
2020-09-14 17:35:44 +01:00
|
|
|
* careful when cycling between views. The only views we should focus are
|
2020-09-11 20:48:28 +01:00
|
|
|
* those that are already mapped and those that have been minimized.
|
|
|
|
|
*/
|
2021-08-16 07:16:56 +01:00
|
|
|
bool
|
2020-09-28 20:41:41 +01:00
|
|
|
isfocusable(struct view *view)
|
2020-09-11 20:48:28 +01:00
|
|
|
{
|
|
|
|
|
/* filter out those xwayland surfaces that have never been mapped */
|
2020-09-28 20:41:41 +01:00
|
|
|
if (!view->surface) {
|
2020-09-11 20:48:28 +01:00
|
|
|
return false;
|
2020-09-28 20:41:41 +01:00
|
|
|
}
|
2020-09-11 20:48:28 +01:00
|
|
|
return (view->mapped || view->minimized);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 02:02:50 +02:00
|
|
|
static struct wl_list *
|
|
|
|
|
get_prev_item(struct wl_list *item)
|
2020-09-11 20:48:28 +01:00
|
|
|
{
|
2022-06-15 02:02:50 +02:00
|
|
|
return item->prev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct wl_list *
|
|
|
|
|
get_next_item(struct wl_list *item)
|
|
|
|
|
{
|
|
|
|
|
return item->next;
|
2020-09-11 20:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
static struct view *
|
|
|
|
|
first_view(struct server *server)
|
2020-09-11 20:48:28 +01:00
|
|
|
{
|
2022-06-15 02:02:50 +02:00
|
|
|
struct wlr_scene_node *node;
|
|
|
|
|
struct wl_list *list_head =
|
|
|
|
|
&server->workspace_current->tree->children;
|
|
|
|
|
wl_list_for_each_reverse(node, list_head, link) {
|
2022-07-06 07:19:28 +02:00
|
|
|
if (!node->data) {
|
|
|
|
|
/* We found some non-view, most likely the region overlay */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-09-26 03:48:02 +02:00
|
|
|
struct view *view = node_view_from_node(node);
|
|
|
|
|
if (isfocusable(view)) {
|
|
|
|
|
return view;
|
|
|
|
|
}
|
2022-06-15 02:02:50 +02:00
|
|
|
}
|
|
|
|
|
return NULL;
|
2020-09-11 20:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
struct view *
|
2022-06-15 02:02:50 +02:00
|
|
|
desktop_cycle_view(struct server *server, struct view *start_view,
|
2021-12-26 23:29:01 +00:00
|
|
|
enum lab_cycle_dir dir)
|
2020-09-11 20:48:28 +01:00
|
|
|
{
|
2022-09-02 16:41:27 -04:00
|
|
|
/*
|
|
|
|
|
* Views are listed in stacking order, topmost first. Usually
|
|
|
|
|
* the topmost view is already focused, so we pre-select the
|
|
|
|
|
* view second from the top:
|
|
|
|
|
*
|
|
|
|
|
* View #1 (on top, currently focused)
|
|
|
|
|
* View #2 (pre-selected)
|
|
|
|
|
* View #3
|
|
|
|
|
* ...
|
|
|
|
|
*
|
|
|
|
|
* This assumption doesn't always hold with XWayland views,
|
|
|
|
|
* where a main application window may be focused but an
|
|
|
|
|
* focusable sub-view (e.g. an about dialog) may still be on
|
|
|
|
|
* top of it. In that case, we pre-select the sub-view:
|
|
|
|
|
*
|
|
|
|
|
* Sub-view of #1 (on top, pre-selected)
|
|
|
|
|
* Main view #1 (currently focused)
|
|
|
|
|
* Main view #2
|
|
|
|
|
* ...
|
|
|
|
|
*
|
|
|
|
|
* The general rule is:
|
|
|
|
|
*
|
|
|
|
|
* - Pre-select the top view if NOT already focused
|
|
|
|
|
* - Otherwise select the view second from the top
|
|
|
|
|
*/
|
2022-09-26 10:58:13 +02:00
|
|
|
|
|
|
|
|
/* Make sure to have all nodes in their actual ordering */
|
|
|
|
|
osd_preview_restore(server);
|
|
|
|
|
|
2022-09-02 16:41:27 -04:00
|
|
|
if (!start_view) {
|
|
|
|
|
start_view = first_view(server);
|
|
|
|
|
if (!start_view || start_view != desktop_focused_view(server)) {
|
|
|
|
|
return start_view; /* may be NULL */
|
|
|
|
|
}
|
2020-10-31 14:46:33 +00:00
|
|
|
}
|
2022-09-02 16:41:27 -04:00
|
|
|
struct view *view = start_view;
|
2022-06-15 02:02:50 +02:00
|
|
|
struct wlr_scene_node *node = &view->scene_tree->node;
|
2020-09-11 20:48:28 +01:00
|
|
|
|
2022-06-15 02:02:50 +02:00
|
|
|
assert(node->parent);
|
|
|
|
|
struct wl_list *list_head = &node->parent->children;
|
|
|
|
|
struct wl_list *list_item = &node->link;
|
2022-09-17 12:31:07 +01:00
|
|
|
struct wl_list *(*iter)(struct wl_list *list);
|
2020-09-11 20:48:28 +01:00
|
|
|
|
2022-06-15 02:02:50 +02:00
|
|
|
/* Scene nodes are ordered like last node == displayed topmost */
|
|
|
|
|
iter = dir == LAB_CYCLE_DIR_FORWARD ? get_prev_item : get_next_item;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
list_item = iter(list_item);
|
|
|
|
|
if (list_item == list_head) {
|
|
|
|
|
/* Start / End of list reached. Roll over */
|
|
|
|
|
list_item = iter(list_item);
|
2020-09-28 20:41:41 +01:00
|
|
|
}
|
2022-06-15 02:02:50 +02:00
|
|
|
node = wl_container_of(list_item, node, link);
|
2022-07-06 07:19:28 +02:00
|
|
|
if (!node->data) {
|
|
|
|
|
/* We found some non-view, most likely the region overlay */
|
|
|
|
|
view = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-06-15 02:02:50 +02:00
|
|
|
view = node_view_from_node(node);
|
|
|
|
|
if (isfocusable(view)) {
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
} while (view != start_view);
|
|
|
|
|
|
|
|
|
|
/* No focusable views found, including the one we started with */
|
|
|
|
|
return NULL;
|
2020-09-18 20:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-20 22:07:19 +01:00
|
|
|
static struct view *
|
2020-10-31 14:32:31 +00:00
|
|
|
topmost_mapped_view(struct server *server)
|
2020-09-18 20:28:48 +01:00
|
|
|
{
|
2022-06-15 02:02:50 +02:00
|
|
|
struct view *view;
|
|
|
|
|
struct wl_list *node_list;
|
|
|
|
|
struct wlr_scene_node *node;
|
|
|
|
|
node_list = &server->workspace_current->tree->children;
|
|
|
|
|
wl_list_for_each_reverse(node, node_list, link) {
|
2022-07-06 07:19:28 +02:00
|
|
|
if (!node->data) {
|
|
|
|
|
/* We found some non-view, most likely the region overlay */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-06-15 02:02:50 +02:00
|
|
|
view = node_view_from_node(node);
|
|
|
|
|
if (view->mapped) {
|
|
|
|
|
return view;
|
|
|
|
|
}
|
2020-09-28 20:41:41 +01:00
|
|
|
}
|
2022-06-15 02:02:50 +02:00
|
|
|
return NULL;
|
2020-09-18 20:28:48 +01:00
|
|
|
}
|
2020-10-31 14:32:31 +00:00
|
|
|
|
2021-09-19 22:20:54 +00:00
|
|
|
struct view *
|
2021-09-20 22:12:34 +01:00
|
|
|
desktop_focused_view(struct server *server)
|
2021-09-19 22:20:54 +00:00
|
|
|
{
|
|
|
|
|
struct seat *seat = &server->seat;
|
|
|
|
|
struct wlr_surface *focused_surface;
|
|
|
|
|
focused_surface = seat->seat->keyboard_state.focused_surface;
|
|
|
|
|
if (!focused_surface) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
struct view *view;
|
2022-11-03 19:58:21 +00:00
|
|
|
wl_list_for_each(view, &server->views, link) {
|
2021-09-19 22:20:54 +00:00
|
|
|
if (view->surface == focused_surface) {
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
void
|
2020-10-31 14:32:31 +00:00
|
|
|
desktop_focus_topmost_mapped_view(struct server *server)
|
2020-09-18 20:28:48 +01:00
|
|
|
{
|
2020-10-31 14:32:31 +00:00
|
|
|
struct view *view = topmost_mapped_view(server);
|
2021-10-16 19:44:54 +01:00
|
|
|
desktop_focus_and_activate_view(&server->seat, view);
|
2021-12-06 21:23:49 +00:00
|
|
|
desktop_move_to_front(view);
|
2020-09-18 20:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-05 17:16:23 +01:00
|
|
|
void
|
|
|
|
|
desktop_focus_output(struct output *output)
|
|
|
|
|
{
|
|
|
|
|
if (!output_is_usable(output) || output->server->input_mode
|
|
|
|
|
!= LAB_INPUT_STATE_PASSTHROUGH) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
struct view *view;
|
|
|
|
|
struct wlr_scene_node *node;
|
|
|
|
|
struct wlr_output_layout *layout = output->server->output_layout;
|
|
|
|
|
struct wl_list *list_head =
|
|
|
|
|
&output->server->workspace_current->tree->children;
|
|
|
|
|
wl_list_for_each_reverse(node, list_head, link) {
|
|
|
|
|
if (!node->data) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
view = node_view_from_node(node);
|
|
|
|
|
if (!isfocusable(view)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (wlr_output_layout_intersects(layout,
|
|
|
|
|
output->wlr_output, &view->current)) {
|
|
|
|
|
desktop_focus_and_activate_view(&output->server->seat, view);
|
|
|
|
|
wlr_cursor_warp(output->server->seat.cursor, NULL,
|
|
|
|
|
view->current.x + view->current.width / 2,
|
|
|
|
|
view->current.y + view->current.height / 2);
|
|
|
|
|
cursor_update_focus(output->server);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* No view found on desired output */
|
|
|
|
|
struct wlr_box layout_box;
|
|
|
|
|
wlr_output_layout_get_box(output->server->output_layout,
|
|
|
|
|
output->wlr_output, &layout_box);
|
|
|
|
|
wlr_cursor_warp(output->server->seat.cursor, NULL,
|
|
|
|
|
layout_box.x + output->usable_area.x + output->usable_area.width / 2,
|
|
|
|
|
layout_box.y + output->usable_area.y + output->usable_area.height / 2);
|
|
|
|
|
cursor_update_focus(output->server);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-22 21:58:55 +00:00
|
|
|
static struct wlr_surface *
|
|
|
|
|
get_surface_from_layer_node(struct wlr_scene_node *node)
|
|
|
|
|
{
|
|
|
|
|
assert(node->data);
|
|
|
|
|
struct node_descriptor *desc = (struct node_descriptor *)node->data;
|
|
|
|
|
if (desc->type == LAB_NODE_DESC_LAYER_SURFACE) {
|
|
|
|
|
struct lab_layer_surface *surface;
|
|
|
|
|
surface = node_layer_surface_from_node(node);
|
|
|
|
|
return surface->scene_layer_surface->layer_surface->surface;
|
|
|
|
|
} else if (desc->type == LAB_NODE_DESC_LAYER_POPUP) {
|
|
|
|
|
struct lab_layer_popup *popup;
|
|
|
|
|
popup = node_layer_popup_from_node(node);
|
|
|
|
|
return popup->wlr_popup->base->surface;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-29 20:16:32 +00:00
|
|
|
static bool
|
|
|
|
|
is_layer_descendant(struct wlr_scene_node *node)
|
|
|
|
|
{
|
|
|
|
|
goto start;
|
|
|
|
|
while (node) {
|
|
|
|
|
struct node_descriptor *desc = node->data;
|
|
|
|
|
if (desc && desc->type == LAB_NODE_DESC_LAYER_SURFACE) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
start:
|
|
|
|
|
node = node->parent ? &node->parent->node : NULL;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-12 04:54:00 -04:00
|
|
|
/* TODO: make this less big and scary */
|
|
|
|
|
struct cursor_context
|
|
|
|
|
get_cursor_context(struct server *server)
|
2020-09-11 20:48:28 +01:00
|
|
|
{
|
2022-09-12 04:54:00 -04:00
|
|
|
struct cursor_context ret = {.type = LAB_SSD_NONE};
|
|
|
|
|
struct wlr_cursor *cursor = server->seat.cursor;
|
2022-09-18 05:40:52 +02:00
|
|
|
|
|
|
|
|
/* Prevent drag icons to be on top of the hitbox detection */
|
|
|
|
|
if (server->seat.drag.active) {
|
|
|
|
|
dnd_icons_show(&server->seat, false);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-11 23:12:45 +00:00
|
|
|
struct wlr_scene_node *node =
|
2022-09-12 04:54:00 -04:00
|
|
|
wlr_scene_node_at(&server->scene->tree.node,
|
|
|
|
|
cursor->x, cursor->y, &ret.sx, &ret.sy);
|
2021-07-12 16:44:30 +01:00
|
|
|
|
2022-09-18 05:40:52 +02:00
|
|
|
if (server->seat.drag.active) {
|
|
|
|
|
dnd_icons_show(&server->seat, true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-12 04:54:00 -04:00
|
|
|
ret.node = node;
|
2022-02-18 00:07:37 +01:00
|
|
|
if (!node) {
|
2022-09-12 04:54:00 -04:00
|
|
|
ret.type = LAB_SSD_ROOT;
|
|
|
|
|
return ret;
|
2021-07-19 07:06:36 +01:00
|
|
|
}
|
2023-01-28 22:34:27 +00:00
|
|
|
|
2022-12-22 21:58:55 +00:00
|
|
|
#if HAVE_XWAYLAND
|
2022-05-26 00:39:04 +02:00
|
|
|
if (node->type == WLR_SCENE_NODE_BUFFER) {
|
|
|
|
|
struct wlr_surface *surface = lab_wlr_surface_from_node(node);
|
2022-06-05 15:17:35 +02:00
|
|
|
if (node->parent == server->unmanaged_tree) {
|
2022-09-12 04:54:00 -04:00
|
|
|
ret.type = LAB_SSD_UNMANAGED;
|
|
|
|
|
ret.surface = surface;
|
|
|
|
|
return ret;
|
2022-02-22 07:57:17 +01:00
|
|
|
}
|
2022-02-18 00:07:37 +01:00
|
|
|
}
|
2022-12-22 21:58:55 +00:00
|
|
|
#endif
|
2022-02-25 22:31:24 +00:00
|
|
|
while (node) {
|
|
|
|
|
struct node_descriptor *desc = node->data;
|
|
|
|
|
if (desc) {
|
2022-09-12 04:54:00 -04:00
|
|
|
switch (desc->type) {
|
|
|
|
|
case LAB_NODE_DESC_VIEW:
|
|
|
|
|
case LAB_NODE_DESC_XDG_POPUP:
|
|
|
|
|
ret.view = desc->data;
|
2022-11-26 16:46:28 -05:00
|
|
|
ret.type = ssd_get_part_type(ret.view->ssd, ret.node);
|
2022-09-12 04:54:00 -04:00
|
|
|
if (ret.type == LAB_SSD_CLIENT) {
|
|
|
|
|
ret.surface = lab_wlr_surface_from_node(ret.node);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
case LAB_NODE_DESC_SSD_BUTTON: {
|
2022-09-17 12:31:07 +01:00
|
|
|
/*
|
|
|
|
|
* Always return the top scene node for SSD
|
|
|
|
|
* buttons
|
|
|
|
|
*/
|
|
|
|
|
struct ssd_button *button =
|
|
|
|
|
node_ssd_button_from_node(node);
|
2022-09-12 04:54:00 -04:00
|
|
|
ret.node = node;
|
2022-11-26 16:53:35 -05:00
|
|
|
ret.type = ssd_button_get_type(button);
|
|
|
|
|
ret.view = ssd_button_get_view(button);
|
2022-09-12 04:54:00 -04:00
|
|
|
return ret;
|
2022-06-08 14:37:30 +02:00
|
|
|
}
|
2022-09-12 04:54:00 -04:00
|
|
|
case LAB_NODE_DESC_LAYER_SURFACE:
|
2022-12-22 21:58:55 +00:00
|
|
|
ret.node = node;
|
|
|
|
|
ret.type = LAB_SSD_LAYER_SURFACE;
|
|
|
|
|
ret.surface = get_surface_from_layer_node(node);
|
|
|
|
|
return ret;
|
2022-09-12 04:54:00 -04:00
|
|
|
case LAB_NODE_DESC_LAYER_POPUP:
|
2022-12-22 21:58:55 +00:00
|
|
|
ret.node = node;
|
2022-09-12 04:54:00 -04:00
|
|
|
ret.type = LAB_SSD_CLIENT;
|
2022-12-22 21:58:55 +00:00
|
|
|
ret.surface = get_surface_from_layer_node(node);
|
2022-09-12 04:54:00 -04:00
|
|
|
return ret;
|
|
|
|
|
case LAB_NODE_DESC_MENUITEM:
|
2022-03-03 04:33:33 +01:00
|
|
|
/* Always return the top scene node for menu items */
|
2022-09-12 04:54:00 -04:00
|
|
|
ret.node = node;
|
|
|
|
|
ret.type = LAB_SSD_MENU;
|
|
|
|
|
return ret;
|
|
|
|
|
case LAB_NODE_DESC_NODE:
|
|
|
|
|
case LAB_NODE_DESC_TREE:
|
|
|
|
|
break;
|
2022-03-03 04:33:33 +01:00
|
|
|
}
|
2022-02-25 22:31:24 +00:00
|
|
|
}
|
2022-12-29 20:16:32 +00:00
|
|
|
|
|
|
|
|
/* Edge-case nodes without node-descriptors */
|
|
|
|
|
if (node->type == WLR_SCENE_NODE_BUFFER) {
|
|
|
|
|
struct wlr_surface *surface = lab_wlr_surface_from_node(node);
|
|
|
|
|
if (surface) {
|
2023-01-28 22:34:27 +00:00
|
|
|
if (wlr_surface_is_layer_surface(surface)) {
|
|
|
|
|
ret.type = LAB_SSD_LAYER_SURFACE;
|
|
|
|
|
}
|
2022-12-29 20:16:32 +00:00
|
|
|
if (is_layer_descendant(node)) {
|
|
|
|
|
/*
|
|
|
|
|
* layer-shell subsurfaces need to be
|
|
|
|
|
* able to receive pointer actions.
|
|
|
|
|
*
|
|
|
|
|
* Test by running
|
|
|
|
|
* `gtk-layer-demo -k exclusive`, then
|
|
|
|
|
* open the 'set margin' dialog and try
|
|
|
|
|
* setting the margin with the pointer.
|
|
|
|
|
*/
|
|
|
|
|
ret.surface = surface;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 15:17:35 +02:00
|
|
|
/* node->parent is always a *wlr_scene_tree */
|
|
|
|
|
node = node->parent ? &node->parent->node : NULL;
|
2021-09-25 09:40:23 +01:00
|
|
|
}
|
2022-09-12 04:54:00 -04:00
|
|
|
wlr_log(WLR_ERROR, "Unknown node detected");
|
|
|
|
|
return ret;
|
2021-11-26 13:03:15 -05:00
|
|
|
}
|