mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-26 06:59:52 -05:00
Merge branch 'master' into modifier-fixes
This commit is contained in:
commit
43896af90f
41 changed files with 765 additions and 103 deletions
|
|
@ -263,10 +263,19 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|||
oc->name = strdup(output_name);
|
||||
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
oc->scale = 1;
|
||||
oc->enable = true;
|
||||
wl_list_insert(&config->outputs, &oc->link);
|
||||
}
|
||||
|
||||
if (strcmp(name, "x") == 0) {
|
||||
if (strcmp(name, "enable") == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
oc->enable = true;
|
||||
} else if (strcasecmp(value, "false") == 0) {
|
||||
oc->enable = false;
|
||||
} else {
|
||||
wlr_log(L_ERROR, "got invalid output enable value: %s", value);
|
||||
}
|
||||
} else if (strcmp(name, "x") == 0) {
|
||||
oc->x = strtol(value, NULL, 10);
|
||||
} else if (strcmp(name, "y") == 0) {
|
||||
oc->y = strtol(value, NULL, 10);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_gamma_control.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_server_decoration.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
|
|
@ -502,6 +503,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
|
|||
WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT);
|
||||
desktop->primary_selection_device_manager =
|
||||
wlr_primary_selection_device_manager_create(server->wl_display);
|
||||
desktop->idle = wlr_idle_create(server->wl_display);
|
||||
|
||||
return desktop;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
|
|
@ -85,6 +86,8 @@ static void pressed_keysyms_update(xkb_keysym_t *pressed_keysyms,
|
|||
|
||||
static const char *exec_prefix = "exec ";
|
||||
|
||||
static bool outputs_enabled = true;
|
||||
|
||||
static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
||||
const char *command) {
|
||||
struct roots_seat *seat = keyboard->seat;
|
||||
|
|
@ -119,6 +122,12 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
|||
}
|
||||
} else if (strcmp(command, "nop") == 0) {
|
||||
wlr_log(L_DEBUG, "nop command");
|
||||
} else if (strcmp(command, "toggle_outputs") == 0) {
|
||||
outputs_enabled = !outputs_enabled;
|
||||
struct roots_output *output;
|
||||
wl_list_for_each(output, &keyboard->input->server->desktop->outputs, link) {
|
||||
wlr_output_enable(output->wlr_output, outputs_enabled);
|
||||
}
|
||||
} else {
|
||||
wlr_log(L_ERROR, "unknown binding command: %s", command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ int main(int argc, char **argv) {
|
|||
|
||||
if (server.backend == NULL) {
|
||||
wlr_log(L_ERROR, "could not start backend");
|
||||
wlr_backend_destroy(server.backend);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,6 +169,19 @@ static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface,
|
|||
}
|
||||
}
|
||||
|
||||
static void render_xwayland_children(struct wlr_xwayland_surface *surface,
|
||||
struct roots_desktop *desktop, struct wlr_output *wlr_output,
|
||||
struct timespec *when) {
|
||||
struct wlr_xwayland_surface *child;
|
||||
wl_list_for_each(child, &surface->children, parent_link) {
|
||||
if (child->surface != NULL && child->added) {
|
||||
render_surface(child->surface, desktop, wlr_output, when,
|
||||
child->x, child->y, 0);
|
||||
}
|
||||
render_xwayland_children(child, desktop, wlr_output, when);
|
||||
}
|
||||
}
|
||||
|
||||
static void render_view(struct roots_view *view, struct roots_desktop *desktop,
|
||||
struct wlr_output *wlr_output, struct timespec *when) {
|
||||
switch (view->type) {
|
||||
|
|
@ -200,7 +213,7 @@ static bool has_standalone_surface(struct roots_view *view) {
|
|||
case ROOTS_WL_SHELL_VIEW:
|
||||
return wl_list_empty(&view->wl_shell_surface->popups);
|
||||
case ROOTS_XWAYLAND_VIEW:
|
||||
return true;
|
||||
return wl_list_empty(&view->xwayland_surface->children);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -211,6 +224,10 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
struct roots_desktop *desktop = output->desktop;
|
||||
struct roots_server *server = desktop->server;
|
||||
|
||||
if (!wlr_output->enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
|
|
@ -218,27 +235,36 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_renderer_begin(server->renderer, wlr_output);
|
||||
|
||||
if (output->fullscreen_view != NULL) {
|
||||
struct roots_view *view = output->fullscreen_view;
|
||||
|
||||
// Make sure the view is centered on screen
|
||||
const struct wlr_box *output_box =
|
||||
wlr_output_layout_get_box(desktop->layout, wlr_output);
|
||||
struct wlr_box view_box;
|
||||
view_get_box(output->fullscreen_view, &view_box);
|
||||
view_get_box(view, &view_box);
|
||||
double view_x = (double)(output_box->width - view_box.width) / 2 +
|
||||
output_box->x;
|
||||
double view_y = (double)(output_box->height - view_box.height) / 2 +
|
||||
output_box->y;
|
||||
view_move(output->fullscreen_view, view_x, view_y);
|
||||
view_move(view, view_x, view_y);
|
||||
|
||||
if (has_standalone_surface(output->fullscreen_view)) {
|
||||
wlr_output_set_fullscreen_surface(wlr_output,
|
||||
output->fullscreen_view->wlr_surface);
|
||||
if (has_standalone_surface(view)) {
|
||||
wlr_output_set_fullscreen_surface(wlr_output, view->wlr_surface);
|
||||
} else {
|
||||
wlr_output_set_fullscreen_surface(wlr_output, NULL);
|
||||
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
render_view(output->fullscreen_view, desktop, wlr_output, &now);
|
||||
render_view(view, desktop, wlr_output, &now);
|
||||
|
||||
// During normal rendering the xwayland window tree isn't traversed
|
||||
// because all windows are rendered. Here we only want to render
|
||||
// the fullscreen window's children so we have to traverse the tree.
|
||||
if (view->type == ROOTS_XWAYLAND_VIEW) {
|
||||
render_xwayland_children(view->xwayland_surface, desktop,
|
||||
wlr_output, &now);
|
||||
}
|
||||
}
|
||||
wlr_renderer_end(server->renderer);
|
||||
wlr_output_swap_buffers(wlr_output);
|
||||
|
|
@ -324,9 +350,10 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_log(L_DEBUG, "'%s %s %s' %"PRId32"mm x %"PRId32"mm", wlr_output->make,
|
||||
wlr_output->model, wlr_output->serial, wlr_output->phys_width,
|
||||
wlr_output->phys_height);
|
||||
|
||||
if (wl_list_length(&wlr_output->modes) > 0) {
|
||||
struct wlr_output_mode *mode = NULL;
|
||||
mode = wl_container_of((&wlr_output->modes)->prev, mode, link);
|
||||
struct wlr_output_mode *mode =
|
||||
wl_container_of((&wlr_output->modes)->prev, mode, link);
|
||||
wlr_output_set_mode(wlr_output, mode);
|
||||
}
|
||||
|
||||
|
|
@ -341,13 +368,17 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
struct roots_output_config *output_config =
|
||||
roots_config_get_output(config, wlr_output);
|
||||
if (output_config) {
|
||||
if (output_config->mode.width) {
|
||||
set_mode(wlr_output, output_config);
|
||||
if (output_config->enable) {
|
||||
if (output_config->mode.width) {
|
||||
set_mode(wlr_output, output_config);
|
||||
}
|
||||
wlr_output_set_scale(wlr_output, output_config->scale);
|
||||
wlr_output_set_transform(wlr_output, output_config->transform);
|
||||
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,
|
||||
output_config->y);
|
||||
} else {
|
||||
wlr_output_enable(wlr_output, false);
|
||||
}
|
||||
wlr_output_set_scale(wlr_output, output_config->scale);
|
||||
wlr_output_set_transform(wlr_output, output_config->transform);
|
||||
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,
|
||||
output_config->y);
|
||||
} else {
|
||||
wlr_output_layout_add_auto(desktop->layout, wlr_output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/config.h>
|
||||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include "rootston/xcursor.h"
|
||||
#include "rootston/input.h"
|
||||
#include "rootston/seat.h"
|
||||
|
|
@ -14,6 +15,8 @@
|
|||
static void handle_keyboard_key(struct wl_listener *listener, void *data) {
|
||||
struct roots_keyboard *keyboard =
|
||||
wl_container_of(listener, keyboard, keyboard_key);
|
||||
struct roots_desktop *desktop = keyboard->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, keyboard->seat->seat);
|
||||
struct wlr_event_keyboard_key *event = data;
|
||||
roots_keyboard_handle_key(keyboard, event);
|
||||
}
|
||||
|
|
@ -22,12 +25,16 @@ static void handle_keyboard_modifiers(struct wl_listener *listener,
|
|||
void *data) {
|
||||
struct roots_keyboard *keyboard =
|
||||
wl_container_of(listener, keyboard, keyboard_modifiers);
|
||||
struct roots_desktop *desktop = keyboard->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, keyboard->seat->seat);
|
||||
roots_keyboard_handle_modifiers(keyboard);
|
||||
}
|
||||
|
||||
static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, motion);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_pointer_motion *event = data;
|
||||
roots_cursor_handle_motion(cursor, event);
|
||||
}
|
||||
|
|
@ -36,6 +43,8 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener,
|
|||
void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, motion_absolute);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_pointer_motion_absolute *event = data;
|
||||
roots_cursor_handle_motion_absolute(cursor, event);
|
||||
}
|
||||
|
|
@ -43,6 +52,8 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener,
|
|||
static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, button);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_pointer_button *event = data;
|
||||
roots_cursor_handle_button(cursor, event);
|
||||
}
|
||||
|
|
@ -50,6 +61,8 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
|||
static void handle_cursor_axis(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, axis);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_pointer_axis *event = data;
|
||||
roots_cursor_handle_axis(cursor, event);
|
||||
}
|
||||
|
|
@ -57,6 +70,8 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
|
|||
static void handle_touch_down(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, touch_down);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_touch_down *event = data;
|
||||
roots_cursor_handle_touch_down(cursor, event);
|
||||
}
|
||||
|
|
@ -64,6 +79,8 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
|
|||
static void handle_touch_up(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, touch_up);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_touch_up *event = data;
|
||||
roots_cursor_handle_touch_up(cursor, event);
|
||||
}
|
||||
|
|
@ -71,6 +88,8 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
|
|||
static void handle_touch_motion(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, touch_motion);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_touch_motion *event = data;
|
||||
roots_cursor_handle_touch_motion(cursor, event);
|
||||
}
|
||||
|
|
@ -78,6 +97,8 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
|
|||
static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, tool_axis);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_tablet_tool_axis *event = data;
|
||||
roots_cursor_handle_tool_axis(cursor, event);
|
||||
}
|
||||
|
|
@ -85,6 +106,8 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
|||
static void handle_tool_tip(struct wl_listener *listener, void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, tool_tip);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_event_tablet_tool_tip *event = data;
|
||||
roots_cursor_handle_tool_tip(cursor, event);
|
||||
}
|
||||
|
|
@ -93,6 +116,8 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
|||
void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, request_set_cursor);
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
|
||||
struct wlr_seat_pointer_request_set_cursor_event *event = data;
|
||||
roots_cursor_handle_request_set_cursor(cursor, event);
|
||||
}
|
||||
|
|
@ -268,11 +293,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wlr_seat_set_capabilities(seat->seat,
|
||||
WL_SEAT_CAPABILITY_KEYBOARD |
|
||||
WL_SEAT_CAPABILITY_POINTER |
|
||||
WL_SEAT_CAPABILITY_TOUCH);
|
||||
|
||||
wl_list_insert(&input->seats, &seat->link);
|
||||
|
||||
seat->seat_destroy.notify = roots_seat_handle_seat_destroy;
|
||||
|
|
@ -281,6 +301,28 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
|||
return seat;
|
||||
}
|
||||
|
||||
static void seat_update_capabilities(struct roots_seat *seat) {
|
||||
uint32_t caps = 0;
|
||||
if (!wl_list_empty(&seat->keyboards)) {
|
||||
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
}
|
||||
if (!wl_list_empty(&seat->pointers) || !wl_list_empty(&seat->tablet_tools)) {
|
||||
caps |= WL_SEAT_CAPABILITY_POINTER;
|
||||
}
|
||||
if (!wl_list_empty(&seat->touch)) {
|
||||
caps |= WL_SEAT_CAPABILITY_TOUCH;
|
||||
}
|
||||
wlr_seat_set_capabilities(seat->seat, caps);
|
||||
|
||||
// Hide cursor if seat doesn't have pointer capability
|
||||
if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) {
|
||||
wlr_cursor_set_image(seat->cursor->cursor, NULL, 0, 0, 0, 0, 0, 0);
|
||||
} else {
|
||||
wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager,
|
||||
seat->cursor->default_xcursor, seat->cursor->cursor);
|
||||
}
|
||||
}
|
||||
|
||||
static void seat_add_keyboard(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
|
||||
|
|
@ -379,6 +421,8 @@ void roots_seat_add_device(struct roots_seat *seat,
|
|||
seat_add_tablet_tool(seat, device);
|
||||
break;
|
||||
}
|
||||
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
static void seat_remove_keyboard(struct roots_seat *seat,
|
||||
|
|
@ -455,6 +499,8 @@ void roots_seat_remove_device(struct roots_seat *seat,
|
|||
seat_remove_tablet_tool(seat, device);
|
||||
break;
|
||||
}
|
||||
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
void roots_seat_configure_xcursor(struct roots_seat *seat) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue