fix resize, move and border bugs
This commit is contained in:
+10
-8
@@ -127,6 +127,16 @@ static void process_cursor_resize(struct absinthe_server *server) {
|
||||
|
||||
void process_cursor_motion(struct absinthe_server *server, uint32_t time)
|
||||
{
|
||||
double sx, sy;
|
||||
struct wlr_seat *seat = server->seat;
|
||||
struct wlr_surface *surface = NULL;
|
||||
struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy);
|
||||
|
||||
if (!toplevel) {
|
||||
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server->cursor_mode == ABSINTHE_CURSOR_MOVE) {
|
||||
process_cursor_move(server);
|
||||
return;
|
||||
@@ -135,14 +145,6 @@ void process_cursor_motion(struct absinthe_server *server, uint32_t time)
|
||||
return;
|
||||
}
|
||||
|
||||
double sx, sy;
|
||||
struct wlr_seat *seat = server->seat;
|
||||
struct wlr_surface *surface = NULL;
|
||||
struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy);
|
||||
|
||||
if (!toplevel)
|
||||
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default");
|
||||
|
||||
if (surface) {
|
||||
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
||||
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
|
||||
|
||||
+5
-5
@@ -31,7 +31,7 @@ void server_new_output(struct wl_listener *listener, void *data)
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
struct absinthe_output *output = calloc(1, sizeof(*output));
|
||||
struct absinthe_output *output = malloc(sizeof(*output));
|
||||
output->wlr_output = wlr_output;
|
||||
output->server = server;
|
||||
|
||||
@@ -57,7 +57,7 @@ void server_new_xdg_toplevel(struct wl_listener *listener, void *data)
|
||||
struct absinthe_server *server = wl_container_of(listener, server, new_xdg_toplevel);
|
||||
struct wlr_xdg_toplevel *xdg_toplevel = data;
|
||||
|
||||
struct absinthe_toplevel *toplevel = calloc(1, sizeof(*toplevel));
|
||||
struct absinthe_toplevel *toplevel = malloc(sizeof(*toplevel));
|
||||
toplevel->server = server;
|
||||
toplevel->xdg_toplevel = xdg_toplevel;
|
||||
toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree);
|
||||
@@ -90,12 +90,12 @@ void server_new_xdg_popup(struct wl_listener *listener, void *data)
|
||||
struct absinthe_server *server = wl_container_of(listener, server, new_xdg_popup);
|
||||
struct wlr_xdg_popup *xdg_popup = data;
|
||||
|
||||
struct absinthe_popup *popup = calloc(1, sizeof(*popup));
|
||||
struct absinthe_popup *popup = malloc(sizeof(*popup));
|
||||
popup->xdg_popup = xdg_popup;
|
||||
|
||||
struct wlr_xdg_surface *parent = wlr_xdg_surface_try_from_wlr_surface(xdg_popup->parent);
|
||||
struct absinthe_toplevel *parent_toplevel = parent->data;
|
||||
struct wlr_scene_tree *parent_tree = parent_toplevel->scene_tree;
|
||||
struct wlr_scene_tree *parent_tree = parent_toplevel->scene_tree;
|
||||
xdg_popup->base->data = wlr_scene_xdg_surface_create(parent_tree, xdg_popup->base);
|
||||
|
||||
popup->commit.notify = xdg_popup_commit;
|
||||
@@ -221,7 +221,7 @@ void server_cursor_frame(struct wl_listener *listener, void *data)
|
||||
static void server_new_keyboard(struct absinthe_server *server, struct wlr_input_device *device)
|
||||
{
|
||||
struct wlr_keyboard *wlr_keyboard = wlr_keyboard_from_input_device(device);
|
||||
struct absinthe_keyboard *keyboard = calloc(1, sizeof(*keyboard));
|
||||
struct absinthe_keyboard *keyboard = malloc(sizeof(*keyboard));
|
||||
keyboard->server = server;
|
||||
keyboard->wlr_keyboard = wlr_keyboard;
|
||||
|
||||
|
||||
+7
-16
@@ -1,4 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/util/log.h>
|
||||
@@ -12,24 +13,17 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data)
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, commit);
|
||||
|
||||
if (toplevel->xdg_toplevel->base->initial_commit) {
|
||||
// Let client set the preferred size
|
||||
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, 0, 0);
|
||||
|
||||
// Forse server side decoration mode
|
||||
if (toplevel->decoration)
|
||||
xdg_decoration_request_mode(&toplevel->decoration_request_mode, toplevel->decoration);
|
||||
|
||||
// Let toplevel set preferred size
|
||||
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, 0, 0);
|
||||
} else {
|
||||
// Check for size because we did't set it on initial commit
|
||||
if (toplevel->geometry.width == 0 || toplevel->geometry.height == 0) {
|
||||
int32_t bw = toplevel->border_width;
|
||||
toplevel->geometry.width = toplevel->xdg_toplevel->base->geometry.width + 2 * bw;
|
||||
toplevel->geometry.height = toplevel->xdg_toplevel->base->geometry.height + 2 * bw;
|
||||
|
||||
int32_t rel_x = toplevel->output->geometry.x + toplevel->output->geometry.width / 2 - toplevel->geometry.width / 2;
|
||||
int32_t rel_y = toplevel->output->geometry.y + toplevel->output->geometry.height / 2 - toplevel->geometry.height / 2;
|
||||
toplevel->geometry.x += abs(rel_x);
|
||||
toplevel->geometry.y += abs(rel_y);
|
||||
}
|
||||
int32_t bw = toplevel->border_width;
|
||||
toplevel->geometry.width = toplevel->xdg_toplevel->base->geometry.width + 2 * bw;
|
||||
toplevel->geometry.height = toplevel->xdg_toplevel->base->geometry.height + 2 * bw;
|
||||
|
||||
absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
|
||||
absinthe_toplevel_update_borders_geometry(toplevel);
|
||||
@@ -48,9 +42,6 @@ void xdg_toplevel_map(struct wl_listener *listener, void *data)
|
||||
|
||||
toplevel->border_width = ABSINTHE_WINDOW_BORDER_WIDTH;
|
||||
|
||||
absinthe_toplevel_set_border_color(toplevel, unfocused_border_color);
|
||||
absinthe_toplevel_update_borders_geometry(toplevel);
|
||||
|
||||
toplevel->output = toplevel->server->focused_output;
|
||||
toplevel->fullscreen = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user