Skip to content

Instantly share code, notes, and snippets.

@Consolatis
Created August 7, 2023 12:10
Show Gist options
  • Save Consolatis/bf5d7e3ee5b2ac9358bd880763c7f5a2 to your computer and use it in GitHub Desktop.
Save Consolatis/bf5d7e3ee5b2ac9358bd880763c7f5a2 to your computer and use it in GitHub Desktop.
Incomplete ToggleShade implementation
diff --git a/include/ssd.h b/include/ssd.h
index 5e82be2c..2664905f 100644
--- a/include/ssd.h
+++ b/include/ssd.h
@@ -65,6 +65,7 @@ void ssd_update_geometry(struct ssd *ssd);
void ssd_destroy(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 79963b4b..7192249c 100644
--- a/include/view.h
+++ b/include/view.h
@@ -221,6 +221,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);
void view_adjust_size(struct view *view, int *w, int *h);
diff --git a/src/action.c b/src/action.c
index c04e1c54..b15f5f3f 100644
--- a/src/action.c
+++ b/src/action.c
@@ -82,6 +82,7 @@ enum action_type {
ACTION_TYPE_SNAP_TO_REGION,
ACTION_TYPE_TOGGLE_KEYBINDS,
ACTION_TYPE_FOCUS_OUTPUT,
+ ACTION_TYPE_TOGGLE_SHADE,
};
const char *action_names[] = {
@@ -118,6 +119,7 @@ const char *action_names[] = {
"SnapToRegion",
"ToggleKeybinds",
"FocusOutput",
+ "ToggleShade",
NULL
};
@@ -743,6 +745,11 @@ actions_run(struct view *activator, struct server *server,
desktop_focus_output(output_from_name(server, output_name));
}
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/ssd/ssd.c b/src/ssd/ssd.c
index 3cd9b875..40e3493b 100644
--- a/src/ssd/ssd.c
+++ b/src/ssd/ssd.c
@@ -273,6 +273,17 @@ 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.active.tree->node, !enable);
+ wlr_scene_node_set_enabled(&ssd->border.inactive.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 4c72e13f..472c4b71 100644
--- a/src/view.c
+++ b/src/view.c
@@ -1170,6 +1170,14 @@ view_toggle_keybinds(struct view *view)
inhibit_keybinds(view, !view->inhibits_keybinds);
}
+void
+view_toggle_shade(struct view *view)
+{
+ assert(view);
+ ssd_enable_shade(view->ssd, view->scene_node->enabled);
+ wlr_scene_node_set_enabled(view->scene_node, !view->scene_node->enabled);
+}
+
void
view_destroy(struct view *view)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment