Merge branch 'master' into refactor-wlr-list

master
emersion 7 years ago
commit 151901123f
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -1,2 +0,0 @@
// This is used to make meson happy
void dummy(void);

@ -53,12 +53,6 @@ struct roots_cursor {
struct wl_listener tool_axis; struct wl_listener tool_axis;
struct wl_listener tool_tip; struct wl_listener tool_tip;
struct wl_listener pointer_grab_begin;
struct wl_listener pointer_grab_end;
struct wl_listener touch_grab_begin;
struct wl_listener touch_grab_end;
struct wl_listener request_set_cursor; struct wl_listener request_set_cursor;
}; };
@ -96,16 +90,4 @@ void roots_cursor_handle_tool_tip(struct roots_cursor *cursor,
void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor, void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
struct wlr_seat_pointer_request_set_cursor_event *event); struct wlr_seat_pointer_request_set_cursor_event *event);
void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
struct wlr_seat_pointer_grab *grab);
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
struct wlr_seat_pointer_grab *grab);
void roots_cursor_handle_touch_grab_begin(struct roots_cursor *cursor,
struct wlr_seat_touch_grab *grab);
void roots_cursor_handle_touch_grab_end(struct roots_cursor *cursor,
struct wlr_seat_touch_grab *grab);
#endif #endif

@ -23,7 +23,7 @@ struct roots_output {
}; };
struct roots_desktop { struct roots_desktop {
struct wlr_list *views; struct wl_list views; // roots_view::link
struct wl_list outputs; struct wl_list outputs;
struct timespec last_frame; struct timespec last_frame;
@ -50,6 +50,7 @@ struct roots_desktop {
#ifdef HAS_XWAYLAND #ifdef HAS_XWAYLAND
struct wlr_xwayland *xwayland; struct wlr_xwayland *xwayland;
struct wl_listener xwayland_surface; struct wl_listener xwayland_surface;
struct wl_listener xwayland_ready;
#endif #endif
}; };
@ -59,6 +60,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
struct roots_config *config); struct roots_config *config);
void desktop_destroy(struct roots_desktop *desktop); void desktop_destroy(struct roots_desktop *desktop);
void view_init(struct roots_view *view, struct roots_desktop *desktop);
void view_destroy(struct roots_view *view); void view_destroy(struct roots_view *view);
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy); struct wlr_surface **surface, double *sx, double *sy);

@ -4,33 +4,18 @@
#include "rootston/input.h" #include "rootston/input.h"
#include "rootston/keyboard.h" #include "rootston/keyboard.h"
struct roots_drag_icon {
struct wlr_surface *surface;
struct wl_list link; // roots_seat::drag_icons
bool mapped;
bool is_pointer;
int32_t touch_id;
int32_t sx;
int32_t sy;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
};
struct roots_seat { struct roots_seat {
struct roots_input *input; struct roots_input *input;
struct wlr_seat *seat; struct wlr_seat *seat;
struct roots_cursor *cursor; struct roots_cursor *cursor;
struct wl_list link; struct wl_list link;
struct wl_list drag_icons;
// coordinates of the first touch point if it exists // coordinates of the first touch point if it exists
int32_t touch_id; int32_t touch_id;
double touch_x, touch_y; double touch_x, touch_y;
struct roots_view *focus; struct wl_list views; // roots_seat_view::link
bool has_focus;
struct wl_list keyboards; struct wl_list keyboards;
struct wl_list pointers; struct wl_list pointers;
@ -38,6 +23,14 @@ struct roots_seat {
struct wl_list tablet_tools; struct wl_list tablet_tools;
}; };
struct roots_seat_view {
struct roots_seat *seat;
struct roots_view *view;
struct wl_list link; // roots_seat::views
struct wl_listener view_destroy;
};
struct roots_pointer { struct roots_pointer {
struct roots_seat *seat; struct roots_seat *seat;
struct wlr_input_device *device; struct wlr_input_device *device;
@ -76,7 +69,11 @@ void roots_seat_configure_xcursor(struct roots_seat *seat);
bool roots_seat_has_meta_pressed(struct roots_seat *seat); bool roots_seat_has_meta_pressed(struct roots_seat *seat);
void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view); struct roots_view *roots_seat_get_focus(struct roots_seat *seat);
void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view);
void roots_seat_cycle_focus(struct roots_seat *seat);
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view); void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view);

