Commit graph

132 commits

Author SHA1 Message Date
Consolatis
38a1a9bbbc Disable all output leasing due to a wlroots UAF 2025-07-06 19:59:43 +01:00
Consolatis
448c61a295 scaled-icon-buffer: reduce the need for updates 2025-06-27 14:05:42 +02:00
Consolatis
acd2a23f1b scaled-icon-buffer: add icon priority
Co-Authored-By: tokyo4j <hrak1529@gmail.com>
2025-06-27 14:05:42 +02:00
John Lindgren
54b236e027 common/font: add scaled_font_buffer_create_for_titlebar()
Co-authored-by: tokyo4j <hrak1529@gmail.com>
2025-06-18 15:48:24 -04:00
John Lindgren
3ca7adace0 common/graphic-helpers: add a few cairo pattern helpers 2025-06-18 15:48:24 -04:00
John Lindgren
c4bae87c04 common/graphic-helpers: adopt lookup_named_color from xpm parser 2025-06-18 15:48:24 -04:00
tokyo4j
97ce4131bb Replace scaled_rect_buffer with lab_scene_rect
This fixes the gap between menu items and the menu border in an output
with a fractional scale due to the semantic gap between cairo and
wlroots's position-independent scene renderer.
2025-06-10 06:03:03 +09:00
tokyo4j
ffd400503e Replace multi_rect with lab_scene_rect
lab_scene_rect accepts the arbitrary number of borders and a background
color.
2025-06-10 06:03:03 +09:00
tokyo4j
fb077c0095 Support xdg-toplevel-icon protocol
This patch also changes the semantics of scaled_icon_buffer: rather than
calling scaled_icon_buffer_set_app_id() every time an app_id is set, we
can now call scaled_icon_buffer_set_view() just once so that multiple
scaled_icon_buffers bound to a window are automatically updated when an
app_id is set or new icon is set via xdg-toplevel-icon-v1.
2025-06-07 02:12:56 +09:00
tokyo4j
7969aa267e common/box: drop box_contains() 2025-05-21 13:55:59 +02:00
Johan Malm
58d22d05e2 font: use PangoStyle enum 2025-04-23 20:20:29 +01:00
Johan Malm
94ead35227 font: use PangoWeight enum
No change in functionality.

Suggested-by: @spl237
2025-04-23 20:20:29 +01:00
Simon Long
6a810ad762
Add support for all Pango font weight options 2025-04-23 18:03:02 +02:00
tokyo4j
cfbe54e67a box: add box_to_fbox() 2025-02-22 20:38:03 +09:00
tokyo4j
dc474521ab ssd: dynamically look up window icons in titlebar for output scales
by introducing scaled_icon_buffer.
2025-01-26 11:46:32 +01:00
tokyo4j
5e29f79258 string-helpers: add str_equal() 2025-01-25 07:27:21 +09:00
tokyo4j
45f73b58a1 img: remove padding_x from lab_img_render()
padding_x in lab_img_render() was just to make sure window icons in the
titlebar doesn't get too close to adjacent buttons and it didn't felt
clean. To remove it from lab_img, this commit changes the size of window
icon buffers from (window.button.width)x(window.button.height) to
(window.button.width * 0.8)x(window.button.height) and horizontally
slide it by (window.button.width * 0.1) to keep the horizontal padding.

Note that the size of the hitbox for a window icon is kept the same and
nothing is changed from user's perspective.
2025-01-25 07:27:21 +09:00
tokyo4j
925360ffba scaled-scene-buffer: block sharing of buffers created before reconfigure
This prevents potential bugs that buffers created by scaled_scene_buffers
before Reconfigure are reused by other newly created scaled_scene_buffers.

This is targeted for scaled_icon_buffer whose buffer creation depends on
server->sfdo.
2025-01-13 18:24:10 +09:00
tokyo4j
c49f577c6b scaled-scene-buffer: store all the scaled_scene_buffers in a single list 2025-01-13 18:24:10 +09:00
Consolatis
6496773fd1 scaled-scene-buffer: use outputs_update signal
This fixes an issue with buffers not updating when an output is configured
for a new scale. It also supports windows being on more than 2 outputs at
once and in general simplifies the code.
2025-01-11 07:29:46 +01:00
tinyboxvk
1a6dd845a2 Fix typos
Signed-off-by: tinyboxvk <13696594+tinyboxvk@users.noreply.github.com>
2025-01-09 06:59:57 +00:00
Consolatis
10c6abb36a string-helpers: add str_endswith_ignore_case() 2025-01-09 00:57:06 +09:00
Consolatis
b58f8dab21 scaled_{img,scene}_buffer: add architecture graph 2025-01-06 04:39:09 +01:00
tokyo4j
70fb713874 img: fix UAF on Reconfigure by refcounting
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.
2025-01-04 09:10:02 +01:00
Johan Malm
6457cbccda Make enum three_state public 2024-12-31 16:23:47 +00:00
tokyo4j
16dbdc64e5 ssd: rework titlebar button rendering
- 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().
2024-12-23 18:11:32 +09:00
Johan Malm
2446c46069 string-helpers.c: add str_starts_with() 2024-12-18 18:32:25 +00:00
tokyo4j
5db953aa89 scaled-scene-buffer: reduce unnecessary renderings
Prior to this commit, a backing buffer with scale 1 was always created for
a scaled_scene_buffer before showing it, and backing buffers for specific
scales were created on output_enter events.

This commit removes this redundant re-renderings by calling
wlr_scene_buffer_set_dest_size() upon scaled_scene_buffer creation just to
receive output_enter events and delaying the first rendering to the first
output_enter event.

