I've switched to Wayland. Instead of Openbox on Xorg, I started using Labwc with Wayland. I'm slowly moving my configuration to the new environment and trying to find solutions to problems that have already been solved for Openbox.
One of those problems was the automatic removal of window titlebars for maximized windows. Since I use a top panel, the window name is displayed on the panel and I don't need the redundant titlebar. Orcsome was able to accomplish this. Unfortunately, there's nothing like Orcsome for Wayland or Labwc (yet).
My previous workaround for Labwc was using a config file tweak which would remove the decorations every time the window is maximized by clicking the "maximize" button on the titlebar. Also, maximizing windows via a keyboard shortcut would also remove the titlebar. It worked fine, but had its limitations: windows that start maximized would still have the titlebar and I'd have to remove it manually by pressing the maximize keyboard shortcut. I also tried to define a catch-all rule which starts everything maximized without decorations and then separate rules for each program that I didn't want to maximize. It's tedious, because you always need to keep updating it.
Here's how the workarounds look like:
This is the first case which removes the decorations when clicking the maximize button.
<context name="Maximize">
<mousebind button="Left" action="Click">
<action name="ToggleMaximize" />
<action name="SetDecorations" decorations="none" forceSSD="no" />
</mousebind>
...
</context>
The second example is for the keyboard shortcut which maximizes and removes the decorations.
<keybind key="W-Page_Up">
<action name="Maximize"/>
<action name="SetDecorations" decorations="none" forceSSD="no" />
</keybind>
Native Labwc solution
With the help of AI, I was able to cobble together a patch to bring this functionality to Labwc natively. "Help" is an understatement in this case. The AI did everything, since I have no C programming knowledge whatsoever.
To my surprise, it worked on the first try. Here's the patch.
diff --git a/include/view.h b/include/view.h
index 0ff42c85..43a4d4f0 100644
--- a/include/view.h
+++ b/include/view.h
@@ -209,6 +209,9 @@ struct view {
bool inhibits_keybinds;
xkb_layout_index_t keyboard_layout;
+ bool saved_ssd_enabled;
+ bool saved_decoration_state_valid;
+
/* Pointer to an output owned struct region, may be NULL */
struct region *tiled_region;
/* Set to region->name when tiled_region is free'd by a destroying output */
diff --git a/src/view.c b/src/view.c
index e17a883c..1e86e3e3 100644
--- a/src/view.c
+++ b/src/view.c
@@ -1265,7 +1265,15 @@ view_apply_maximized_geometry(struct view *view)
{
assert(view);
assert(view->maximized != VIEW_AXIS_NONE);
+
+ if (!view->saved_decoration_state_valid) {
+ view->saved_ssd_enabled = view->ssd_enabled;
+ view->saved_decoration_state_valid = true;
+ }
+
+ view->ssd_enabled = false;
struct output *output = view->output;
+
assert(output_is_usable(output));
struct wlr_box box = output_usable_area_in_layout_coords(output);
@@ -1365,6 +1373,10 @@ view_restore_to(struct view *view, struct wlr_box geometry)
return;
}
if (view->maximized != VIEW_AXIS_NONE) {
+ if (view->saved_decoration_state_valid) {
+ view->ssd_enabled = view->saved_ssd_enabled;
+ view->saved_decoration_state_valid = false;
+ }
set_maximized(view, VIEW_AXIS_NONE);
}
view_move_resize(view, geometry);
@@ -2492,6 +2504,7 @@ void
view_init(struct view *view)
{
assert(view);
+ view->saved_decoration_state_valid = false;
wl_signal_init(&view->events.new_app_id);
wl_signal_init(&view->events.new_title);
Arch Linux users can use my PKGBUILD. Bear in mind that this is working for the current Labwc version. I have no idea if I'll update the patch for future versions. My hopes are that the maintainers of Labwc implement this natively via a config option.