diff options
-rw-r--r-- | backend/drm/backend.c | 2 | ||||
-rw-r--r-- | backend/drm/drm.c | 6 | ||||
-rw-r--r-- | backend/drm/renderer.c | 2 | ||||
-rw-r--r-- | backend/headless/output.c | 2 | ||||
-rw-r--r-- | backend/libinput/backend.c | 4 | ||||
-rw-r--r-- | examples/output-layout.c | 2 | ||||
-rw-r--r-- | examples/rotation.c | 2 | ||||
-rw-r--r-- | examples/screenshot.c | 2 | ||||
-rw-r--r-- | examples/touch.c | 2 | ||||
-rw-r--r-- | include/backend/drm/drm.h | 1 | ||||
-rw-r--r-- | include/rootston/view.h | 3 | ||||
-rw-r--r-- | include/wlr/render.h | 7 | ||||
-rw-r--r-- | include/wlr/render/interface.h | 2 | ||||
-rw-r--r-- | render/gles2/renderer.c | 6 | ||||
-rw-r--r-- | render/wlr_renderer.c | 4 | ||||
-rw-r--r-- | rootston/desktop.c | 19 | ||||
-rw-r--r-- | rootston/keyboard.c | 5 | ||||
-rw-r--r-- | rootston/output.c | 6 | ||||
-rw-r--r-- | rootston/rootston.ini.example | 2 | ||||
-rw-r--r-- | rootston/wl_shell.c | 2 | ||||
-rw-r--r-- | rootston/xdg_shell.c | 2 | ||||
-rw-r--r-- | rootston/xdg_shell_v6.c | 2 | ||||
-rw-r--r-- | rootston/xwayland.c | 2 | ||||
-rw-r--r-- | types/wlr_output.c | 4 |
24 files changed, 66 insertions, 25 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 47dff227..fec14da9 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -83,6 +83,8 @@ static void session_signal(struct wl_listener *listener, void *data) { wl_list_for_each(conn, &drm->outputs, link){ if (conn->output.current_mode) { 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..d6388597 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; @@ -296,6 +296,8 @@ static void wlr_drm_connector_enable(struct wlr_output *output, bool enable) { if (enable) { wlr_drm_connector_start_renderer(conn); + } else { + output->current_mode = NULL; } wlr_output_update_enabled(&conn->output, enable); @@ -647,7 +649,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/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/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/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/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 a8b070ce..3628b051 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -23,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; @@ -269,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); 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 a354ebf8..3e954989 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -202,6 +202,7 @@ struct render_data { struct roots_output *output; struct timespec *when; pixman_region32_t *damage; + float alpha; }; /** @@ -296,7 +297,7 @@ 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); } damage_finish: @@ -355,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 = @@ -376,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); } 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/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 1aa5a96c..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; diff --git a/types/wlr_output.c b/types/wlr_output.c index 809b1959..5a2886c7 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -391,7 +391,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); @@ -448,7 +448,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); |