This doesn't change any behaviors.
Attaching LAB_NODE_NONE node-descriptor to ssd->tree looks strange, this
patch uses new LAB_NODE_SSD_ROOT instead. The node-descriptor attached to
ssd->tree is needed for get_cursor_context() to detect cursor hovering on
borders/extents.
I also updated get_cursor_context() to make my intent clearer.
struct ssd_part and struct node_descriptor seem to have essentially the
same purpose: tag a wlr_scene_node with some extra data indicating what
we're using it for.
Also, as with enum ssd_part_type (now lab_node_type), ssd_part is used
for several types of nodes that are not part of SSD.
So instead of the current chaining (node_descriptor -> ssd_part), let's
flatten/unify the two structs.
In detail:
- First, merge node_descriptor_type into lab_node_type.
- Add a separate view pointer in node_descriptor, since in the case of
SSD buttons we need separate view and button data pointers.
- Rename ssd_part_button to simply ssd_button. It no longer contains
an ssd_part as base.
- Add node_try_ssd_button_from_node() which replaces
node_ssd_part_from_node() + button_try_from_ssd_part().
- Factor out ssd_button_free() to be called in node descriptor destroy.
- Finally, get_cursor_context() needs a little reorganization to handle
the unified structs.
Overall, this simplifies the code a bit, and in my opinion makes it
easier to understand. No functional change intended.
ssd_part_type contains several node types that are not actually part of
server-side decorations (ROOT, MENU, OSD, etc.)
Rename it accordingly and move it to a common location, along with some
related conversion/comparison functions.
Our codebase for ssd scenes has grown with a lot of technical debts:
- We needed to call `ssd_get_part()` everywhere to get the scene node of a
ssd part. We then needed to cast it to `wlr_scene_rect` and
`wlr_scene_buffer`. This bloated our codebase and even blocked
duplicated button types in `<titlebar><layout>`.
- `ssd_get_part_type()` was a dirty hack. It compared parent, grandparent
and grandgrandparent of a node with each subtree in the ssd to get the
part type of the node.
To resolve this issues, this commit changes how ssd scenes are managed:
- Access scene rects and scene buffers just as a member of `struct ssd`.
- `ssd_part` is now a attachment to a scene node that can be accessed via
node_descriptor->data, with a new node-descriptor type
`LAB_NODE_DESC_SSD_PART`. `LAB_NODE_DESC_SSD_BUTTON` is unified into it.
Now the scene graph under ssd->tree looks like below. The parentheses
indicate the type of ssd_part attached to the node:
ssd->tree (LAB_SSD_NONE)
+--titlebar (LAB_SSD_PART_TITLEBAR)
| +--inactive
| | +--background bar
| | +--left corner
| | +--right corner
| | +--title (LAB_SSD_PART_TITLE)
| | +--iconify button (LAB_SSD_BUTTON_ICONIFY)
| | | +--normal close icon image
| | | +--hovered close icon image
| | | +--...
| | +--window icon (LAB_SSD_BUTTON_WINDOW_ICON)
| | | +--window icon image
| | +--...
| +--active
| +--...
+--border
| +--inactive
| | +--top
| | +--...
| +--active
| +--top
| +--...
+--shadow
| +--inactive
| | +--top
| | +--...
| +--active
| +--top
| +--...
+--extents
+--top
+--...
When hovering on SSD, `get_cursor_context()` traverses this scene node
from the leaf. If it finds a `ssd_part` attached to the node, it returns
`ssd_part_type` that represents the resizing direction, button types or
`Title`/`Titlebar`.
Before this commit, nothing was rendered in window icon button if the
application doesn't set its app_id (e.g. nested kwin_wayland). This was my
oversight in dc474521.
This commit makes sure fallback icon (set via <theme><fallbackAppIcon>)
by removing ssd->state.app_id and the early-return in
ssd_update_window_icon(). This doesn't affect performance because
scaled_icon_buffer caches app_id and scaled_icon_buffer_set_app_id() does
nothing when a duplicated app_id is passed.
Before this commit, there was a use-after-free bug on Reconfigure:
- theme_finish() destroys lab_imgs for titlebar icons
- For some reason, undecorate() calls _create_buffer() in
scaled-img-buffer.c, which calls img_render() on a destroyed lab_img.
So in this commit, the lifetime of lab_img is expanded to when the
scaled_img_buffers referencing it are all destroyed. This is achieved by
calling lab_img_copy() when setting a lab_img to scaled_img_buffer and
calling lab_img_destroy() when clearing a lab_img.
Now that scaled_img_buffer.img are always different, lab_img_equal() is
added to compare the content of scaled_img_buffer.img.
- fix that icons for normal/hovered/rounded buttons are not placed
exactly the same position
- fix blurry window button icons in scaled outputs
This commit introduces lab_img and scaled_img_buffer and uses them for
rendering icons in the window titlebar. Now the process of rendering
button icons are split into 2 phases: loading with lab_img_load() and
creating scene-nodes for them with scaled_img_buffer_create(). This
might incur some additional overhead since we no longer preload icon
textures, but the rendering of icon only happens for the first window
as backing buffers are shared and the overhead won't be noticeable.
This commit also simplifies the process of centering icon buffer in the
button, by creating icon buffers in a fixed geometry via
lab_img_render().
window.button.{height,width} determine the space allocated for buttons.
Buttons can be smaller than this size and will then just be center aligned
within the allocated space. However, buttons will be clamped at this size
to prevent them from going outside of the allocated space.
get_scale_box() was using the raw pixel size of the icon buffer for
layout, which caused the icon to be incorrectly scaled up if the buffer
scale was >1.
- The builtin hover effect is now unrounded when the window is tiled.
- All the corner button icons including ones provided by the user are
now rounded when the window is not tiled.
- Fixed the bug that the window menu button as a fallback of the window
icon is not correctly rounded.
The default `titleLayout` is updated to `icon:iconify,max,close` which
replaces the window menu button with the window icon.
When the icon file is not found or could not be loaded, the window menu
icon as before is shown.
The icon theme can be selected with `<theme><icon>`.
This commit adds libsfdo as an optional dependency. `-Dicon=disabled` can
be passsed to `meson setup` command in order to disable window icon, in
which case the window icon is always replaced with a window menu button.
This fixes the ugly look of SSD for tiny windows (e.g. "xterm -geometry
1x1") due to the early return in `ssd_update_geometry()`. Now SSDs are
rendered correctly for those windows by hiding some buttons when the
window width is smaller than the total width of buttons. Additionally for
windows smaller than (button width)*2, the corners are un-rounded so a
small titlebar can be rendered with a scene-rect.
Add optional drop-shadows to windows using server-side decoration.
Shadows can be enabled/disabled rc.xml and their appearance configured
in themerc. The default is no shadows to preserve current behaviour.
The shadows are drawn in fixed corner and edge buffers shared between
all windows, the edges are scaled to size depending on the size of each
window. Two sets of buffers are used to give the different appearances
for active and inactive windows. I use separate corner/edge buffers for
a few reasons:
- It avoids needing to store a separate large shadow buffer per window
- It avoids needing to redraw the shadows when the window is being
resized
- Compositing the shadows onto the desktop should be faster as there are
overall fewer pixels to blend, and scaling up the edge buffers only
requires reading a tiny buffer which is then replicated.
This fixes an issue detected by the static analyzer.
It currently is not a real bug but it could become
one in the future if `add_toggled_icon()` is called
before `add_scene_button()`.
Rather than having `add_toggled_icon()` go through
the list, find the root button and then fetch its
node descriptor just supply the button as argument.
With the new keepBorder option enabled, the
ToggleDecorations action now has 3 states:
- the first time only disables the titlebar
- the second time disables the whole SSD
- the third time enables the whole SSD again
When the keepBorder action is disabled, the old 2-state
behavior is restored, e.g. the ToggleDecorations action
only toggles between on and off.
Fixes#813
Made all header files to have LABWC_ prefix in include guard identifers.
Converted from __LABWC_ in 35 include/ files.
Converted from __LAB_ in 5 include/ files.
Added LABWC prefix to 3 include/ files.
Added include guards to 3 include/ files.
The double underscores were removed since according to C standard
those "are always reserved for any use".