diff --git a/include/ssd.h b/include/ssd.h index f1b27516..5d0a32ee 100644 --- a/include/ssd.h +++ b/include/ssd.h @@ -68,6 +68,7 @@ void ssd_destroy(struct ssd *ssd); void ssd_titlebar_hide(struct ssd *ssd); void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable); +void ssd_enable_shade(struct ssd *ssd, bool enable); struct ssd_hover_state *ssd_hover_state_new(void); void ssd_update_button_hover(struct wlr_scene_node *node, diff --git a/include/view.h b/include/view.h index c446df8b..ea8ce5a7 100644 --- a/include/view.h +++ b/include/view.h @@ -148,6 +148,7 @@ struct view { bool ssd_enabled; bool ssd_titlebar_hidden; enum ssd_preference ssd_preference; + bool shaded; bool minimized; enum view_axis maximized; bool fullscreen; @@ -462,6 +463,7 @@ const char *view_get_string_prop(struct view *view, const char *prop); void view_update_title(struct view *view); void view_update_app_id(struct view *view); void view_reload_ssd(struct view *view); +void view_toggle_shade(struct view *view); struct view_size_hints view_get_size_hints(struct view *view); void view_adjust_size(struct view *view, int *w, int *h); diff --git a/src/action.c b/src/action.c index 46bc8c9e..9ff478bf 100644 --- a/src/action.c +++ b/src/action.c @@ -103,6 +103,7 @@ enum action_type { ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE, ACTION_TYPE_AUTO_PLACE, ACTION_TYPE_TOGGLE_TEARING, + ACTION_TYPE_TOGGLE_SHADE, }; const char *action_names[] = { @@ -151,6 +152,7 @@ const char *action_names[] = { "VirtualOutputRemove", "AutoPlace", "ToggleTearing", + "ToggleShade", NULL }; @@ -960,6 +962,11 @@ actions_run(struct view *activator, struct server *server, view->tearing_hint ? "en" : "dis"); } break; + case ACTION_TYPE_TOGGLE_SHADE: + if (view) { + view_toggle_shade(view); + } + break; case ACTION_TYPE_INVALID: wlr_log(WLR_ERROR, "Not executing unknown action"); break; diff --git a/src/input/cursor.c b/src/input/cursor.c index 309bb6cd..38bf250c 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -471,7 +471,12 @@ cursor_update_common(struct server *server, struct cursor_context *ctx, */ wlr_seat_pointer_notify_clear_focus(wlr_seat); if (!seat->drag.active) { - cursor_set(seat, cursor_get_from_ssd(ctx->type)); + enum lab_cursors cursor = cursor_get_from_ssd(ctx->type); + if (ctx->view && ctx->view->shaded && cursor > LAB_CURSOR_GRAB) { + /* Prevent resize cursor on borders for shaded SSD */ + cursor = LAB_CURSOR_DEFAULT; + } + cursor_set(seat, cursor); } } } diff --git a/src/interactive.c b/src/interactive.c index f92ab8c1..d6672efe 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -80,10 +80,11 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges) cursor_set(seat, LAB_CURSOR_GRAB); break; case LAB_INPUT_STATE_RESIZE: - if (view->fullscreen || view->maximized == VIEW_AXIS_BOTH) { + if (view->shaded || view->fullscreen || + view->maximized == VIEW_AXIS_BOTH) { /* - * We don't allow resizing while fullscreen or - * maximized in both directions. + * We don't allow resizing while shaded, + * fullscreen or maximized in both directions. */ return; } diff --git a/src/menu/menu.c b/src/menu/menu.c index 236ab26d..86f5f163 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -718,6 +718,8 @@ init_windowmenu(struct server *server) fill_item("name.action", "ToggleMaximize"); current_item = item_create(menu, _("Fullscreen"), false); fill_item("name.action", "ToggleFullscreen"); + current_item = item_create(menu, _("Shade"), false); + fill_item("name.action", "ToggleShade"); current_item = item_create(menu, _("Decorations"), false); fill_item("name.action", "ToggleDecorations"); current_item = item_create(menu, _("Always on Top"), false); diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index df18f1e5..35294160 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -333,6 +333,16 @@ ssd_set_active(struct ssd *ssd, bool active) wlr_scene_node_set_enabled(&ssd->titlebar.inactive.tree->node, !active); } +void +ssd_enable_shade(struct ssd *ssd, bool enable) +{ + if (!ssd) { + return; + } + wlr_scene_node_set_enabled(&ssd->border.tree->node, !enable); + wlr_scene_node_set_enabled(&ssd->extents.tree->node, !enable); +} + void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable) { diff --git a/src/view.c b/src/view.c index 7ab09e2d..6e6689cf 100644 --- a/src/view.c +++ b/src/view.c @@ -1974,6 +1974,18 @@ view_connect_map(struct view *view, struct wlr_surface *surface) mappable_connect(&view->mappable, surface, handle_map, handle_unmap); } +void +view_toggle_shade(struct view *view) +{ + assert(view); + if (!view->ssd) { + return; + } + view->shaded = !view->shaded; + ssd_enable_shade(view->ssd, view->shaded); + wlr_scene_node_set_enabled(view->scene_node, !view->shaded); +} + void view_destroy(struct view *view) {