aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/backend.c4
-rw-r--r--backend/drm/drm.c4
-rw-r--r--backend/drm/renderer.c2
-rw-r--r--backend/headless/output.c2
-rw-r--r--backend/libinput/backend.c4
-rw-r--r--backend/wayland/wl_seat.c10
-rw-r--r--backend/x11/backend.c12
-rw-r--r--examples/idle-inhibit.c232
-rw-r--r--examples/meson.build7
-rw-r--r--examples/output-layout.c2
-rw-r--r--examples/rotation.c2
-rw-r--r--examples/screenshot.c2
-rw-r--r--examples/touch.c2
-rw-r--r--include/backend/drm/drm.h1
-rw-r--r--include/rootston/desktop.h6
-rw-r--r--include/rootston/output.h3
-rw-r--r--include/rootston/view.h3
-rw-r--r--include/wlr/render.h7
-rw-r--r--include/wlr/render/interface.h2
-rw-r--r--include/wlr/types/wlr_compositor.h1
-rw-r--r--include/wlr/types/wlr_idle_inhibit_v1.h45
-rw-r--r--include/wlr/xwayland.h1
-rw-r--r--include/wlr/xwm.h12
-rw-r--r--protocol/meson.build3
-rw-r--r--render/egl.c30
-rw-r--r--render/gles2/renderer.c6
-rw-r--r--render/gles2/texture.c3
-rw-r--r--render/wlr_renderer.c4
-rw-r--r--rootston/desktop.c27
-rw-r--r--rootston/keyboard.c5
-rw-r--r--rootston/output.c140
-rw-r--r--rootston/rootston.ini.example2
-rw-r--r--rootston/seat.c4
-rw-r--r--rootston/wl_shell.c2
-rw-r--r--rootston/xdg_shell.c2
-rw-r--r--rootston/xdg_shell_v6.c2
-rw-r--r--rootston/xwayland.c4
-rw-r--r--types/meson.build1
-rw-r--r--types/wlr_compositor.c2
-rw-r--r--types/wlr_idle_inhibit_v1.c185
-rw-r--r--types/wlr_output.c4
-rw-r--r--wlroots.syms1
-rw-r--r--xwayland/xwayland.c21
-rw-r--r--xwayland/xwm.c46
44 files changed, 776 insertions, 84 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 47dff227..75b44210 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -81,8 +81,10 @@ static void session_signal(struct wl_listener *listener, void *data) {
struct wlr_drm_connector *conn;
wl_list_for_each(conn, &drm->outputs, link){
- if (conn->output.current_mode) {
+ if (conn->output.enabled) {
wlr_output_set_mode(&conn->output, conn->output.current_mode);
+ } else {
+ wlr_drm_connector_enable(&conn->output, false);
}
if (!conn->crtc) {
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index e60b7e1c..3b714300 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -282,7 +282,7 @@ void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn) {
}
}
-static void wlr_drm_connector_enable(struct wlr_output *output, bool enable) {
+void wlr_drm_connector_enable(struct wlr_output *output, bool enable) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
if (conn->state != WLR_DRM_CONN_CONNECTED) {
return;
@@ -647,7 +647,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
float matrix[16];
wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0);
wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex,
- &matrix);
+ &matrix, 1.0f);
glFinish();
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride);
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index f3e570f7..7ee13843 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -239,7 +239,7 @@ struct gbm_bo *wlr_drm_surface_mgpu_copy(struct wlr_drm_surface *dest,
glViewport(0, 0, dest->width, dest->height);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
- wlr_render_with_matrix(dest->renderer->wlr_rend, tex, &matrix);
+ wlr_render_with_matrix(dest->renderer->wlr_rend, tex, &matrix, 1.0f);
return wlr_drm_surface_swap_buffers(dest, NULL);
}
diff --git a/backend/headless/output.c b/backend/headless/output.c
index ba4a094e..6ce8fc35 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -67,6 +67,8 @@ static void output_destroy(struct wlr_output *wlr_output) {
wl_list_remove(&output->link);
+ wl_event_source_remove(output->frame_timer);
+
eglDestroySurface(output->backend->egl.display, output->egl_surface);
free(output);
}
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c
index 71fe0d93..1e7c1ad4 100644
--- a/backend/libinput/backend.c
+++ b/backend/libinput/backend.c
@@ -118,7 +118,9 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *wlr_backend) {
wl_list_remove(&backend->session_signal.link);
wlr_list_finish(&backend->wlr_device_lists);
- wl_event_source_remove(backend->input_event);
+ if (backend->input_event) {
+ wl_event_source_remove(backend->input_event);
+ }
libinput_unref(backend->libinput_context);
free(backend);
}
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index b1f7cff6..841e693d 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -163,10 +163,12 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
struct wlr_input_device *dev = data;
assert(dev && dev->keyboard);
- struct wlr_event_keyboard_key wlr_event;
- wlr_event.keycode = key;
- wlr_event.state = state;
- wlr_event.time_msec = time;
+ struct wlr_event_keyboard_key wlr_event = {
+ .keycode = key,
+ .state = state,
+ .time_msec = time,
+ .update_state = false,
+ };
wlr_keyboard_notify_key(dev->keyboard, &wlr_event);
}
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 65eb0094..8633ece3 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -188,6 +188,17 @@ static void init_atom(struct wlr_x11_backend *x11, struct wlr_x11_atom *atom,
atom->reply = xcb_intern_atom_reply(x11->xcb_conn, atom->cookie, NULL);
}
+static void parse_xcb_setup(struct wlr_output *output, xcb_connection_t *xcb_conn) {
+ const xcb_setup_t *xcb_setup = xcb_get_setup(xcb_conn);
+
+ snprintf(output->make, sizeof(output->make), "%.*s",
+ xcb_setup_vendor_length(xcb_setup),
+ xcb_setup_vendor(xcb_setup));
+ snprintf(output->model, sizeof(output->model), "%"PRIu16".%"PRIu16,
+ xcb_setup->protocol_major_version,
+ xcb_setup->protocol_minor_version);
+}
+
static bool wlr_x11_backend_start(struct wlr_backend *backend) {
struct wlr_x11_backend *x11 = (struct wlr_x11_backend *)backend;
struct wlr_x11_output *output = &x11->output;
@@ -207,6 +218,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
wlr_output_init(&output->wlr_output, &x11->backend, &output_impl,
x11->wl_display);
snprintf(output->wlr_output.name, sizeof(output->wlr_output.name), "X11-1");
+ parse_xcb_setup(&output->wlr_output, x11->xcb_conn);
output->win = xcb_generate_id(x11->xcb_conn);
xcb_create_window(x11->xcb_conn, XCB_COPY_FROM_PARENT, output->win,
diff --git a/examples/idle-inhibit.c b/examples/idle-inhibit.c
new file mode 100644
index 00000000..b7b9c21c
--- /dev/null
+++ b/examples/idle-inhibit.c
@@ -0,0 +1,232 @@
+#include <GLES2/gl2.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wayland-client.h>
+#include <wayland-egl.h>
+#include <wlr/render/egl.h>
+#include "xdg-shell-client-protocol.h"
+#include "idle-inhibit-unstable-v1-client-protocol.h"
+
+#include <linux/input-event-codes.h>
+
+/**
+ * Usage: idle-inhibit
+ * Creates a xdg-toplevel using the idle-inhibit protocol.
+ * It will be solid green, when it has an idle inhibitor, and solid yellow if
+ * it does not.
+ * Left click with a pointer will toggle this state. (Touch is not supported
+ * for now).
+ */
+
+static int width = 500, height = 300;
+
+static struct wl_compositor *compositor = NULL;
+static struct wl_seat *seat = NULL;
+static struct xdg_wm_base *wm_base = NULL;
+static struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = NULL;
+static struct zwp_idle_inhibitor_v1 *idle_inhibitor = NULL;
+
+struct wlr_egl egl;
+struct wl_egl_window *egl_window;
+struct wlr_egl_surface *egl_surface;
+
+static void draw(void) {
+ eglMakeCurrent(egl.display, egl_surface, egl_surface, egl.context);
+
+ float color[] = {1.0, 1.0, 0.0, 1.0};
+ if (idle_inhibitor) {
+ color[0] = 0.0;
+ }
+
+ glViewport(0, 0, width, height);
+ glClearColor(color[0], color[1], color[2], 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ eglSwapBuffers(egl.display, egl_surface);
+}
+
+static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
+ uint32_t time, uint32_t button, uint32_t state_w) {
+ struct wl_surface *surface = data;
+
+ if (button == BTN_LEFT && state_w == WL_POINTER_BUTTON_STATE_PRESSED) {
+ if (idle_inhibitor) {
+ zwp_idle_inhibitor_v1_destroy(idle_inhibitor);
+ idle_inhibitor = NULL;
+ } else {
+ idle_inhibitor =
+ zwp_idle_inhibit_manager_v1_create_inhibitor(
+ idle_inhibit_manager,
+ surface);
+ }
+ }
+
+ draw();
+}
+
+static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
+ uint32_t serial, struct wl_surface *surface,
+ wl_fixed_t surface_x, wl_fixed_t surface_y) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
+ uint32_t serial, struct wl_surface *surface) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
+ uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
+ uint32_t time, uint32_t axis, wl_fixed_t value) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_axis_source(void *data,
+ struct wl_pointer *wl_pointer, uint32_t axis_source) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_axis_stop(void *data,
+ struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis) {
+ // This space intentionally left blank
+}
+
+static void pointer_handle_axis_discrete(void *data,
+ struct wl_pointer *wl_pointer, uint32_t axis, int32_t discrete) {
+ // This space intentionally left blank
+}
+
+static const struct wl_pointer_listener pointer_listener = {
+ .enter = pointer_handle_enter,
+ .leave = pointer_handle_leave,
+ .motion = pointer_handle_motion,
+ .button = pointer_handle_button,
+ .axis = pointer_handle_axis,
+ .frame = pointer_handle_frame,
+ .axis_source = pointer_handle_axis_source,
+ .axis_stop = pointer_handle_axis_stop,
+ .axis_discrete = pointer_handle_axis_discrete,
+};
+
+static void xdg_surface_handle_configure(void *data,
+ struct xdg_surface *xdg_surface, uint32_t serial) {
+ xdg_surface_ack_configure(xdg_surface, serial);
+ wl_egl_window_resize(egl_window, width, height, 0, 0);
+ draw();
+}
+
+static const struct xdg_surface_listener xdg_surface_listener = {
+ .configure = xdg_surface_handle_configure,
+};
+
+static void xdg_toplevel_handle_configure(void *data,
+ struct xdg_toplevel *xdg_toplevel, int32_t w, int32_t h,
+ struct wl_array *states) {
+ width = w;
+ height = h;
+}
+
+static void xdg_toplevel_handle_close(void *data,
+ struct xdg_toplevel *xdg_toplevel) {
+ exit(EXIT_SUCCESS);
+}
+
+
+static const struct xdg_toplevel_listener xdg_toplevel_listener = {
+ .configure = xdg_toplevel_handle_configure,
+ .close = xdg_toplevel_handle_close,
+};
+
+static void handle_global(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface, uint32_t version) {
+ if (strcmp(interface, "wl_compositor") == 0) {
+ compositor = wl_registry_bind(registry, name,
+ &wl_compositor_interface, 1);
+ } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
+ wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
+ } else if (strcmp(interface, zwp_idle_inhibit_manager_v1_interface.name) == 0) {
+ idle_inhibit_manager = wl_registry_bind(registry, name,
+ &zwp_idle_inhibit_manager_v1_interface, 1);
+ } else if (strcmp(interface, wl_seat_interface.name) == 0) {
+ seat = wl_registry_bind(registry, name, &wl_seat_interface, version);
+ }
+}
+
+static void handle_global_remove(void *data, struct wl_registry *registry,
+ uint32_t name) {
+ // who cares
+}
+
+static const struct wl_registry_listener registry_listener = {
+ .global = handle_global,
+ .global_remove = handle_global_remove,
+};
+
+int main(int argc, char **argv) {
+ struct wl_display *display = wl_display_connect(NULL);
+ if (display == NULL) {
+ fprintf(stderr, "Failed to create display\n");
+ return EXIT_FAILURE;
+ }
+
+ struct wl_registry *registry = wl_display_get_registry(display);
+ wl_registry_add_listener(registry, &registry_listener, NULL);
+ wl_display_dispatch(display);
+ wl_display_roundtrip(display);
+
+ if (compositor == NULL) {
+ fprintf(stderr, "wl-compositor not available\n");
+ return EXIT_FAILURE;
+ }
+ if (wm_base == NULL) {
+ fprintf(stderr, "xdg-shell not available\n");
+ return EXIT_FAILURE;
+ }
+ if (idle_inhibit_manager == NULL) {
+ fprintf(stderr, "idle-inhibit not available\n");
+ return EXIT_FAILURE;
+ }
+
+ wlr_egl_init(&egl, EGL_PLATFORM_WAYLAND_EXT, display, NULL,
+ WL_SHM_FORMAT_ARGB8888);
+
+ struct wl_surface *surface = wl_compositor_create_surface(compositor);
+ struct xdg_surface *xdg_surface =
+ xdg_wm_base_get_xdg_surface(wm_base, surface);
+ struct xdg_toplevel *xdg_toplevel = xdg_surface_get_toplevel(xdg_surface);
+
+ idle_inhibitor =
+ zwp_idle_inhibit_manager_v1_create_inhibitor(idle_inhibit_manager,
+ surface);
+
+ struct wl_pointer *pointer = wl_seat_get_pointer(seat);
+ wl_pointer_add_listener(pointer, &pointer_listener, surface);
+
+
+ xdg_surface_add_listener(xdg_surface, &xdg_surface_listener, NULL);
+ xdg_toplevel_add_listener(xdg_toplevel, &xdg_toplevel_listener, NULL);
+
+ wl_surface_commit(surface);
+
+ egl_window = wl_egl_window_create(surface, width, height);
+ egl_surface = wlr_egl_create_surface(&egl, egl_window);
+
+ wl_display_roundtrip(display);
+
+ draw();
+
+ while (wl_display_dispatch(display) != -1) {
+ // This space intentionally left blank
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/examples/meson.build b/examples/meson.build
index aa9eac47..a83def8f 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -41,3 +41,10 @@ executable(
dependencies: [wayland_client, wlr_protos, wlroots, threads],
link_with: lib_shared,
)
+
+executable(
+ 'idle-inhibit',
+ 'idle-inhibit.c',
+ dependencies: [wayland_client, wlr_protos, wlroots, threads],
+ link_with: lib_shared,
+)
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 91ab80f4..45257be9 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -122,7 +122,7 @@ static void handle_output_frame(struct output_state *output,
wlr_texture_get_matrix(sample->cat_texture, &matrix,
&wlr_output->transform_matrix, local_x, local_y);
wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix);
+ sample->cat_texture, &matrix, 1.0f);
}
wlr_renderer_end(sample->renderer);
diff --git a/examples/rotation.c b/examples/rotation.c
index e390daaf..1158ccc4 100644
--- a/examples/rotation.c
+++ b/examples/rotation.c
@@ -52,7 +52,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_texture_get_matrix(sample->cat_texture, &matrix,
&wlr_output->transform_matrix, x, y);
wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix);
+ sample->cat_texture, &matrix, 1.0f);
}
}
diff --git a/examples/screenshot.c b/examples/screenshot.c
index 7edb7327..e73989c6 100644
--- a/examples/screenshot.c
+++ b/examples/screenshot.c
@@ -122,7 +122,7 @@ static const struct wl_registry_listener registry_listener = {
};
static int backingfile(off_t size) {
- static char template[] = "/tmp/wlroots-shared-XXXXXX";
+ char template[] = "/tmp/wlroots-shared-XXXXXX";
int fd, ret;
fd = mkstemp(template);
diff --git a/examples/touch.c b/examples/touch.c
index 3cf00e9c..278252cc 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -53,7 +53,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
(int)(p->x * width) - sample->cat_texture->width / 2,
(int)(p->y * height) - sample->cat_texture->height / 2);
wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix);
+ sample->cat_texture, &matrix, 1.0f);
}
wlr_renderer_end(sample->renderer);
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 65db04ef..ee3fd38e 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -144,6 +144,7 @@ void wlr_drm_restore_outputs(struct wlr_drm_backend *drm);
void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn);
void wlr_drm_scan_connectors(struct wlr_drm_backend *state);
int wlr_drm_event(int fd, uint32_t mask, void *data);
+void wlr_drm_connector_enable(struct wlr_output *output, bool enable);
void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn);
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
index 0132a7e8..467de8ab 100644
--- a/include/rootston/desktop.h
+++ b/include/rootston/desktop.h
@@ -16,6 +16,10 @@
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/types/wlr_xdg_shell.h>
+#include <wlr/types/wlr_list.h>
+#include <wlr/types/wlr_idle.h>
+#include <wlr/types/wlr_idle_inhibit_v1.h>
+#include "rootston/view.h"
#include "rootston/config.h"
#include "rootston/output.h"
#include "rootston/view.h"
@@ -41,6 +45,7 @@ struct roots_desktop {
struct wlr_server_decoration_manager *server_decoration_manager;
struct wlr_primary_selection_device_manager *primary_selection_device_manager;
struct wlr_idle *idle;
+ struct wlr_idle_inhibit_manager_v1 *idle_inhibit;
struct wl_listener new_output;
struct wl_listener layout_change;
@@ -73,6 +78,7 @@ void view_apply_damage(struct roots_view *view);
void view_damage_whole(struct roots_view *view);
void view_update_position(struct roots_view *view, double x, double y);
void view_update_size(struct roots_view *view, uint32_t width, uint32_t height);
+void view_initial_focus(struct roots_view *view);
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
diff --git a/include/rootston/output.h b/include/rootston/output.h
index 9682e4f5..a852a204 100644
--- a/include/rootston/output.h
+++ b/include/rootston/output.h
@@ -19,7 +19,8 @@ struct roots_output {
struct wlr_output_damage *damage;
struct wl_listener destroy;
- struct wl_listener frame;
+ struct wl_listener damage_frame;
+ struct wl_listener damage_destroy;
};
void handle_new_output(struct wl_listener *listener, void *data);
diff --git a/include/rootston/view.h b/include/rootston/view.h
index 198086c1..ff5ef44a 100644
--- a/include/rootston/view.h
+++ b/include/rootston/view.h
@@ -83,6 +83,7 @@ struct roots_view {
double x, y;
uint32_t width, height;
float rotation;
+ float alpha;
bool decorated;
int border_width;
@@ -180,6 +181,7 @@ struct roots_xdg_popup {
struct wl_listener new_popup;
};
+struct roots_view *view_create();
void view_get_box(const struct roots_view *view, struct wlr_box *box);
void view_activate(struct roots_view *view, bool active);
void view_move(struct roots_view *view, double x, double y);
@@ -190,6 +192,7 @@ void view_maximize(struct roots_view *view, bool maximized);
void view_set_fullscreen(struct roots_view *view, bool fullscreen,
struct wlr_output *output);
void view_rotate(struct roots_view *view, float rotation);
+void view_cycle_alpha(struct roots_view *view);
void view_close(struct roots_view *view);
bool view_center(struct roots_view *view);
void view_setup(struct roots_view *view);
diff --git a/include/wlr/render.h b/include/wlr/render.h
index 3743482b..747603da 100644
--- a/include/wlr/render.h
+++ b/include/wlr/render.h
@@ -33,12 +33,13 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r);
* float projection[16];
* float matrix[16];
* wlr_texture_get_matrix(texture, &matrix, &projection, 123, 321);
- * wlr_render_with_matrix(renderer, texture, &matrix);
+ * wlr_render_with_matrix(renderer, texture, &matrix, 0.5f);
*
- * This will render the texture at <123, 321>.
+ * This will render the texture at <123, 321> with an alpha channel of 0.5.
*/
bool wlr_render_with_matrix(struct wlr_renderer *r,
- struct wlr_texture *texture, const float (*matrix)[16]);
+ struct wlr_texture *texture, const float (*matrix)[16], float alpha);
+
/**
* Renders a solid quad in the specified color.
*/
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index b989e399..eda5af1c 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -22,7 +22,7 @@ struct wlr_renderer_impl {
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer);
bool (*render_with_matrix)(struct wlr_renderer *renderer,
- struct wlr_texture *texture, const float (*matrix)[16]);
+ struct wlr_texture *texture, const float (*matrix)[16], float alpha);
void (*render_quad)(struct wlr_renderer *renderer,
const float (*color)[4], const float (*matrix)[16]);
void (*render_ellipse)(struct wlr_renderer *renderer,
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index 8481c590..5919b934 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -14,6 +14,7 @@ struct wlr_compositor {
struct {
struct wl_signal new_surface;
+ struct wl_signal destroy;
} events;
};
diff --git a/include/wlr/types/wlr_idle_inhibit_v1.h b/include/wlr/types/wlr_idle_inhibit_v1.h
new file mode 100644
index 00000000..a777ff43
--- /dev/null
+++ b/include/wlr/types/wlr_idle_inhibit_v1.h
@@ -0,0 +1,45 @@
+#ifndef WLR_TYPES_WLR_IDLE_INHIBIT_V1_H
+#define WLR_TYPES_WLR_IDLE_INHIBIT_V1_H
+
+#include <wayland-server.h>
+
+/* This interface permits clients to inhibit the idle behavior such as
+ * screenblanking, locking, and screensaving.
+ *
+ * This allows clients to ensure they stay visible instead of being hidden by
+ * power-saving.
+ *
+ * Inhibitors are created for surfaces. They should only be in effect, while
+ * this surface is visible.
+ * The effect could also be limited to outputs it is displayed on (e.g.
+ * dimm/dpms off outputs, except the one a video is displayed on).
+ */
+
+struct wlr_idle_inhibit_manager_v1 {
+ struct wl_list wl_resources; // wl_resource_get_link
+ struct wl_list inhibitors; // wlr_idle_inhibit_inhibitor_v1::link
+ struct wl_global *global;
+
+ struct wl_listener display_destroy;
+
+ struct {
+ struct wl_signal new_inhibitor;
+ } events;
+};
+
+struct wlr_idle_inhibitor_v1 {
+ struct wlr_surface *surface;
+ struct wl_resource *resource;
+ struct wl_listener surface_destroy;
+
+ struct wl_list link; // wlr_idle_inhibit_manager_v1::inhibitors;
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+};
+
+struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display);
+void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibit);
+
+#endif
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index ad7ceb83..0d4b91ed 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -186,4 +186,5 @@ void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface,
void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
struct wlr_seat *seat);
+bool wlr_xwayland_surface_is_unmanaged(const struct wlr_xwayland_surface *surface);
#endif
diff --git a/include/wlr/xwm.h b/include/wlr/xwm.h
index 242ff9cc..7d518f7e 100644
--- a/include/wlr/xwm.h
+++ b/include/wlr/xwm.h
@@ -39,6 +39,12 @@ enum atom_name {
INCR,
TEXT,
TIMESTAMP,
+ NET_WM_WINDOW_TYPE_UTILITY,
+ NET_WM_WINDOW_TYPE_TOOLTIP,
+ NET_WM_WINDOW_TYPE_DND,
+ NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
+ NET_WM_WINDOW_TYPE_POPUP_MENU,
+ NET_WM_WINDOW_TYPE_COMBO,
ATOM_LAST,
};
@@ -93,7 +99,8 @@ struct wlr_xwm {
const xcb_query_extension_reply_t *xfixes;
- struct wl_listener compositor_surface_create;
+ struct wl_listener compositor_new_surface;
+ struct wl_listener compositor_destroy;
struct wl_listener seat_selection;
struct wl_listener seat_primary_selection;
};
@@ -112,4 +119,7 @@ void xwm_selection_finish(struct wlr_xwm *xwm);
void xwm_set_seat(struct wlr_xwm *xwm, struct wlr_seat *seat);
+bool wlr_xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms,
+ size_t num_atoms, enum atom_name needle);
+
#endif
diff --git a/protocol/meson.build b/protocol/meson.build
index 2853971f..6c87a887 100644
--- a/protocol/meson.build
+++ b/protocol/meson.build
@@ -23,6 +23,7 @@ wayland_scanner_client = generator(
protocols = [
[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
+ [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
'gamma-control.xml',
'gtk-primary-selection.xml',
'idle.xml',
@@ -32,6 +33,8 @@ protocols = [
client_protocols = [
[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
+ [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
+ [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
'idle.xml',
'screenshooter.xml',
]
diff --git a/render/egl.c b/render/egl.c
index 21c446f1..0a68d6e5 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -83,6 +83,24 @@ static bool egl_get_config(EGLDisplay disp, EGLint *attribs, EGLConfig *out,
return false;
}
+static bool check_egl_ext(const char *egl_exts, const char *ext) {
+ size_t extlen = strlen(ext);
+ const char *end = egl_exts + strlen(egl_exts);
+
+ while (egl_exts < end) {
+ if (*egl_exts == ' ') {
+ egl_exts++;
+ continue;
+ }
+ size_t n = strcspn(egl_exts, " ");
+ if (n == extlen && strncmp(ext, egl_exts, n) == 0) {
+ return true;
+ }
+ egl_exts += n;
+ }
+ return false;
+}
+
bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
EGLint *config_attribs, EGLint visual_id) {
if (!load_glapi()) {
@@ -137,17 +155,17 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
wlr_log(L_INFO, "GL vendor: %s", glGetString(GL_VENDOR));
wlr_log(L_INFO, "Supported OpenGL ES extensions: %s", egl->gl_exts_str);
- if (strstr(egl->egl_exts_str, "EGL_WL_bind_wayland_display") == NULL ||
- strstr(egl->egl_exts_str, "EGL_KHR_image_base") == NULL) {
+ if (!check_egl_ext(egl->egl_exts_str, "EGL_WL_bind_wayland_display") ||
+ !check_egl_ext(egl->egl_exts_str, "EGL_KHR_image_base")) {
wlr_log(L_ERROR, "Required egl extensions not supported");
goto error;
}
egl->egl_exts.buffer_age =
- strstr(egl->egl_exts_str, "EGL_EXT_buffer_age") != NULL;
+ check_egl_ext(egl->egl_exts_str, "EGL_EXT_buffer_age");
egl->egl_exts.swap_buffers_with_damage =
- strstr(egl->egl_exts_str, "EGL_EXT_swap_buffers_with_damage") != NULL ||
- strstr(egl->egl_exts_str, "EGL_KHR_swap_buffers_with_damage") != NULL;
+ check_egl_ext(egl->egl_exts_str, "EGL_EXT_swap_buffers_with_damage") ||
+ check_egl_ext(egl->egl_exts_str, "EGL_KHR_swap_buffers_with_damage");
return true;
@@ -193,7 +211,7 @@ bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf,
EGLImage wlr_egl_create_image(struct wlr_egl *egl, EGLenum target,
EGLClientBuffer buffer, const EGLint *attribs) {
if (!eglCreateImageKHR) {
- return false;
+ return NULL;
}
return eglCreateImageKHR(egl->display, egl->context, target,
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 81a932e6..ad739cf8 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -171,7 +171,7 @@ static void draw_quad() {
}
static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
- struct wlr_texture *texture, const float (*matrix)[16]) {
+ struct wlr_texture *texture, const float (*matrix)[16], float alpha) {
if (!texture || !texture->valid) {
wlr_log(L_ERROR, "attempt to render invalid texture");
return false;
@@ -179,12 +179,12 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
wlr_texture_bind(texture);
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
- // TODO: source alpha from somewhere else I guess
- GL_CALL(glUniform1f(2, 1.0f));
+ GL_CALL(glUniform1f(2, alpha));
draw_quad();
return true;
}
+
static void wlr_gles2_render_quad(struct wlr_renderer *wlr_renderer,
const float (*color)[4], const float (*matrix)[16]) {
GL_CALL(glUseProgram(shaders.quad));
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 688a51d8..241b94a8 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -86,7 +86,8 @@ static bool gles2_texture_upload_shm(struct wlr_texture *_texture,
struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture;
const struct pixel_format *fmt = gl_format_for_wl_format(format);
if (!fmt || !fmt->gl_format) {
- wlr_log(L_ERROR, "No supported pixel format for this texture");
+ wlr_log(L_ERROR, "Unsupported pixel format %"PRIu32" for this texture",
+ format);
return false;
}
wl_shm_buffer_begin_access(buffer);
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index fa6c6fc3..ce8fbe36 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -36,8 +36,8 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) {
}
bool wlr_render_with_matrix(struct wlr_renderer *r,
- struct wlr_texture *texture, const float (*matrix)[16]) {
- return r->impl->render_with_matrix(r, texture, matrix);
+ struct wlr_texture *texture, const float (*matrix)[16], float alpha) {
+ return r->impl->render_with_matrix(r, texture, matrix, alpha);
}
void wlr_render_colored_quad(struct wlr_renderer *r,
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 6b28a41c..3628b051 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -10,6 +10,7 @@
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_wl_shell.h>
@@ -22,6 +23,16 @@
#include "rootston/view.h"
#include "rootston/xcursor.h"
+
+struct roots_view *view_create() {
+ struct roots_view *view = calloc(1, sizeof(struct roots_view));
+ if (!view) {
+ return NULL;
+ }
+ view->alpha = 1.0f;
+ return view;
+}
+
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x;
box->y = view->y;
@@ -268,6 +279,15 @@ void view_rotate(struct roots_view *view, float rotation) {
view_damage_whole(view);
}
+void view_cycle_alpha(struct roots_view *view) {
+ view->alpha -= 0.05;
+ /* Don't go completely transparent */
+ if (view->alpha < 0.1) {
+ view->alpha = 1.0;
+ }
+ view_damage_whole(view);
+}
+
void view_close(struct roots_view *view) {
if (view->close) {
view->close(view);
@@ -425,13 +445,17 @@ void view_init(struct roots_view *view, struct roots_desktop *desktop) {
view_damage_whole(view);
}
-void view_setup(struct roots_view *view) {
+void view_initial_focus(struct roots_view *view) {
struct roots_input *input = view->desktop->server->input;
// TODO what seat gets focus? the one with the last input event?
struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) {
roots_seat_set_focus(seat, view);
}
+}
+
+void view_setup(struct roots_view *view) {
+ view_initial_focus(view);
view_center(view);
view_update_output(view, NULL);
@@ -703,6 +727,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
desktop->primary_selection_device_manager =
wlr_primary_selection_device_manager_create(server->wl_display);
desktop->idle = wlr_idle_create(server->wl_display);
+ desktop->idle_inhibit = wlr_idle_inhibit_v1_create(server->wl_display);
return desktop;
}
diff --git a/rootston/keyboard.c b/rootston/keyboard.c
index 6ec90c31..b5dac51c 100644
--- a/rootston/keyboard.c
+++ b/rootston/keyboard.c
@@ -106,6 +106,11 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
}
} else if (strcmp(command, "next_window") == 0) {
roots_seat_cycle_focus(seat);
+ } else if (strcmp(command, "alpha") == 0) {
+ struct roots_view *focus = roots_seat_get_focus(seat);
+ if (focus != NULL) {
+ view_cycle_alpha(focus);
+ }
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
const char *shell_cmd = command + strlen(exec_prefix);
pid_t pid = fork();
diff --git a/rootston/output.c b/rootston/output.c
index 8ef383c3..4d0a9c05 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -182,26 +182,46 @@ static void xwayland_children_for_each_surface(
}
#endif
+static void drag_icons_for_each_surface(struct roots_input *input,
+ surface_iterator_func_t iterator, void *user_data) {
+ struct roots_seat *seat;
+ wl_list_for_each(seat, &input->seats, link) {
+ struct roots_drag_icon *drag_icon;
+ wl_list_for_each(drag_icon, &seat->drag_icons, link) {
+ if (!drag_icon->wlr_drag_icon->mapped) {
+ continue;
+ }
+ surface_for_each_surface(drag_icon->wlr_drag_icon->surface,
+ drag_icon->x, drag_icon->y, 0, iterator, user_data);
+ }
+ }
+}
+
struct render_data {
struct roots_output *output;
struct timespec *when;
pixman_region32_t *damage;
+ float alpha;
};
/**
- * Checks whether a surface at (lx, ly) intersects an output. Sets `box` to the
- * surface box in the output, in output-local coordinates.
+ * Checks whether a surface at (lx, ly) intersects an output. If `box` is not
+ * NULL, it populates it with the surface box in the output, in output-local
+ * coordinates.
*/
static bool surface_intersect_output(struct wlr_surface *surface,
struct wlr_output_layout *output_layout, struct wlr_output *wlr_output,
double lx, double ly, float rotation, struct wlr_box *box) {
double ox = lx, oy = ly;
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
- box->x = ox * wlr_output->scale;
- box->y = oy * wlr_output->scale;
- box->width = surface->current->width * wlr_output->scale;
- box->height = surface->current->height * wlr_output->scale;
+
+ if (box != NULL) {
+ box->x = ox * wlr_output->scale;
+ box->y = oy * wlr_output->scale;
+ box->width = surface->current->width * wlr_output->scale;
+ box->height = surface->current->height * wlr_output->scale;
+ }
struct wlr_box layout_box = {
.x = lx, .y = ly,
@@ -239,7 +259,6 @@ static void render_surface(struct wlr_surface *surface, double lx, double ly,
float rotation, void *_data) {
struct render_data *data = _data;
struct roots_output *output = data->output;
- struct timespec *when = data->when;
struct wlr_renderer *renderer =
wlr_backend_get_renderer(output->wlr_output->backend);
assert(renderer);
@@ -278,11 +297,9 @@ static void render_surface(struct wlr_surface *surface, double lx, double ly,
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
for (int i = 0; i < nrects; ++i) {
scissor_output(output, &rects[i]);
- wlr_render_with_matrix(renderer, surface->texture, &matrix);
+ wlr_render_with_matrix(renderer, surface->texture, &matrix, data->alpha);
}
- wlr_surface_send_frame_done(surface, when);
-
damage_finish:
pixman_region32_fini(&damage);
}
@@ -339,7 +356,7 @@ static void render_decorations(struct roots_view *view,
float matrix[16];
wlr_matrix_project_box(&matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
view->rotation, &output->wlr_output->transform_matrix);
- float color[] = { 0.2, 0.2, 0.2, 1 };
+ float color[] = { 0.2, 0.2, 0.2, view->alpha };
int nrects;
pixman_box32_t *rects =
@@ -360,6 +377,7 @@ static void render_view(struct roots_view *view, struct render_data *data) {
return;
}
+ data->alpha = view->alpha;
render_decorations(view, data);
view_for_each_surface(view, render_surface, data);
}
@@ -384,6 +402,20 @@ static bool has_standalone_surface(struct roots_view *view) {
return true;
}
+static void surface_send_frame_done(struct wlr_surface *surface, double lx,
+ double ly, float rotation, void *_data) {
+ struct render_data *data = _data;
+ struct roots_output *output = data->output;
+ struct timespec *when = data->when;
+
+ if (!surface_intersect_output(surface, output->desktop->layout,
+ output->wlr_output, lx, ly, rotation, NULL)) {
+ return;
+ }
+
+ wlr_surface_send_frame_done(surface, when);
+}
+
static void render_output(struct roots_output *output) {
struct wlr_output *wlr_output = output->wlr_output;
struct roots_desktop *desktop = output->desktop;
@@ -434,17 +466,18 @@ static void render_output(struct roots_output *output) {
return;
}
- if (!needs_swap) {
- // Output doesn't need swap and isn't damaged, skip rendering completely
- goto damage_finish;
- }
-
struct render_data data = {
.output = output,
.when = &now,
.damage = &damage,
+ .alpha = 1.0,
};
+ if (!needs_swap) {
+ // Output doesn't need swap and isn't damaged, skip rendering completely
+ goto damage_finish;
+ }
+
wlr_renderer_begin(renderer, wlr_output);
if (!pixman_region32_not_empty(&damage)) {
@@ -490,17 +523,8 @@ static void render_output(struct roots_output *output) {
}
// Render drag icons
- struct roots_drag_icon *drag_icon = NULL;
- struct roots_seat *seat = NULL;
- wl_list_for_each(seat, &server->input->seats, link) {
- wl_list_for_each(drag_icon, &seat->drag_icons, link) {
- if (!drag_icon->wlr_drag_icon->mapped) {
- continue;
- }
- render_surface(drag_icon->wlr_drag_icon->surface,
- drag_icon->x, drag_icon->y, 0, &data);
- }
- }
+ data.alpha = 1.0;
+ drag_icons_for_each_surface(server->input, render_surface, &data);
renderer_end:
wlr_renderer_scissor(renderer, NULL);
@@ -512,12 +536,32 @@ renderer_end:
damage_finish:
pixman_region32_fini(&damage);
-}
-static void output_damage_handle_frame(struct wl_listener *listener,
- void *data) {
- struct roots_output *output = wl_container_of(listener, output, frame);
- render_output(output);
+ // Send frame done events to all surfaces
+ if (output->fullscreen_view != NULL) {
+ struct roots_view *view = output->fullscreen_view;
+ if (wlr_output->fullscreen_surface == view->wlr_surface) {
+ // The surface is managed by the wlr_output
+ return;
+ }
+
+ view_for_each_surface(view, surface_send_frame_done, &data);
+
+#ifdef WLR_HAS_XWAYLAND
+ if (view->type == ROOTS_XWAYLAND_VIEW) {
+ xwayland_children_for_each_surface(view->xwayland_surface,
+ surface_send_frame_done, &data);
+ }
+#endif
+ } else {
+ struct roots_view *view;
+ wl_list_for_each_reverse(view, &desktop->views, link) {
+ view_for_each_surface(view, surface_send_frame_done, &data);
+ }
+
+ drag_icons_for_each_surface(server->input, surface_send_frame_done,
+ &data);
+ }
}
void output_damage_whole(struct roots_output *output) {
@@ -681,19 +725,37 @@ static void set_mode(struct wlr_output *output,
}
}
-static void output_handle_destroy(struct wl_listener *listener, void *data) {
- struct roots_output *output = wl_container_of(listener, output, destroy);
-
+static void output_destroy(struct roots_output *output) {
// TODO: cursor
//example_config_configure_cursor(sample->config, sample->cursor,
// sample->compositor);
wl_list_remove(&output->link);
wl_list_remove(&output->destroy.link);
- wl_list_remove(&output->frame.link);
+ wl_list_remove(&output->damage_frame.link);
+ wl_list_remove(&output->damage_destroy.link);
free(output);
}
+static void output_handle_destroy(struct wl_listener *listener, void *data) {
+ struct roots_output *output = wl_container_of(listener, output, destroy);
+ output_destroy(output);
+}
+
+static void output_damage_handle_frame(struct wl_listener *listener,
+ void *data) {
+ struct roots_output *output =
+ wl_container_of(listener, output, damage_frame);
+ render_output(output);
+}
+
+static void output_damage_handle_destroy(struct wl_listener *listener,
+ void *data) {
+ struct roots_output *output =
+ wl_container_of(listener, output, damage_destroy);
+ output_destroy(output);
+}
+
void handle_new_output(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = wl_container_of(listener, desktop,
new_output);
@@ -722,8 +784,10 @@ void handle_new_output(struct wl_listener *listener, void *data) {
output->destroy.notify = output_handle_destroy;
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
- output->frame.notify = output_damage_handle_frame;
- wl_signal_add(&output->damage->events.frame, &output->frame);
+ output->damage_frame.notify = output_damage_handle_frame;
+ wl_signal_add(&output->damage->events.frame, &output->damage_frame);
+ output->damage_destroy.notify = output_damage_handle_destroy;
+ wl_signal_add(&output->damage->events.destroy, &output->damage_destroy);
struct roots_output_config *output_config =
roots_config_get_output(config, wlr_output);
diff --git a/rootston/rootston.ini.example b/rootston/rootston.ini.example
index a6619767..6f29a35d 100644
--- a/rootston/rootston.ini.example
+++ b/rootston/rootston.ini.example
@@ -42,8 +42,10 @@ meta-key = Logo
# - "exec" to execute a shell command
# - "close" to close the current view
# - "next_window" to cycle through windows
+# - "alpha" to cycle a window's alpha channel
[bindings]
Logo+Shift+e = exit
Logo+q = close
Logo+m = maximize
Alt+Tab = next_window
+Ctrl+Shift+a = alpha
diff --git a/rootston/seat.c b/rootston/seat.c
index 38c26628..9acbb737 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -408,10 +408,10 @@ static void handle_keyboard_destroy(struct wl_listener *listener, void *data) {
struct roots_keyboard *keyboard =
wl_container_of(listener, keyboard, device_destroy);
struct roots_seat *seat = keyboard->seat;
- roots_keyboard_destroy(keyboard);
wl_list_remove(&keyboard->device_destroy.link);
wl_list_remove(&keyboard->keyboard_key.link);
wl_list_remove(&keyboard->keyboard_modifiers.link);
+ roots_keyboard_destroy(keyboard);
seat_update_capabilities(seat);
}
@@ -721,7 +721,7 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
#ifdef WLR_HAS_XWAYLAND
if (view && view->type == ROOTS_XWAYLAND_VIEW &&
- view->xwayland_surface->override_redirect) {
+ wlr_xwayland_surface_is_unmanaged(view->xwayland_surface)) {
return;
}
#endif
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 44a65cf5..899df1c6 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -227,7 +227,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit);
- struct roots_view *view = calloc(1, sizeof(struct roots_view));
+ struct roots_view *view = view_create();
if (!view) {
free(roots_surface);
return;
diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c
index 8340de46..9368ce0b 100644
--- a/rootston/xdg_shell.c
+++ b/rootston/xdg_shell.c
@@ -333,7 +333,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->new_popup.notify = handle_new_popup;
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
- struct roots_view *view = calloc(1, sizeof(struct roots_view));
+ struct roots_view *view = view_create();
if (!view) {
free(roots_surface);
return;
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index 8e6674ab..eda349cb 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -333,7 +333,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
roots_surface->new_popup.notify = handle_new_popup;
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
- struct roots_view *view = calloc(1, sizeof(struct roots_view));
+ struct roots_view *view = view_create();
if (!view) {
free(roots_surface);
return;
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index e9e0d5e0..56f068ea 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -317,7 +317,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_signal_add(&surface->surface->events.commit,
&roots_surface->surface_commit);
- struct roots_view *view = calloc(1, sizeof(struct roots_view));
+ struct roots_view *view = view_create();
if (view == NULL) {
free(roots_surface);
return;
@@ -350,5 +350,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
}
view_setup(view);
+ } else {
+ view_initial_focus(view);
}
}
diff --git a/types/meson.build b/types/meson.build
index 3e40be02..703b06ca 100644
--- a/types/meson.build
+++ b/types/meson.build
@@ -27,6 +27,7 @@ lib_wlr_types = static_library(
'wlr_xcursor_manager.c',
'wlr_xdg_shell_v6.c',
'wlr_xdg_shell.c',
+ 'wlr_idle_inhibit_v1.c',
),
include_directories: wlr_inc,
dependencies: [pixman, xkbcommon, wayland_server, wlr_protos],
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 008f2e51..f27655c0 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -90,6 +90,7 @@ void wlr_compositor_destroy(struct wlr_compositor *compositor) {
if (compositor == NULL) {
return;
}
+ wlr_signal_emit_safe(&compositor->events.destroy, compositor);
wl_list_remove(&compositor->display_destroy.link);
wl_global_destroy(compositor->wl_global);
free(compositor);
@@ -195,6 +196,7 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
wl_list_init(&compositor->wl_resources);
wl_list_init(&compositor->surfaces);
wl_signal_init(&compositor->events.new_surface);
+ wl_signal_init(&compositor->events.destroy);
compositor->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &compositor->display_destroy);
diff --git a/types/wlr_idle_inhibit_v1.c b/types/wlr_idle_inhibit_v1.c
new file mode 100644
index 00000000..3a5fc810
--- /dev/null
+++ b/types/wlr_idle_inhibit_v1.c
@@ -0,0 +1,185 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <wlr/util/log.h>
+#include <util/signal.h>
+#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_idle_inhibit_v1.h>
+#include "wayland-util.h"
+#include "wayland-server.h"
+#include "idle-inhibit-unstable-v1-protocol.h"
+
+static struct zwp_idle_inhibit_manager_v1_interface idle_inhibit_impl;
+
+static struct zwp_idle_inhibitor_v1_interface idle_inhibitor_impl;
+
+static struct wlr_idle_inhibit_manager_v1 *
+wlr_idle_inhibit_manager_v1_from_resource(struct wl_resource *resource) {
+ assert(wl_resource_instance_of(resource, &zwp_idle_inhibit_manager_v1_interface,
+ &idle_inhibit_impl));
+ return wl_resource_get_user_data(resource);
+}
+
+static struct wlr_idle_inhibitor_v1 *
+wlr_idle_inhibitor_v1_from_resource(struct wl_resource *resource) {
+ assert(wl_resource_instance_of(resource, &zwp_idle_inhibitor_v1_interface,
+ &idle_inhibitor_impl));
+ return wl_resource_get_user_data(resource);
+}
+
+static void idle_inhibitor_destroy(struct wl_resource *resource) {
+ struct wlr_idle_inhibitor_v1 *inhibitor =
+ wlr_idle_inhibitor_v1_from_resource(resource);
+
+ wlr_signal_emit_safe(&inhibitor->events.destroy, inhibitor->surface);
+
+ wl_list_remove(&inhibitor->link);
+ wl_list_remove(&inhibitor->surface_destroy.link);
+ free(inhibitor);
+}
+
+static void idle_inhibitor_handle_surface_destroy(
+ struct wl_listener *listener, void *data) {
+ struct wlr_idle_inhibitor_v1 *inhibitor =
+ wl_container_of(listener, inhibitor, surface_destroy);
+
+ wl_resource_destroy(inhibitor->resource);
+}
+
+static void idle_inhibitor_v1_handle_destroy(struct wl_client *client,
+ struct wl_resource *manager_resource) {
+ wl_resource_destroy(manager_resource);
+}
+
+static struct zwp_idle_inhibitor_v1_interface idle_inhibitor_impl = {
+ .destroy = idle_inhibitor_v1_handle_destroy,
+};
+
+static void wlr_create_inhibitor(struct wl_client *client,
+ struct wl_resource *resource, uint32_t id,
+ struct wl_resource *surface_resource) {
+ struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
+ struct wlr_idle_inhibit_manager_v1 *manager =
+ wlr_idle_inhibit_manager_v1_from_resource(resource);
+
+ struct wlr_idle_inhibitor_v1 *inhibitor =
+ calloc(1, sizeof(struct wlr_idle_inhibitor_v1));
+ if (!inhibitor) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ struct wl_resource *wl_resource = wl_resource_create(client,
+ &zwp_idle_inhibitor_v1_interface, 1, id);
+ if (!wl_resource) {
+ wl_client_post_no_memory(client);
+ free(inhibitor);
+ return;
+ }
+
+ inhibitor->resource = wl_resource;
+ inhibitor->surface = surface;
+ wl_signal_init(&inhibitor->events.destroy);
+
+ inhibitor->surface_destroy.notify = idle_inhibitor_handle_surface_destroy;
+ wl_signal_add(&surface->events.destroy, &inhibitor->surface_destroy);
+
+
+ wl_resource_set_implementation(wl_resource, &idle_inhibitor_impl,
+ inhibitor, idle_inhibitor_destroy);
+
+ wl_list_insert(&manager->inhibitors, &inhibitor->link);
+ wlr_signal_emit_safe(&manager->events.new_inhibitor, inhibitor);
+}
+
+
+static void idle_inhibit_manager_v1_destroy(struct wl_resource *resource) {
+ wl_list_remove(wl_resource_get_link(resource));
+}
+
+static void idle_inhibit_manager_v1_handle_destroy(struct wl_client *client,
+ struct wl_resource *manager_resource) {
+ wl_resource_destroy(manager_resource);
+}
+
+static struct zwp_idle_inhibit_manager_v1_interface idle_inhibit_impl = {
+ .destroy = idle_inhibit_manager_v1_handle_destroy,
+ .create_inhibitor = wlr_create_inhibitor,
+};
+
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_idle_inhibit_manager_v1 *idle_inhibit =
+ wl_container_of(listener, idle_inhibit, display_destroy);
+
+ wlr_idle_inhibit_v1_destroy(idle_inhibit);
+}
+
+static void idle_inhibit_bind(struct wl_client *wl_client, void *data,
+ uint32_t version, uint32_t id) {
+ struct wlr_idle_inhibit_manager_v1 *idle_inhibit = data;
+
+ struct wl_resource *wl_resource = wl_resource_create(wl_client,
+ &zwp_idle_inhibit_manager_v1_interface, version, id);
+
+ if (!wl_resource) {
+ wl_client_post_no_memory(wl_client);
+ return;
+ }
+
+ wl_list_insert(&idle_inhibit->wl_resources, wl_resource_get_link(wl_resource));
+
+ wl_resource_set_implementation(wl_resource, &idle_inhibit_impl,
+ idle_inhibit, idle_inhibit_manager_v1_destroy);
+ wlr_log(L_DEBUG, "idle_inhibit bound");
+}
+
+void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibit) {
+ if (!idle_inhibit) {
+ return;
+ }
+
+ wl_list_remove(&idle_inhibit->display_destroy.link);
+
+ struct wlr_idle_inhibitor_v1 *inhibitor;
+ struct wlr_idle_inhibitor_v1 *tmp;
+ wl_list_for_each_safe(inhibitor, tmp, &idle_inhibit->inhibitors, link) {
+ wl_resource_destroy(inhibitor->resource);
+ }
+
+ struct wl_resource *resource;
+ struct wl_resource *tmp_resource;
+ wl_resource_for_each_safe(resource, tmp_resource, &idle_inhibit->wl_resources) {
+ wl_resource_destroy(inhibitor->resource);
+ }
+
+ wl_global_destroy(idle_inhibit->global);
+ free(idle_inhibit);
+}
+
+struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display) {
+ struct wlr_idle_inhibit_manager_v1 *idle_inhibit =
+ calloc(1, sizeof(struct wlr_idle_inhibit_manager_v1));
+
+ if (!idle_inhibit) {
+ return NULL;
+ }
+
+ wl_list_init(&idle_inhibit->wl_resources);
+ wl_list_init(&idle_inhibit->inhibitors);
+ idle_inhibit->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &idle_inhibit->display_destroy);
+ wl_signal_init(&idle_inhibit->events.new_inhibitor);
+
+ idle_inhibit->global = wl_global_create(display,
+ &zwp_idle_inhibit_manager_v1_interface, 1,
+ idle_inhibit, idle_inhibit_bind);
+
+ if (!idle_inhibit->global) {
+ wl_list_remove(&idle_inhibit->display_destroy.link);
+ free(idle_inhibit);
+ return NULL;
+ }
+
+ wlr_log(L_DEBUG, "idle_inhibit manager created");
+
+ return idle_inhibit;
+}
diff --git a/types/wlr_output.c b/types/wlr_output.c
index bc3da269..96c9d324 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -386,7 +386,7 @@ static void output_fullscreen_surface_render(struct wlr_output *output,
for (int i = 0; i < nrects; ++i) {
output_scissor(output, &rects[i]);
wlr_renderer_clear(renderer, &(float[]){0, 0, 0, 0});
- wlr_render_with_matrix(surface->renderer, surface->texture, &matrix);
+ wlr_render_with_matrix(surface->renderer, surface->texture, &matrix, 1.0f);
}
wlr_renderer_scissor(renderer, NULL);
@@ -443,7 +443,7 @@ static void output_cursor_render(struct wlr_output_cursor *cursor,
pixman_box32_t *rects = pixman_region32_rectangles(&surface_damage, &nrects);
for (int i = 0; i < nrects; ++i) {
output_scissor(cursor->output, &rects[i]);
- wlr_render_with_matrix(renderer, texture, &matrix);
+ wlr_render_with_matrix(renderer, texture, &matrix, 1.0f);
}
wlr_renderer_scissor(renderer, NULL);
diff --git a/wlroots.syms b/wlroots.syms
index 93d6fe51..3f45e045 100644
--- a/wlroots.syms
+++ b/wlroots.syms
@@ -2,6 +2,7 @@ WLROOTS_0_0_0 {
global:
wlr_*;
_wlr_log;
+ _wlr_vlog;
local:
wlr_data_device_keyboard_drag_interface;
wlr_data_device_pointer_drag_interface;
diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c
index 1d935180..8dffd040 100644
--- a/xwayland/xwayland.c
+++ b/xwayland/xwayland.c
@@ -405,3 +405,24 @@ void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
xwayland->seat_destroy.notify = wlr_xwayland_handle_seat_destroy;
wl_signal_add(&seat->events.destroy, &xwayland->seat_destroy);
}
+
+
+bool wlr_xwayland_surface_is_unmanaged(const struct wlr_xwayland_surface *surface) {
+ static enum atom_name needles[] = {
+ NET_WM_WINDOW_TYPE_UTILITY,
+ NET_WM_WINDOW_TYPE_TOOLTIP,
+ NET_WM_WINDOW_TYPE_DND,
+ NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
+ NET_WM_WINDOW_TYPE_POPUP_MENU,
+ NET_WM_WINDOW_TYPE_COMBO,
+ };
+
+ for (size_t i = 0; i < sizeof(needles) / sizeof(needles[0]); ++i) {
+ if (wlr_xwm_atoms_contains(surface->xwm, surface->window_type,
+ surface->window_type_len, needles[i])) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 94dfdaab..c41b8d47 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -54,6 +54,12 @@ const char *atom_map[ATOM_LAST] = {
"INCR",
"TEXT",
"TIMESTAMP",
+ "_NET_WM_WINDOW_TYPE_UTILITY",
+ "_NET_WM_WINDOW_TYPE_TOOLTIP",
+ "_NET_WM_WINDOW_TYPE_DND",
+ "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
+ "_NET_WM_WINDOW_TYPE_POPUP_MENU",
+ "_NET_WM_WINDOW_TYPE_COMBO",
};
/* General helpers */
@@ -1019,11 +1025,11 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) {
return count;
}
-static void handle_compositor_surface_create(struct wl_listener *listener,
+static void handle_compositor_new_surface(struct wl_listener *listener,
void *data) {
- struct wlr_surface *surface = data;
struct wlr_xwm *xwm =
- wl_container_of(listener, xwm, compositor_surface_create);
+ wl_container_of(listener, xwm, compositor_new_surface);
+ struct wlr_surface *surface = data;
if (wl_resource_get_client(surface->resource) != xwm->xwayland->client) {
return;
}
@@ -1043,6 +1049,16 @@ static void handle_compositor_surface_create(struct wl_listener *listener,
}
}
+static void handle_compositor_destroy(struct wl_listener *listener,
+ void *data) {
+ struct wlr_xwm *xwm =
+ wl_container_of(listener, xwm, compositor_destroy);
+ wl_list_remove(&xwm->compositor_new_surface.link);
+ wl_list_remove(&xwm->compositor_destroy.link);
+ wl_list_init(&xwm->compositor_new_surface.link);
+ wl_list_init(&xwm->compositor_destroy.link);
+}
+
void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *xsurface,
bool activated) {
struct wlr_xwayland_surface *focused = xsurface->xwm->focus_surface;
@@ -1124,7 +1140,8 @@ void xwm_destroy(struct wlr_xwm *xwm) {
wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) {
wlr_xwayland_surface_destroy(xsurface);
}
- wl_list_remove(&xwm->compositor_surface_create.link);
+ wl_list_remove(&xwm->compositor_new_surface.link);
+ wl_list_remove(&xwm->compositor_destroy.link);
xcb_disconnect(xwm->xcb_conn);
free(xwm);
@@ -1407,9 +1424,12 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
xwm_selection_init(xwm);
- xwm->compositor_surface_create.notify = handle_compositor_surface_create;
+ xwm->compositor_new_surface.notify = handle_compositor_new_surface;
wl_signal_add(&wlr_xwayland->compositor->events.new_surface,
- &xwm->compositor_surface_create);
+ &xwm->compositor_new_surface);
+ xwm->compositor_destroy.notify = handle_compositor_destroy;
+ wl_signal_add(&wlr_xwayland->compositor->events.destroy,
+ &xwm->compositor_destroy);
xwm_create_wm_window(xwm);
@@ -1432,3 +1452,17 @@ void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface,
xsurface_set_net_wm_state(surface);
xcb_flush(surface->xwm->xcb_conn);
}
+
+bool wlr_xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms,
+ size_t num_atoms, enum atom_name needle) {
+ xcb_atom_t atom = xwm->atoms[needle];
+
+ for (size_t i = 0; i < num_atoms; ++i) {
+ if (atom == atoms[i]) {
+ return true;
+ }
+ }
+
+ return false;
+}
+