@ -9,7 +9,6 @@
struct roots_wl_shell_surface { struct roots_wl_shell_surface {
struct roots_view *view; struct roots_view *view;
// TODO: Maybe destroy listener should go in roots_view
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener request_move; struct wl_listener request_move;
struct wl_listener request_resize; struct wl_listener request_resize;
@ -22,7 +21,6 @@ struct roots_wl_shell_surface {
struct roots_xdg_surface_v6 { struct roots_xdg_surface_v6 {
struct roots_view *view; struct roots_view *view;
// TODO: Maybe destroy listener should go in roots_view
struct wl_listener commit; struct wl_listener commit;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener request_move; struct wl_listener request_move;
@ -33,7 +31,6 @@ struct roots_xdg_surface_v6 {
struct roots_xwayland_surface { struct roots_xwayland_surface {
struct roots_view *view; struct roots_view *view;
// TODO: Maybe destroy listener should go in roots_view
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener request_configure; struct wl_listener request_configure;
struct wl_listener request_move; struct wl_listener request_move;
@ -51,6 +48,7 @@ enum roots_view_type {
struct roots_view { struct roots_view {
struct roots_desktop *desktop; struct roots_desktop *desktop;
struct wl_list link; // roots_desktop::views
double x, y; double x, y;
float rotation; float rotation;
@ -80,6 +78,10 @@ struct roots_view {
}; };
struct wlr_surface *wlr_surface; struct wlr_surface *wlr_surface;
struct {
struct wl_signal destroy;
} events;
// TODO: This would probably be better as a field that's updated on a // TODO: This would probably be better as a field that's updated on a
// configure event from the xdg_shell // configure event from the xdg_shell
// If not then this should follow the typical type/impl pattern we use // If not then this should follow the typical type/impl pattern we use

@ -53,6 +53,27 @@ struct wlr_data_source {
} events; } events;
}; };
struct wlr_drag_icon {
struct wlr_surface *surface;
struct wlr_seat_client *client;
struct wl_list link; // wlr_seat::drag_icons
bool mapped;
bool is_pointer;
int32_t touch_id;
int32_t sx;
int32_t sy;
struct {
struct wl_signal destroy;
} events;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct wl_listener seat_client_destroy;
};
struct wlr_drag { struct wlr_drag {
struct wlr_seat_pointer_grab pointer_grab; struct wlr_seat_pointer_grab pointer_grab;
struct wlr_seat_keyboard_grab keyboard_grab; struct wlr_seat_keyboard_grab keyboard_grab;
@ -64,7 +85,7 @@ struct wlr_drag {
bool is_pointer_grab; bool is_pointer_grab;
struct wlr_surface *icon; struct wlr_drag_icon *icon;
struct wlr_surface *focus; struct wlr_surface *focus;
struct wlr_data_source *source; struct wlr_data_source *source;
@ -72,9 +93,9 @@ struct wlr_drag {
int32_t grab_touch_id; int32_t grab_touch_id;
struct wl_listener point_destroy; struct wl_listener point_destroy;
struct wl_listener icon_destroy;
struct wl_listener source_destroy; struct wl_listener source_destroy;
struct wl_listener seat_client_unbound; struct wl_listener seat_client_destroy;
struct wl_listener icon_destroy;
}; };
/** /**

@ -21,6 +21,10 @@ struct wlr_seat_client {
struct wl_resource *touch; struct wl_resource *touch;
struct wl_resource *data_device; struct wl_resource *data_device;
struct {
struct wl_signal destroy;
} events;
struct wl_list link; struct wl_list link;
}; };
@ -165,6 +169,8 @@ struct wlr_seat {
struct wl_global *wl_global; struct wl_global *wl_global;
struct wl_display *display; struct wl_display *display;
struct wl_list clients; struct wl_list clients;
struct wl_list drag_icons; // wlr_drag_icon::link
char *name; char *name;
uint32_t capabilities; uint32_t capabilities;
struct timespec last_event; struct timespec last_event;
@ -180,9 +186,6 @@ struct wlr_seat {
struct wl_listener selection_data_source_destroy; struct wl_listener selection_data_source_destroy;
struct { struct {
struct wl_signal client_bound;
struct wl_signal client_unbound;
struct wl_signal pointer_grab_begin; struct wl_signal pointer_grab_begin;
struct wl_signal pointer_grab_end; struct wl_signal pointer_grab_end;

@ -131,7 +131,6 @@ wlr_deps = [
lib_wlr = library( lib_wlr = library(
'wlroots', 'wlroots',
files('dummy.c'),
link_whole: wlr_parts, link_whole: wlr_parts,
dependencies: wlr_deps, dependencies: wlr_deps,
include_directories: wlr_inc, include_directories: wlr_inc,

@ -58,19 +58,21 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
} }
break; break;
case ROOTS_CURSOR_MOVE: case ROOTS_CURSOR_MOVE:
if (seat->focus) { view = roots_seat_get_focus(seat);
if (view != NULL) {
double dx = cursor->cursor->x - cursor->offs_x; double dx = cursor->cursor->x - cursor->offs_x;
double dy = cursor->cursor->y - cursor->offs_y; double dy = cursor->cursor->y - cursor->offs_y;
view_move(seat->focus, cursor->view_x + dx, view_move(view, cursor->view_x + dx,
cursor->view_y + dy); cursor->view_y + dy);
} }
break; break;
case ROOTS_CURSOR_RESIZE: case ROOTS_CURSOR_RESIZE:
if (seat->focus) { view = roots_seat_get_focus(seat);
if (view != NULL) {
double dx = cursor->cursor->x - cursor->offs_x; double dx = cursor->cursor->x - cursor->offs_x;
double dy = cursor->cursor->y - cursor->offs_y; double dy = cursor->cursor->y - cursor->offs_y;
double active_x = seat->focus->x; double active_x = view->x;
double active_y = seat->focus->y; double active_y = view->y;
int width = cursor->view_width; int width = cursor->view_width;
int height = cursor->view_height; int height = cursor->view_height;
if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) {
@ -99,18 +101,18 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
height = 0; height = 0;
} }
if (active_x != seat->focus->x || if (active_x != view->x ||
active_y != seat->focus->y) { active_y != view->y) {
view_move_resize(seat->focus, active_x, active_y, view_move_resize(view, active_x, active_y,
width, height); width, height);
} else { } else {
view_resize(seat->focus, width, height); view_resize(view, width, height);
} }
} }
break; break;
case ROOTS_CURSOR_ROTATE: case ROOTS_CURSOR_ROTATE:
if (seat->focus) { view = roots_seat_get_focus(seat);
struct roots_view *view = seat->focus; if (view != NULL) {
int ox = view->x + view->wlr_surface->current->width/2, int ox = view->x + view->wlr_surface->current->width/2,
oy = view->y + view->wlr_surface->current->height/2; oy = view->y + view->wlr_surface->current->height/2;
int ux = cursor->offs_x - ox, int ux = cursor->offs_x - ox,
@ -124,7 +126,6 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
} }
break; break;
} }
} }
static void roots_cursor_press_button(struct roots_cursor *cursor, static void roots_cursor_press_button(struct roots_cursor *cursor,
@ -141,7 +142,7 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
if (state == WLR_BUTTON_PRESSED && if (state == WLR_BUTTON_PRESSED &&
view && view &&
roots_seat_has_meta_pressed(seat)) { roots_seat_has_meta_pressed(seat)) {
roots_seat_focus_view(seat, view); roots_seat_set_focus(seat, view);
uint32_t edges; uint32_t edges;
switch (button) { switch (button) {
@ -192,7 +193,7 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
cursor->input_events[i].device = device; cursor->input_events[i].device = device;
cursor->input_events_idx = (i + 1) cursor->input_events_idx = (i + 1)
% (sizeof(cursor->input_events) / sizeof(cursor->input_events[0])); % (sizeof(cursor->input_events) / sizeof(cursor->input_events[0]));
roots_seat_focus_view(seat, view); roots_seat_set_focus(seat, view);
break; break;
} }
} }
@ -354,105 +355,3 @@ void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
event->hotspot_y); event->hotspot_y);
cursor->cursor_client = event->seat_client->client; cursor->cursor_client = event->seat_client->client;
} }
static void handle_drag_icon_commit(struct wl_listener *listener, void *data) {
struct roots_drag_icon *drag_icon =
wl_container_of(listener, drag_icon, surface_commit);
drag_icon->sx += drag_icon->surface->current->sx;
drag_icon->sy += drag_icon->surface->current->sy;
}
static void handle_drag_icon_destroy(struct wl_listener *listener, void *data) {
struct roots_drag_icon *drag_icon =
wl_container_of(listener, drag_icon, surface_destroy);
wl_list_remove(&drag_icon->link);
wl_list_remove(&drag_icon->surface_destroy.link);
wl_list_remove(&drag_icon->surface_commit.link);
free(drag_icon);
}
static struct roots_drag_icon *seat_add_drag_icon(struct roots_seat *seat,
struct wlr_surface *icon_surface) {
if (!icon_surface) {
return NULL;
}
struct roots_drag_icon *iter_icon;
wl_list_for_each(iter_icon, &seat->drag_icons, link) {
if (iter_icon->surface == icon_surface) {
// already in the list
return iter_icon;
}
}
struct roots_drag_icon *drag_icon =
calloc(1, sizeof(struct roots_drag_icon));
drag_icon->mapped = true;
drag_icon->surface = icon_surface;
wl_list_insert(&seat->drag_icons, &drag_icon->link);
wl_signal_add(&icon_surface->events.destroy,
&drag_icon->surface_destroy);
drag_icon->surface_destroy.notify = handle_drag_icon_destroy;
wl_signal_add(&icon_surface->events.commit,
&drag_icon->surface_commit);
drag_icon->surface_commit.notify = handle_drag_icon_commit;
return drag_icon;
}
static void seat_unmap_drag_icon(struct roots_seat *seat,
struct wlr_surface *icon_surface) {
if (!icon_surface) {
return;
}
struct roots_drag_icon *icon;
wl_list_for_each(icon, &seat->drag_icons, link) {
if (icon->surface == icon_surface) {
icon->mapped = false;
}
}
}
void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
struct wlr_seat_pointer_grab *grab) {
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
struct wlr_drag *drag = grab->data;
struct roots_drag_icon *icon =
seat_add_drag_icon(cursor->seat, drag->icon);
if (icon) {
icon->is_pointer = true;
}
}
}
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
struct wlr_seat_pointer_grab *grab) {
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
struct wlr_drag *drag = grab->data;
seat_unmap_drag_icon(cursor->seat, drag->icon);
}
}
void roots_cursor_handle_touch_grab_begin(struct roots_cursor *cursor,
struct wlr_seat_touch_grab *grab) {
if (grab->interface == &wlr_data_device_touch_drag_interface) {
struct wlr_drag *drag = grab->data;
struct roots_drag_icon *icon =
seat_add_drag_icon(cursor->seat, drag->icon);
if (icon) {
icon->is_pointer = false;
icon->touch_id = drag->grab_touch_id;
}
}
}
void roots_cursor_handle_touch_grab_end(struct roots_cursor *cursor,
struct wlr_seat_touch_grab *grab) {
if (grab->interface == &wlr_data_device_touch_drag_interface) {
struct wlr_drag *drag = grab->data;
seat_unmap_drag_icon(cursor->seat, drag->icon);
}
}

@ -18,29 +18,6 @@
#include "rootston/seat.h" #include "rootston/seat.h"
#include "rootston/xcursor.h" #include "rootston/xcursor.h"
// TODO replace me with a signal
void view_destroy(struct roots_view *view) {
struct roots_desktop *desktop = view->desktop;
struct roots_input *input = desktop->server->input;
struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) {
if (seat->focus == view) {
seat->focus = NULL;
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
}
}
for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *_view = desktop->views->items[i];
if (view == _view) {
wlr_list_del(desktop->views, i);
break;
}
}
free(view);
}
void view_get_box(const struct roots_view *view, struct wlr_box *box) { void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x; box->x = view->x;
box->y = view->y; box->y = view->y;
@ -201,12 +178,23 @@ bool view_center(struct roots_view *view) {
return true; return true;
} }
void view_destroy(struct roots_view *view) {
wl_signal_emit(&view->events.destroy, view);
free(view);
}
void view_init(struct roots_view *view, struct roots_desktop *desktop) {
view->desktop = desktop;
wl_signal_init(&view->events.destroy);
}
void view_setup(struct roots_view *view) { void view_setup(struct roots_view *view) {
struct roots_input *input = view->desktop->server->input; struct roots_input *input = view->desktop->server->input;
// TODO what seat gets focus? the one with the last input event? // TODO what seat gets focus? the one with the last input event?
struct roots_seat *seat; struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) { wl_list_for_each(seat, &input->seats, link) {
roots_seat_focus_view(seat, view); roots_seat_set_focus(seat, view);
} }
view_center(view); view_center(view);
@ -215,25 +203,10 @@ void view_setup(struct roots_view *view) {
view_update_output(view, &before); view_update_output(view, &before);
} }
void view_teardown(struct roots_view *view) {
// TODO replace me with a signal
/*
struct wlr_list *views = view->desktop->views;
if (views->length < 2 || views->items[views->length-1] != view) {
return;
}
struct roots_view *prev_view = views->items[views->length-2];
struct roots_input *input = prev_view->desktop->server->input;
set_view_focus(input, prev_view->desktop, prev_view);
*/
}
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
for (ssize_t i = desktop->views->length - 1; i >= 0; --i) { struct roots_view *view;
struct roots_view *view = desktop->views->items[i]; wl_list_for_each(view, &desktop->views, link) {
if (view->type == ROOTS_WL_SHELL_VIEW && if (view->type == ROOTS_WL_SHELL_VIEW &&
view->wl_shell_surface->state == view->wl_shell_surface->state ==
WLR_WL_SHELL_SURFACE_STATE_POPUP) { WLR_WL_SHELL_SURFACE_STATE_POPUP) {
@ -322,11 +295,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
return NULL; return NULL;
} }
desktop->views = wlr_list_create(); wl_list_init(&desktop->views);
if (desktop->views == NULL) {
free(desktop);
return NULL;
}
wl_list_init(&desktop->outputs); wl_list_init(&desktop->outputs);
desktop->output_add.notify = output_add_notify; desktop->output_add.notify = output_add_notify;
@ -350,7 +319,6 @@ struct roots_desktop *desktop_create(struct roots_server *server,
if (desktop->xcursor_manager == NULL) { if (desktop->xcursor_manager == NULL) {
wlr_log(L_ERROR, "Cannot create XCursor manager for theme %s", wlr_log(L_ERROR, "Cannot create XCursor manager for theme %s",
cursor_theme); cursor_theme);
wlr_list_free(desktop->views);
free(desktop); free(desktop);
return NULL; return NULL;
} }

@ -116,7 +116,7 @@ bool input_view_has_focus(struct roots_input *input, struct roots_view *view) {
} }
struct roots_seat *seat; struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) { wl_list_for_each(seat, &input->seats, link) {
if (seat->focus == view) { if (view == roots_seat_get_focus(seat)) {
return true; return true;
} }
} }

@ -87,20 +87,16 @@ static const char *exec_prefix = "exec ";
static void keyboard_binding_execute(struct roots_keyboard *keyboard, static void keyboard_binding_execute(struct roots_keyboard *keyboard,
const char *command) { const char *command) {
struct roots_server *server = keyboard->input->server; struct roots_seat *seat = keyboard->seat;
if (strcmp(command, "exit") == 0) { if (strcmp(command, "exit") == 0) {
wl_display_terminate(server->wl_display); wl_display_terminate(keyboard->input->server->wl_display);
} else if (strcmp(command, "close") == 0) { } else if (strcmp(command, "close") == 0) {
if (server->desktop->views->length > 0) { struct roots_view *focus = roots_seat_get_focus(seat);
struct roots_view *view = if (focus != NULL) {
server->desktop->views->items[server->desktop->views->length-1]; view_close(focus);
view_close(view);
} }
} else if (strcmp(command, "next_window") == 0) { } else if (strcmp(command, "next_window") == 0) {
if (server->desktop->views->length > 0) { roots_seat_cycle_focus(seat);
struct roots_view *view = server->desktop->views->items[0];
roots_seat_focus_view(keyboard->seat, view);
}
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) { } else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
const char *shell_cmd = command + strlen(exec_prefix); const char *shell_cmd = command + strlen(exec_prefix);
pid_t pid = fork(); pid_t pid = fork();

@ -59,8 +59,9 @@ int main(int argc, char **argv) {
ready(NULL, NULL); ready(NULL, NULL);
#else #else
if (server.desktop->xwayland != NULL) { if (server.desktop->xwayland != NULL) {
struct wl_listener xwayland_ready = { .notify = ready }; wl_signal_add(&server.desktop->xwayland->events.ready,
wl_signal_add(&server.desktop->xwayland->events.ready, &xwayland_ready); &server.desktop->xwayland_ready);
server.desktop->xwayland_ready.notify = ready;
} else { } else {
ready(NULL, NULL); ready(NULL, NULL);
} }

@ -38,7 +38,7 @@ static void rotate_child_position(double *sx, double *sy, double sw, double sh,
static void render_surface(struct wlr_surface *surface, static void render_surface(struct wlr_surface *surface,
struct roots_desktop *desktop, struct wlr_output *wlr_output, struct roots_desktop *desktop, struct wlr_output *wlr_output,
struct timespec *when, double lx, double ly, float rotation) { struct timespec *when, double lx, double ly, float rotation) {
if (surface->texture->valid) { if (wlr_surface_has_buffer(surface)) {
int width = surface->current->width; int width = surface->current->width;
int height = surface->current->height; int height = surface->current->height;
int render_width = width * wlr_output->scale; int render_width = width * wlr_output->scale;
@ -186,15 +186,15 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
wlr_output_make_current(wlr_output); wlr_output_make_current(wlr_output);
wlr_renderer_begin(server->renderer, wlr_output); wlr_renderer_begin(server->renderer, wlr_output);
for (size_t i = 0; i < desktop->views->length; ++i) { struct roots_view *view;
struct roots_view *view = desktop->views->items[i]; wl_list_for_each_reverse(view, &desktop->views, link) {
render_view(view, desktop, wlr_output, &now); render_view(view, desktop, wlr_output, &now);
} }
struct roots_drag_icon *drag_icon = NULL; struct wlr_drag_icon *drag_icon = NULL;
struct roots_seat *seat = NULL; struct roots_seat *seat = NULL;
wl_list_for_each(seat, &server->input->seats, link) { wl_list_for_each(seat, &server->input->seats, link) {
wl_list_for_each(drag_icon, &seat->drag_icons, link) { wl_list_for_each(drag_icon, &seat->seat->drag_icons, link) {
if (!drag_icon->mapped) { if (!drag_icon->mapped) {
continue; continue;
} }

@ -96,38 +96,6 @@ static void handle_request_set_cursor(struct wl_listener *listener,
roots_cursor_handle_request_set_cursor(cursor, event); roots_cursor_handle_request_set_cursor(cursor, event);
} }
static void handle_pointer_grab_begin(struct wl_listener *listener,
void *data) {
struct roots_cursor *cursor =
wl_container_of(listener, cursor, pointer_grab_begin);
struct wlr_seat_pointer_grab *grab = data;
roots_cursor_handle_pointer_grab_begin(cursor, grab);
}
static void handle_pointer_grab_end(struct wl_listener *listener,
void *data) {
struct roots_cursor *cursor =
wl_container_of(listener, cursor, pointer_grab_end);
struct wlr_seat_pointer_grab *grab = data;
roots_cursor_handle_pointer_grab_end(cursor, grab);
}
static void handle_touch_grab_begin(struct wl_listener *listener,
void *data) {
struct roots_cursor *cursor =
wl_container_of(listener, cursor, touch_grab_begin);
struct wlr_seat_touch_grab *grab = data;
roots_cursor_handle_touch_grab_begin(cursor, grab);
}
static void handle_touch_grab_end(struct wl_listener *listener,
void *data) {
struct roots_cursor *cursor =
wl_container_of(listener, cursor, touch_grab_end);
struct wlr_seat_touch_grab *grab = data;
roots_cursor_handle_touch_grab_end(cursor, grab);
}
static void seat_reset_device_mappings(struct roots_seat *seat, static void seat_reset_device_mappings(struct roots_seat *seat,
struct wlr_input_device *device) { struct wlr_input_device *device) {
struct wlr_cursor *cursor = seat->cursor->cursor; struct wlr_cursor *cursor = seat->cursor->cursor;
@ -249,22 +217,6 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
wl_signal_add(&seat->seat->events.request_set_cursor, wl_signal_add(&seat->seat->events.request_set_cursor,
&seat->cursor->request_set_cursor); &seat->cursor->request_set_cursor);
seat->cursor->request_set_cursor.notify = handle_request_set_cursor; seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
wl_signal_add(&seat->seat->events.pointer_grab_begin,
&seat->cursor->pointer_grab_begin);
seat->cursor->pointer_grab_begin.notify = handle_pointer_grab_begin;
wl_signal_add(&seat->seat->events.pointer_grab_end,
&seat->cursor->pointer_grab_end);
seat->cursor->pointer_grab_end.notify = handle_pointer_grab_end;
wl_signal_add(&seat->seat->events.touch_grab_begin,
&seat->cursor->touch_grab_begin);
seat->cursor->touch_grab_begin.notify = handle_touch_grab_begin;
wl_signal_add(&seat->seat->events.touch_grab_end,
&seat->cursor->touch_grab_end);
seat->cursor->touch_grab_end.notify = handle_touch_grab_end;
} }
struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
@ -277,7 +229,7 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
wl_list_init(&seat->pointers); wl_list_init(&seat->pointers);
wl_list_init(&seat->touch); wl_list_init(&seat->touch);
wl_list_init(&seat->tablet_tools); wl_list_init(&seat->tablet_tools);
wl_list_init(&seat->drag_icons); wl_list_init(&seat->views);
seat->input = input; seat->input = input;
@ -533,9 +485,69 @@ bool roots_seat_has_meta_pressed(struct roots_seat *seat) {
return false; return false;
} }
void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) { struct roots_view *roots_seat_get_focus(struct roots_seat *seat) {
struct roots_desktop *desktop = seat->input->server->desktop; if (!seat->has_focus || wl_list_empty(&seat->views)) {
if (seat->focus == view) { return NULL;
}
struct roots_seat_view *seat_view =
wl_container_of(seat->views.next, seat_view, link);
return seat_view->view;
}
static void seat_view_destroy(struct roots_seat_view *seat_view) {
struct roots_seat *seat = seat_view->seat;
if (seat_view->view == roots_seat_get_focus(seat)) {
seat->has_focus = false;
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
}
wl_list_remove(&seat_view->view_destroy.link);
wl_list_remove(&seat_view->link);
free(seat_view);
// Focus first view
if (!wl_list_empty(&seat->views)) {
struct roots_seat_view *first_seat_view = wl_container_of(
seat->views.next, first_seat_view, link);
roots_seat_set_focus(seat, first_seat_view->view);
}
}
static void seat_view_handle_destroy(struct wl_listener *listener, void *data) {
struct roots_seat_view *seat_view =
wl_container_of(listener, seat_view, view_destroy);
seat_view_destroy(seat_view);
}
static struct roots_seat_view *seat_add_view(struct roots_seat *seat,
struct roots_view *view) {
struct roots_seat_view *seat_view =
calloc(1, sizeof(struct roots_seat_view));
if (seat_view == NULL) {
return NULL;
}
seat_view->seat = seat;
seat_view->view = view;
wl_list_insert(&seat->views, &seat_view->link);
seat_view->view_destroy.notify = seat_view_handle_destroy;
wl_signal_add(&view->events.destroy, &seat_view->view_destroy);
return seat_view;
}
void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
// Make sure the view will be rendered on top of others, even if it's
// already focused in this seat
if (view != NULL) {
wl_list_remove(&view->link);
wl_list_insert(&seat->input->server->desktop->views, &view->link);
}
struct roots_view *prev_focus = roots_seat_get_focus(seat);
if (view == prev_focus) {
return; return;
} }
@ -544,33 +556,67 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
return; return;
} }
struct roots_view *prev_focus = seat->focus; struct roots_seat_view *seat_view = NULL;
seat->focus = view; if (view != NULL) {
bool found = false;
wl_list_for_each(seat_view, &seat->views, link) {
if (seat_view->view == view) {
found = true;
break;
}
}
if (!found) {
seat_view = seat_add_view(seat, view);
if (seat_view == NULL) {
wlr_log(L_ERROR, "Allocation failed");
return;
}
}
}
seat->has_focus = false;
// unfocus the old view if it is not focused by some other seat // Deactivate the old view if it is not focused by some other seat
if (prev_focus && !input_view_has_focus(seat->input, prev_focus)) { if (prev_focus != NULL && !input_view_has_focus(seat->input, prev_focus)) {
view_activate(prev_focus, false); view_activate(prev_focus, false);
} }
if (!seat->focus) { if (view == NULL) {
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH; seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
return; return;
} }
size_t index = 0; view_activate(view, true);
for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *_view = desktop->views->items[i]; seat->has_focus = true;
if (_view == view) { wl_list_remove(&seat_view->link);
index = i; wl_list_insert(&seat->views, &seat_view->link);
break; wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface);
}
void roots_seat_cycle_focus(struct roots_seat *seat) {
if (wl_list_empty(&seat->views)) {
return;
}
struct roots_seat_view *first_seat_view = wl_container_of(
seat->views.next, first_seat_view, link);
if (!seat->has_focus) {
roots_seat_set_focus(seat, first_seat_view->view);
return;
} }
if (wl_list_length(&seat->views) < 2) {
return;
} }
view_activate(view, true); // Focus the next view
// TODO: list_swap struct roots_seat_view *next_seat_view = wl_container_of(
wlr_list_del(desktop->views, index); first_seat_view->link.next, next_seat_view, link);
wlr_list_add(desktop->views, view); roots_seat_set_focus(seat, next_seat_view->view);
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface);
// Move the first view to the end of the list
wl_list_remove(&first_seat_view->link);
wl_list_insert(seat->views.prev, &first_seat_view->link);
} }
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) { void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {

@ -77,25 +77,17 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_wl_shell_surface *roots_surface = struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, destroy); wl_container_of(listener, roots_surface, destroy);
view_teardown(roots_surface->view);
wl_list_remove(&roots_surface->destroy.link); wl_list_remove(&roots_surface->destroy.link);
wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_move.link);
wl_list_remove(&roots_surface->request_resize.link); wl_list_remove(&roots_surface->request_resize.link);
wl_list_remove(&roots_surface->request_set_maximized.link); wl_list_remove(&roots_surface->request_set_maximized.link);
wl_list_remove(&roots_surface->set_state.link); wl_list_remove(&roots_surface->set_state.link);
wl_list_remove(&roots_surface->surface_commit.link); wl_list_remove(&roots_surface->surface_commit.link);
wl_list_remove(&roots_surface->view->link);
view_destroy(roots_surface->view); view_destroy(roots_surface->view);
free(roots_surface); free(roots_surface);
} }
static int shell_surface_compare_equals(const void *item, const void *cmp_to) {
const struct roots_view *view = item;
if (view->type == ROOTS_WL_SHELL_VIEW && view->wl_shell_surface == cmp_to) {
return 0;
}
return -1;
}
void handle_wl_shell_surface(struct wl_listener *listener, void *data) { void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = struct roots_desktop *desktop =
wl_container_of(listener, desktop, wl_shell_surface); wl_container_of(listener, desktop, wl_shell_surface);
@ -138,17 +130,24 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
view->wlr_surface = surface->surface; view->wlr_surface = surface->surface;
view->resize = resize; view->resize = resize;
view->close = close; view->close = close;
view->desktop = desktop;
roots_surface->view = view; roots_surface->view = view;
wlr_list_add(desktop->views, view); view_init(view, desktop);
wl_list_insert(&desktop->views, &view->link);
view_setup(view); view_setup(view);
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) { if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
// we need to map it relative to the parent // We need to map it relative to the parent
int i = wlr_list_seq_find(desktop->views, shell_surface_compare_equals, bool found = false;
surface->parent); struct roots_view *parent;
if (i != -1) { wl_list_for_each(parent, &desktop->views, link) {
struct roots_view *parent = desktop->views->items[i]; if (parent->type == ROOTS_WL_SHELL_VIEW &&
parent->wl_shell_surface == surface->parent) {
found = true;
break;
}
}
if (found) {
view_move(view, view_move(view,
parent->x + surface->transient_state->x, parent->x + surface->transient_state->x,
parent->y + surface->transient_state->y); parent->y + surface->transient_state->y);

@ -161,11 +161,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface = struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, destroy); wl_container_of(listener, roots_xdg_surface, destroy);
view_teardown(roots_xdg_surface->view);
wl_list_remove(&roots_xdg_surface->commit.link); wl_list_remove(&roots_xdg_surface->commit.link);
wl_list_remove(&roots_xdg_surface->destroy.link); wl_list_remove(&roots_xdg_surface->destroy.link);
wl_list_remove(&roots_xdg_surface->request_move.link); wl_list_remove(&roots_xdg_surface->request_move.link);
wl_list_remove(&roots_xdg_surface->request_resize.link); wl_list_remove(&roots_xdg_surface->request_resize.link);
wl_list_remove(&roots_xdg_surface->view->link);
view_destroy(roots_xdg_surface->view); view_destroy(roots_xdg_surface->view);
free(roots_xdg_surface); free(roots_xdg_surface);
} }
@ -219,9 +219,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->move_resize = move_resize; view->move_resize = move_resize;
view->maximize = maximize; view->maximize = maximize;
view->close = close; view->close = close;
view->desktop = desktop;
roots_surface->view = view; roots_surface->view = view;
wlr_list_add(desktop->views, view); view_init(view, desktop);
wl_list_insert(&desktop->views, &view->link);
view_setup(view); view_setup(view);
} }

@ -95,7 +95,8 @@ static void maximize(struct roots_view *view, bool maximized) {
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface = struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, destroy); wl_container_of(listener, roots_surface, destroy);
view_teardown(roots_surface->view); struct wlr_xwayland_surface *xwayland_surface =
roots_surface->view->xwayland_surface;
wl_list_remove(&roots_surface->destroy.link); wl_list_remove(&roots_surface->destroy.link);
wl_list_remove(&roots_surface->request_configure.link); wl_list_remove(&roots_surface->request_configure.link);
wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_move.link);
@ -103,6 +104,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&roots_surface->request_maximize.link); wl_list_remove(&roots_surface->request_maximize.link);
wl_list_remove(&roots_surface->map_notify.link); wl_list_remove(&roots_surface->map_notify.link);
wl_list_remove(&roots_surface->unmap_notify.link); wl_list_remove(&roots_surface->unmap_notify.link);
if (xwayland_surface->mapped) {
wl_list_remove(&roots_surface->view->link);
}
view_destroy(roots_surface->view); view_destroy(roots_surface->view);
free(roots_surface); free(roots_surface);
} }
@ -174,29 +178,23 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
static void handle_map_notify(struct wl_listener *listener, void *data) { static void handle_map_notify(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface = struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, map_notify); wl_container_of(listener, roots_surface, map_notify);
struct wlr_xwayland_surface *xsurface = data;
struct roots_view *view = roots_surface->view; struct roots_view *view = roots_surface->view;
struct wlr_xwayland_surface *xsurface = view->xwayland_surface;
struct roots_desktop *desktop = view->desktop; struct roots_desktop *desktop = view->desktop;
view->wlr_surface = xsurface->surface; view->wlr_surface = xsurface->surface;
view->x = (double)xsurface->x; view->x = (double)xsurface->x;
view->y = (double)xsurface->y; view->y = (double)xsurface->y;
wlr_list_push(desktop->views, roots_surface->view); wl_list_insert(&desktop->views, &view->link);
} }
static void handle_unmap_notify(struct wl_listener *listener, void *data) { static void handle_unmap_notify(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface = struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, unmap_notify); wl_container_of(listener, roots_surface, unmap_notify);
struct roots_desktop *desktop = roots_surface->view->desktop;
roots_surface->view->wlr_surface = NULL; roots_surface->view->wlr_surface = NULL;
for (size_t i = 0; i < desktop->views->length; i++) { wl_list_remove(&roots_surface->view->link);
if (desktop->views->items[i] == roots_surface->view) {
wlr_list_del(desktop->views, i);
break;
}
}
} }
void handle_xwayland_surface(struct wl_listener *listener, void *data) { void handle_xwayland_surface(struct wl_listener *listener, void *data) {
@ -242,7 +240,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->xwayland_surface = surface; view->xwayland_surface = surface;
view->roots_xwayland_surface = roots_surface; view->roots_xwayland_surface = roots_surface;
view->wlr_surface = surface->surface; view->wlr_surface = surface->surface;
view->desktop = desktop;
view->activate = activate; view->activate = activate;
view->resize = resize; view->resize = resize;
view->move = move; view->move = move;
@ -250,7 +247,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->maximize = maximize; view->maximize = maximize;
view->close = close; view->close = close;
roots_surface->view = view; roots_surface->view = view;
wlr_list_add(desktop->views, view); view_init(view, desktop);
wl_list_insert(&desktop->views, &view->link);
if (!surface->override_redirect) { if (!surface->override_redirect) {
view_setup(view); view_setup(view);

@ -352,15 +352,13 @@ static void data_device_release(struct wl_client *client,
wl_resource_destroy(resource); wl_resource_destroy(resource);
} }
static void drag_client_seat_unbound(struct wl_listener *listener, void *data) { static void handle_drag_seat_client_destroy(struct wl_listener *listener,
void *data) {
struct wlr_drag *drag = struct wlr_drag *drag =
wl_container_of(listener, drag, seat_client_unbound); wl_container_of(listener, drag, seat_client_destroy);
struct wlr_seat_client *unbound_client = data;
if (drag->focus_client == unbound_client) {
drag->focus_client = NULL; drag->focus_client = NULL;
wl_list_remove(&drag->seat_client_unbound.link); wl_list_remove(&drag->seat_client_destroy.link);
}
} }
static void wlr_drag_set_focus(struct wlr_drag *drag, static void wlr_drag_set_focus(struct wlr_drag *drag,
@ -370,7 +368,7 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
} }
if (drag->focus_client && drag->focus_client->data_device) { if (drag->focus_client && drag->focus_client->data_device) {
wl_list_remove(&drag->seat_client_unbound.link); wl_list_remove(&drag->seat_client_destroy.link);
wl_data_device_send_leave(drag->focus_client->data_device); wl_data_device_send_leave(drag->focus_client->data_device);
drag->focus_client = NULL; drag->focus_client = NULL;
drag->focus = NULL; drag->focus = NULL;
@ -430,9 +428,9 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
drag->focus = surface; drag->focus = surface;
drag->focus_client = focus_client; drag->focus_client = focus_client;
drag->seat_client_unbound.notify = drag_client_seat_unbound; drag->seat_client_destroy.notify = handle_drag_seat_client_destroy;
wl_signal_add(&focus_client->seat->events.client_unbound, wl_signal_add(&focus_client->events.destroy,
&drag->seat_client_unbound); &drag->seat_client_destroy);
} }
static void wlr_drag_end(struct wlr_drag *drag) { static void wlr_drag_end(struct wlr_drag *drag) {
@ -452,6 +450,7 @@ static void wlr_drag_end(struct wlr_drag *drag) {
wlr_drag_set_focus(drag, NULL, 0, 0); wlr_drag_set_focus(drag, NULL, 0, 0);
if (drag->icon) { if (drag->icon) {
drag->icon->mapped = false;
wl_list_remove(&drag->icon_destroy.link); wl_list_remove(&drag->icon_destroy.link);
} }
@ -614,8 +613,72 @@ static void drag_handle_drag_source_destroy(struct wl_listener *listener,
wlr_drag_end(drag); wlr_drag_end(drag);
} }
static void wlr_drag_icon_destroy(struct wlr_drag_icon *icon) {
if (!icon) {
return;
}
wl_signal_emit(&icon->events.destroy, icon);
wl_list_remove(&icon->surface_commit.link);
wl_list_remove(&icon->surface_destroy.link);
wl_list_remove(&icon->seat_client_destroy.link);
wl_list_remove(&icon->link);
free(icon);
}
static void handle_drag_icon_surface_destroy(struct wl_listener *listener,
void *data) {
struct wlr_drag_icon *icon =
wl_container_of(listener, icon, surface_destroy);
wlr_drag_icon_destroy(icon);
}
static void handle_drag_icon_surface_commit(struct wl_listener *listener,
void *data) {
struct wlr_drag_icon *icon =
wl_container_of(listener, icon, surface_commit);
icon->sx += icon->surface->current->sx;
icon->sy += icon->surface->current->sy;
}
static void handle_drag_icon_seat_client_destroy(struct wl_listener *listener,
void *data) {
struct wlr_drag_icon *icon =
wl_container_of(listener, icon, seat_client_destroy);
wlr_drag_icon_destroy(icon);
}
static struct wlr_drag_icon *wlr_drag_icon_create(
struct wlr_surface *icon_surface, struct wlr_seat_client *client,
bool is_pointer, int32_t touch_id) {
struct wlr_drag_icon *icon = calloc(1, sizeof(struct wlr_drag_icon));
if (!icon) {
return NULL;
}
icon->surface = icon_surface;
icon->client = client;
icon->is_pointer = is_pointer;
icon->touch_id = touch_id;
icon->mapped = true;
wl_list_insert(&client->seat->drag_icons, &icon->link);
wl_signal_init(&icon->events.destroy);
wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
icon->surface_destroy.notify = handle_drag_icon_surface_destroy;
wl_signal_add(&icon->surface->events.commit, &icon->surface_commit);
icon->surface_commit.notify = handle_drag_icon_surface_commit;
wl_signal_add(&client->events.destroy, &icon->seat_client_destroy);
icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy;
return icon;
}
static bool seat_client_start_drag(struct wlr_seat_client *client, static bool seat_client_start_drag(struct wlr_seat_client *client,
struct wlr_data_source *source, struct wlr_surface *icon, struct wlr_data_source *source, struct wlr_surface *icon_surface,
struct wlr_surface *origin, uint32_t serial) { struct wlr_surface *origin, uint32_t serial) {
struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag)); struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag));
if (drag == NULL) { if (drag == NULL) {
@ -649,11 +712,20 @@ static bool seat_client_start_drag(struct wlr_seat_client *client,
return true; return true;
} }
if (icon) { if (icon_surface) {
int32_t touch_id = (point ? point->touch_id : 0);
struct wlr_drag_icon *icon =
wlr_drag_icon_create(icon_surface, client, drag->is_pointer_grab,
touch_id);
if (!icon) {
free(drag);
return false;
}
drag->icon = icon; drag->icon = icon;
drag->icon_destroy.notify = drag_handle_icon_destroy; drag->icon_destroy.notify = drag_handle_icon_destroy;
wl_signal_add(&icon->events.destroy, &drag->icon_destroy); wl_signal_add(&icon->events.destroy, &drag->icon_destroy);
drag->icon = icon;
} }
if (source) { if (source) {
@ -712,8 +784,6 @@ static void data_device_start_drag(struct wl_client *client,
} }
} }
// TODO touch grab
if (!seat_client_start_drag(seat_client, source, icon, origin, serial)) { if (!seat_client_start_drag(seat_client, source, icon, origin, serial)) {
wl_resource_post_no_memory(device_resource); wl_resource_post_no_memory(device_resource);
return; return;

@ -181,7 +181,7 @@ static void wl_seat_get_touch(struct wl_client *client,
static void wlr_seat_client_resource_destroy(struct wl_resource *resource) { static void wlr_seat_client_resource_destroy(struct wl_resource *resource) {
struct wlr_seat_client *client = wl_resource_get_user_data(resource); struct wlr_seat_client *client = wl_resource_get_user_data(resource);
wl_signal_emit(&client->seat->events.client_unbound, client); wl_signal_emit(&client->events.destroy, client);
if (client == client->seat->pointer_state.focused_client) { if (client == client->seat->pointer_state.focused_client) {
client->seat->pointer_state.focused_client = NULL; client->seat->pointer_state.focused_client = NULL;
@ -240,7 +240,7 @@ static void wl_seat_bind(struct wl_client *client, void *_wlr_seat,
wl_seat_send_name(seat_client->wl_resource, wlr_seat->name); wl_seat_send_name(seat_client->wl_resource, wlr_seat->name);
} }
wl_seat_send_capabilities(seat_client->wl_resource, wlr_seat->capabilities); wl_seat_send_capabilities(seat_client->wl_resource, wlr_seat->capabilities);
wl_signal_emit(&wlr_seat->events.client_bound, seat_client); wl_signal_init(&seat_client->events.destroy);
} }
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab, static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
@ -404,9 +404,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
wlr_seat->display = display; wlr_seat->display = display;
wlr_seat->name = strdup(name); wlr_seat->name = strdup(name);
wl_list_init(&wlr_seat->clients); wl_list_init(&wlr_seat->clients);
wl_list_init(&wlr_seat->drag_icons);
wl_signal_init(&wlr_seat->events.client_bound);
wl_signal_init(&wlr_seat->events.client_unbound);
wl_signal_init(&wlr_seat->events.request_set_cursor); wl_signal_init(&wlr_seat->events.request_set_cursor);
wl_signal_init(&wlr_seat->events.selection); wl_signal_init(&wlr_seat->events.selection);

@ -42,6 +42,7 @@ const char *atom_map[ATOM_LAST] = {
"_NET_WM_STATE_FULLSCREEN", "_NET_WM_STATE_FULLSCREEN",
"_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_MAXIMIZED_HORZ", "_NET_WM_STATE_MAXIMIZED_HORZ",
"WM_STATE",
}; };
/* General helpers */ /* General helpers */
@ -640,8 +641,8 @@ static void xsurface_set_wm_state(struct wlr_xwayland_surface *xsurface,
xcb_change_property(xwm->xcb_conn, xcb_change_property(xwm->xcb_conn,
XCB_PROP_MODE_REPLACE, XCB_PROP_MODE_REPLACE,
xsurface->window_id, xsurface->window_id,
xwm->atoms[NET_WM_STATE], xwm->atoms[WM_STATE],
xwm->atoms[NET_WM_STATE], xwm->atoms[WM_STATE],
32, // format 32, // format
2, property); 2, property);
} }

@ -30,6 +30,7 @@ enum atom_name {
_NET_WM_STATE_FULLSCREEN, _NET_WM_STATE_FULLSCREEN,
_NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_HORZ,
WM_STATE,
ATOM_LAST, ATOM_LAST,
}; };

Loading…
Cancel
Save