I needed to add font_get_buffer_size() to obtain the size of a font buffer
without actually creating it.
2024-12-18 17:21:29 +09:00
tokyo4j
01032ef3bd font: remove arrow character from font buffer
Arrow signs are specific to submenu items, so they would be more natural
to be handled in menu.c rather than accepting "arrow" in
font_buffer_create().

Also I allowed non-positive numbers for max_width in font_buffer_create(),
in which case the natural font width is used as the buffer width.
2024-12-14 20:09:53 +00:00
Johan Malm
8e3d5784a3 docs: simplify description of shell wildcard patterns
...to align with glob(7) language

Reported-by: @vyivel
2024-12-01 20:17:04 +01:00
tokyo4j
c48324975d buffer: always set buffer->{cairo,surface} for simplification 2024-11-28 18:56:03 +09:00
tokyo4j
12cae9c7ee Add scaled_rect_buffer
scaled_rect_buffer is an implementation of scaled_scene_buffer and shows
an auto-scaling bordered rectangle. This is intended for menu borders,
but can be also useful for other elements like window switcher items.

We will support rounded corners for scaled_rect_buffer in the future.
2024-11-25 19:41:07 +00:00
tokyo4j
c893878aca scaled-scene-buffer: implement buffer sharing mechanism
Implementers can define impl->equal() which compares two
scaled-scene-buffers so that buffers are not allocated for visually
duplicated scaled-scene-buffers.

Currently this mechanism isn't applied for scaled-font-buffers since we
haven't defined impl->equal() for it.
2024-11-21 20:31:41 +00:00
tokyo4j
f071431266 common/list: add WL_LIST_INIT() macro 2024-11-21 20:31:41 +00:00
Consolatis
a4204d3335 common/mem.h: introduce xstrdup_replace() 2024-11-16 22:13:17 +00:00
Andrew J. Hesford
2b877d2293 config/rcxml.c: fix parsing of three-state query parameters 2024-10-30 21:53:23 -04:00
tokyo4j
e0848da70d key-state.c: generalize set operations 2024-10-13 20:45:16 +01:00
John Lindgren
22e50aa4e2 common/box: add box_fit_within()
Factor out common math from ssd's get_scale_box() for use elsewhere.
2024-10-06 21:30:33 -04:00
Johan Malm
d18e67eea8
Merge pull request #2030 from Consolatis/wip/cosmic_workspaces
Initial implementation of cosmic-workspace-unstable-v1
2024-10-01 21:31:04 +01:00
Orfeas
dda47a5e14 action: make "FocusOutput" behave like "MoveToOutput" 2024-08-24 14:59:42 -04:00
droc12345
8fda9968e6
menu: add title theme options (#2097)
Add theme options `menu.title.text.color` and `menu.title.text.justify`.

Add font place MenuHeader: `<font place="MenuHeader">`

Add `Oblique` font style

```
<theme>
  <font>
    <slant>Oblique</slant>
  </font>
</theme>
```
2024-08-21 18:27:07 +01:00
Johan Malm
6564e1bc8d buf: add buf_add_fmt() 2024-08-21 16:09:44 +02:00
Consolatis
a9daaa05be common/array.h: add array_add() helper 2024-08-03 18:25:23 +02:00
tokyo4j
46ec513630 view: implement cascade placement policy
Adds following settings:
<placement>
  <policy>cascade</policy>
  <cascadeOffset x="40" y="30" />
</placement>

"Cascade" policy places a new window at the center of the screen like
"center" policy, but possibly shifts its position to bottom-right so the
new window doesn't cover existing windows.

The algorithm is copied from KWin's implementation:
df9f8f8346/src/placement.cpp (L589)

Also added some helper functions to manipulate `wlr_box`.
2024-07-20 08:59:46 +01:00
Consolatis
45b197b8a4 magnifier: fix flickering on simultaneous gamma changes
Gamma changes take another code path and thus did not
render the magnifier. This patch consalidates both
code paths and therefore also renders the magnifier on
gamma changes.

Fixes: #1905
2024-06-29 23:36:41 +02:00
tokyo4j
23b96ad2a6 Replace _ with - in source file names 2024-05-22 07:10:51 +01:00
Hiroaki Yamamoto
d64e3915a3
Fix some header includes detected by clangd
There were some missing headers like <stddef.h> for `NULL`, <wayland-util.h>
for `wl_link` and <stdbool.h> for `true`/`false`.

Also this commit fixes that `labwc.h` and `ime.h` included each other.
2024-04-21 21:58:57 +02:00
John Lindgren
a8f98cb90b common/buf: rename buf->buf to buf->data 2024-04-18 07:00:23 +01:00
John Lindgren
0573f16693 common: remove buf_init(), add BUF_INIT and buf_move()
Add a BUF_INIT macro, which makes it easier to initialize a struct buf
to an empty string (without a heap allocation).

Add buf_move() to move the contents of one struct buf to another (the
source is reset to BUF_INIT, analogous to C++ move-assignment).

Use buf_reset() instead of directly calling `free(s->buf)` since the
internal buf may not always be allocated by malloc() now.
2024-04-18 07:00:23 +01:00
Johan Malm
c841a25acf Add -S|--session <command> option
...to start <command> on startup and to terminate the compositor when
<command> exits.

This is useful for session management as it allows the session client (for
example `lxqt-session`) to terminate labwc - be exiting itself.

Under X, xinit starts the server and keeps it alive for as long as
lxqt-session runs. Thus either the session client starts the Window
Manager, or the Window Manager can be launched independently first.  On
Wayland, the Compositor is both Display Server and Window Manager, so the
described session management mechanisms do not work because the Compositor
needs to be running before the session can function.

As some session clients support both X11 and Wayland, this command line
option avoids re-writes and fragmentation.

Co-authored-by: @Consolatis
2024-04-14 13:05:25 +02:00