Respect layers for cursor motion
This commit is contained in:
parent
678b4ce549
commit
c1972bfefc
4 changed files with 71 additions and 9 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/types/wlr_box.h>
|
#include <wlr/types/wlr_box.h>
|
||||||
|
#include <wlr/types/wlr_surface.h>
|
||||||
|
|
||||||
#include "desktop/output.h"
|
#include "desktop/output.h"
|
||||||
|
|
||||||
|
@ -29,6 +30,13 @@ struct kiwmi_layer {
|
||||||
|
|
||||||
void arrange_layers(struct kiwmi_output *output);
|
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);
|
void layer_shell_new_surface_notify(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
#endif /* KIWMI_DESKTOP_LAYER_SHELL_H */
|
#endif /* KIWMI_DESKTOP_LAYER_SHELL_H */
|
||||||
|
|
|
@ -300,6 +300,36 @@ arrange_layers(struct kiwmi_output *output)
|
||||||
seat_focus_layer(seat, topmost);
|
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
|
void
|
||||||
layer_shell_new_surface_notify(struct wl_listener *listener, void *data)
|
layer_shell_new_surface_notify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,11 +93,12 @@ surface_at(
|
||||||
double view_sx = lx - view->x + view->geom.x;
|
double view_sx = lx - view->x + view->geom.x;
|
||||||
double view_sy = ly - view->y + view->geom.y;
|
double view_sy = ly - view->y + view->geom.y;
|
||||||
|
|
||||||
double _sx, _sy;
|
double _sx;
|
||||||
struct wlr_surface *_surface = NULL;
|
double _sy;
|
||||||
_surface = view_surface_at(view, view_sx, view_sy, &_sx, &_sy);
|
struct wlr_surface *_surface =
|
||||||
|
view_surface_at(view, view_sx, view_sy, &_sx, &_sy);
|
||||||
|
|
||||||
if (_surface != NULL) {
|
if (_surface) {
|
||||||
*sx = _sx;
|
*sx = _sx;
|
||||||
*sy = _sy;
|
*sy = _sy;
|
||||||
*surface = _surface;
|
*surface = _surface;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/types/wlr_cursor.h>
|
#include <wlr/types/wlr_cursor.h>
|
||||||
|
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_pointer.h>
|
#include <wlr/types/wlr_pointer.h>
|
||||||
#include <wlr/types/wlr_seat.h>
|
#include <wlr/types/wlr_seat.h>
|
||||||
|
@ -18,6 +19,8 @@
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
#include "desktop/desktop.h"
|
#include "desktop/desktop.h"
|
||||||
|
#include "desktop/layer_shell.h"
|
||||||
|
#include "desktop/output.h"
|
||||||
#include "desktop/view.h"
|
#include "desktop/view.h"
|
||||||
#include "input/seat.h"
|
#include "input/seat.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
@ -80,10 +83,29 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time)
|
||||||
break;
|
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;
|
struct wlr_surface *surface = NULL;
|
||||||
double sx;
|
double sx;
|
||||||
double sy;
|
double 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 (!layer) {
|
||||||
struct kiwmi_view *view = view_at(
|
struct kiwmi_view *view = view_at(
|
||||||
desktop, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
desktop, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
||||||
|
|
||||||
|
@ -91,6 +113,7 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time)
|
||||||
wlr_xcursor_manager_set_cursor_image(
|
wlr_xcursor_manager_set_cursor_image(
|
||||||
cursor->xcursor_manager, "left_ptr", cursor->cursor);
|
cursor->xcursor_manager, "left_ptr", cursor->cursor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (surface) {
|
if (surface) {
|
||||||
bool focus_changed = surface != seat->pointer_state.focused_surface;
|
bool focus_changed = surface != seat->pointer_state.focused_surface;
|
||||||
|
|
Loading…
Reference in a new issue