fullscreen and focused output
This commit is contained in:
@@ -45,7 +45,7 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f
|
||||
if (!toplevel || toplevel->fullscreen == fullscreen)
|
||||
return;
|
||||
|
||||
struct absinthe_output *output = toplevel->output;
|
||||
struct absinthe_output *output = toplevel->server->focused_output;
|
||||
toplevel->fullscreen = fullscreen;
|
||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, fullscreen);
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ int main(int argc, char **argv)
|
||||
wl_signal_add(&server.backend->events.new_output, &server.new_output);
|
||||
|
||||
server.output_layout = wlr_output_layout_create(server.display);
|
||||
server.output_layout_change.notify = outputs_update;
|
||||
wl_signal_add(&server.output_layout->events.change, &server.output_layout_change);
|
||||
|
||||
server.output_mgr = wlr_output_manager_v1_create(server.display);
|
||||
|
||||
|
||||
+17
-17
@@ -36,27 +36,27 @@ void output_destroy(struct wl_listener *listener, void *data)
|
||||
free(output);
|
||||
}
|
||||
|
||||
void output_layout_change(struct wl_listener *listener, void *data)
|
||||
void outputs_update(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct absinthe_server *server = wl_container_of(listener, server, output_layout_change);
|
||||
struct wlr_output_configuration_v1 *config = wlr_output_configuration_v1_create();
|
||||
|
||||
struct wlr_output_configuration_head_v1 *config_head;
|
||||
struct absinthe_output *output;
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
if (output->wlr_output->enabled) continue;
|
||||
|
||||
config_head = wlr_output_configuration_head_v1_create(config, output->wlr_output);
|
||||
config_head->state.enabled = false;
|
||||
wlr_output_layout_remove(server->output_layout, output->wlr_output);
|
||||
}
|
||||
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
if (!output->wlr_output->enabled || !wlr_output_layout_get(server->output_layout, output->wlr_output)) continue;
|
||||
|
||||
wlr_output_layout_add_auto(server->output_layout, output->wlr_output);
|
||||
wlr_output_layout_get_box(server->output_layout, output->wlr_output, &output->geometry);
|
||||
}
|
||||
|
||||
wlr_output_manager_v1_set_configuration(server->output_mgr, config);
|
||||
}
|
||||
|
||||
void update_focused_output(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_output *output;
|
||||
int32_t cursor_x = server->cursor->x;
|
||||
int32_t cursor_y = server->cursor->y;
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
bool cursor_in_output_x = cursor_x >= output->geometry.x && cursor_x <= output->geometry.x + output->geometry.width;
|
||||
bool cursor_in_output_y = cursor_y >= output->geometry.y && cursor_y <= output->geometry.y + output->geometry.height;
|
||||
if (cursor_in_output_x && cursor_in_output_y) {
|
||||
server->focused_output = output;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -44,12 +44,12 @@ void server_new_output(struct wl_listener *listener, void *data)
|
||||
output->destroy.notify = output_destroy;
|
||||
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
|
||||
|
||||
wl_list_insert(&server->outputs, &output->link);
|
||||
|
||||
struct wlr_output_layout_output *l_layout = wlr_output_layout_add_auto(server->output_layout, output->wlr_output);
|
||||
struct wlr_scene_output *scene_output = wlr_scene_output_create(server->scene, wlr_output);
|
||||
wlr_scene_output_layout_add_output(server->scene_layout, l_layout, scene_output);
|
||||
wlr_output_layout_get_box(server->output_layout, output->wlr_output, &output->geometry);
|
||||
|
||||
server->focused_output = output;
|
||||
}
|
||||
|
||||
void server_new_xdg_toplevel(struct wl_listener *listener, void *data)
|
||||
@@ -123,6 +123,7 @@ void server_cursor_motion(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct absinthe_server *server = wl_container_of(listener, server, cursor_motion);
|
||||
struct wlr_pointer_motion_event *event = data;
|
||||
update_focused_output(server);
|
||||
wlr_cursor_move(server->cursor, &event->pointer->base, event->delta_x, event->delta_y);
|
||||
process_cursor_motion(server, event->time_msec);
|
||||
}
|
||||
@@ -131,6 +132,7 @@ void server_cursor_motion_absolute(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct absinthe_server *server = wl_container_of(listener, server, cursor_motion_absolute);
|
||||
struct wlr_pointer_motion_absolute_event *event = data;
|
||||
update_focused_output(server);
|
||||
wlr_cursor_warp_absolute(server->cursor, &event->pointer->base, event->x, event->y);
|
||||
process_cursor_motion(server, event->time_msec);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user