diff --git a/include/desktop/layer_shell.h b/include/desktop/layer_shell.h index 47f9711..035580d 100644 --- a/include/desktop/layer_shell.h +++ b/include/desktop/layer_shell.h @@ -12,6 +12,7 @@ #include #include +#include #include "desktop/output.h" @@ -29,6 +30,13 @@ struct kiwmi_layer { void arrange_layers(struct kiwmi_output *output); +struct kiwmi_layer *layer_at( + struct wl_list *layers, + struct wlr_surface **surface, + double ox, + double oy, + double *sx, + double *sy); void layer_shell_new_surface_notify(struct wl_listener *listener, void *data); #endif /* KIWMI_DESKTOP_LAYER_SHELL_H */ diff --git a/kiwmi/desktop/layer_shell.c b/kiwmi/desktop/layer_shell.c index 093a90e..cd9b287 100644 --- a/kiwmi/desktop/layer_shell.c +++ b/kiwmi/desktop/layer_shell.c @@ -300,6 +300,36 @@ arrange_layers(struct kiwmi_output *output) seat_focus_layer(seat, topmost); } +struct kiwmi_layer * +layer_at( + struct wl_list *layers, + struct wlr_surface **surface, + double ox, + double oy, + double *sx, + double *sy) +{ + struct kiwmi_layer *layer; + wl_list_for_each_reverse (layer, layers, link) { + double layer_sx = ox - layer->geom.x; + double layer_sy = oy - layer->geom.y; + + double _sx; + double _sy; + struct wlr_surface *_surface = wlr_layer_surface_v1_surface_at( + layer->layer_surface, layer_sx, layer_sy, &_sx, &_sy); + + if (_surface) { + *sx = _sx; + *sy = _sy; + *surface = _surface; + return layer; + } + } + + return NULL; +} + void layer_shell_new_surface_notify(struct wl_listener *listener, void *data) { diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index ddad277..b0f6b47 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -93,11 +93,12 @@ surface_at( double view_sx = lx - view->x + view->geom.x; double view_sy = ly - view->y + view->geom.y; - double _sx, _sy; - struct wlr_surface *_surface = NULL; - _surface = view_surface_at(view, view_sx, view_sy, &_sx, &_sy); + double _sx; + double _sy; + struct wlr_surface *_surface = + view_surface_at(view, view_sx, view_sy, &_sx, &_sy); - if (_surface != NULL) { + if (_surface) { *sx = _sx; *sy = _sy; *surface = _surface; diff --git a/kiwmi/input/cursor.c b/kiwmi/input/cursor.c index ef6e53e..5fbd5a6 100644 --- a/kiwmi/input/cursor.c +++ b/kiwmi/input/cursor.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,8 @@ #include #include "desktop/desktop.h" +#include "desktop/layer_shell.h" +#include "desktop/output.h" #include "desktop/view.h" #include "input/seat.h" #include "server.h" @@ -80,16 +83,36 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time) break; } + double ox = 0; + double oy = 0; + struct wlr_output *wlr_output = wlr_output_layout_output_at( + desktop->output_layout, cursor->cursor->x, cursor->cursor->y); + + wlr_output_layout_output_coords( + desktop->output_layout, wlr_output, &ox, &oy); + + struct kiwmi_output *output = wlr_output->data; + struct wlr_surface *surface = NULL; double sx; double sy; - struct kiwmi_view *view = view_at( - desktop, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); + struct kiwmi_layer *layer = layer_at( + &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], + &surface, + cursor->cursor->x, + cursor->cursor->y, + &sx, + &sy); - if (!view) { - wlr_xcursor_manager_set_cursor_image( - cursor->xcursor_manager, "left_ptr", cursor->cursor); + if (!layer) { + struct kiwmi_view *view = view_at( + desktop, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); + + if (!view) { + wlr_xcursor_manager_set_cursor_image( + cursor->xcursor_manager, "left_ptr", cursor->cursor); + } } if (surface) {