improve xdg + layer shell support
This commit is contained in:
68
cursor.c
68
cursor.c
@@ -2,23 +2,60 @@
|
||||
#include <wlr/util/log.h>
|
||||
#include <assert.h>
|
||||
#include "cursor.h"
|
||||
#include "desktop.h"
|
||||
#include "view.h"
|
||||
#include "seat.h"
|
||||
#include "node.h"
|
||||
|
||||
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;
|
||||
if(!desc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* Focus that client if the button was _pressed_ */
|
||||
switch (desc->type)
|
||||
{
|
||||
case DIYAC_NODE_VIEW:
|
||||
diyac_focus_view(desc->data, true);
|
||||
break;
|
||||
case DIYAC_NODE_LAYER_SURFACE:
|
||||
layer = desc->data;
|
||||
assert(layer);
|
||||
assert(layer->scene_layer_surface);
|
||||
diyac_seat_focus_layer(&server->seat,layer->scene_layer_surface->layer_surface);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void diyac_reset_cursor_mode(struct diyac_server *server)
|
||||
{
|
||||
/* Reset the cursor mode to passthrough. */
|
||||
server->seat.cursor_mode = DIYAC_CURSOR_PASSTHROUGH;
|
||||
server->grabbed_view = NULL;
|
||||
//struct diyac_view * view = diyac_view_at()
|
||||
}
|
||||
|
||||
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;
|
||||
toplevel->current.x = server->seat.cursor->x - server->grab_x;
|
||||
toplevel->current.y = server->seat.cursor->y - server->grab_y;
|
||||
if(toplevel->state != DIYAC_VIEW_NORMAL)
|
||||
{
|
||||
// move the windows to cursor
|
||||
server->grab_x = toplevel->original.width * server->grab_x / toplevel->output->usable_area.width;
|
||||
}
|
||||
toplevel->state = DIYAC_VIEW_NORMAL;
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
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,
|
||||
toplevel->current.x ,
|
||||
@@ -81,14 +118,14 @@ static void process_cursor_resize(struct diyac_server *server, uint32_t time)
|
||||
|
||||
struct wlr_box geo_box;
|
||||
wlr_xdg_surface_get_geometry(toplevel->xdg_toplevel->base, &geo_box);
|
||||
toplevel->current.x = new_left - geo_box.x;
|
||||
toplevel->current.y = new_top - geo_box.y;
|
||||
toplevel->original.x = new_left - geo_box.x;
|
||||
toplevel->original.y = new_top - geo_box.y;
|
||||
int new_width = new_right - new_left;
|
||||
int new_height = new_bottom - new_top;
|
||||
toplevel->current.width = new_width;
|
||||
toplevel->current.height = new_height;
|
||||
toplevel->original.width = new_width;
|
||||
toplevel->original.height = new_height;
|
||||
toplevel->state = DIYAC_VIEW_NORMAL;
|
||||
diyac_view_update_geometry(toplevel, true);
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
/*
|
||||
wlr_scene_node_set_position(&toplevel->scene_tree->node,
|
||||
toplevel->current.x, toplevel->current.y);
|
||||
@@ -114,9 +151,9 @@ static void process_cursor_motion(struct diyac_server *server, uint32_t time)
|
||||
double sx, sy;
|
||||
struct wlr_seat *seat = server->seat.wlr_seat;
|
||||
struct wlr_surface *surface = NULL;
|
||||
struct diyac_view *toplevel = diyac_view_at(server,
|
||||
struct diyac_node_descriptor *desc = diyac_node_at(server,
|
||||
server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy);
|
||||
if (!toplevel)
|
||||
if (!desc)
|
||||
{
|
||||
/* If there's no toplevel under the cursor, set the cursor image to a
|
||||
* default. This is what makes the cursor image appear when you move it
|
||||
@@ -191,10 +228,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);
|
||||
double sx, sy;
|
||||
struct wlr_surface *surface = NULL;
|
||||
struct diyac_view *toplevel = diyac_view_at(seat->server,
|
||||
seat->cursor->x, seat->cursor->y, &surface, &sx, &sy);
|
||||
|
||||
if (event->state == WLR_BUTTON_RELEASED)
|
||||
{
|
||||
/* If you released any buttons, we exit interactive move/resize mode. */
|
||||
@@ -202,8 +236,8 @@ static void server_cursor_button(struct wl_listener *listener, void *data)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Focus that client if the button was _pressed_ */
|
||||
diyac_focus_view(toplevel);
|
||||
diyac_cursor_focus(seat->server);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user