Commit graph

2528 commits

Author SHA1 Message Date
Johan Malm
3a61cd89dd theme: derive titlebar height from its objects
...including the new window.button.height
2024-10-08 20:04:05 +01:00
Johan Malm
2884f77b30 theme: remove titlebar.height option
This theme setting does not exist in Openbox spec and has just been an
additional 'knob' to tweak the height which is otherwise derived from the
sizes of the objects within it plus padding.
2024-10-08 20:04:05 +01:00
Johan Malm
0aa4cfe32d theme: add window.button.height
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.
2024-10-08 20:04:05 +01:00
Johan Malm
be18050479 xdg-shell: fix popup on wrong output 2024-10-08 07:34:25 +09:00
Johan Malm
5b3f90ed72
Merge pull request #2225 from jlindgren90/icon-scaling
Improve icon display especially at larger output scales
2024-10-07 22:16:34 +01:00
John Lindgren
36f754e662 icon-loader: update PNG and XPM loaders to use new buffer helper 2024-10-06 22:38:03 -04:00
John Lindgren
2e9b5886ce buffer: add buffer_convert_cairo_surface_for_icon()
Which handles:
 - conversion from other pixel formats to ARGB32
 - setting the logical size to the desired display size
 - downscaling very large images using CAIRO_FILTER_GOOD
2024-10-06 22:30:46 -04: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
John Lindgren
465aac5514 ssd: respect logical size when displaying window icon
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.
2024-10-06 21:29:40 -04:00
John Lindgren
ddfaae98ad icon-loader: load SVG icons at max scale of any usable output
- Add a new function to get the maximum scale of all usable outputs
- Pass the maximum output scale through to img_svg_load(), which
  ultimately calls cairo_surface_set_device_scale() before rendering
2024-10-06 21:24:34 -04:00
Hiroaki Yamamoto
a5d89a2e4c
xdg: take into account minimum window size for resizing (#2221)
This is especially relavant for <resize drawContents="no">.
2024-10-06 16:58:54 +01:00
John Lindgren
d2b161bdf8 buffer: reduce unnecessary painting to new cairo surfaces
Add buffer_adopt_cairo_surface(), which allows wrapping an existing
cairo image surface in a struct lab_data_buffer. This is useful when
loading PNGs since most will be loaded as ARGB32 already.

Fix a memory leak in the non-ARGB32 PNG case, where we do still need to
paint to a new image surface -- we were leaking the original surface.

Eliminate an unnecessary temporary image surface in SVG loading and just
render the SVG to the image surface held by the lab_data_buffer.

I also cleaned up and clarified the buffer API a bit:

- Add a pointer to the held cairo_surface_t (so we can still access it
  if there is no cairo_t).
- Remove the free_on_destroy bool (it was always true).
- Rename unscaled_width/height to logical_width/height and add an
  explanatory comment. It was unclear what "unscaled" meant.
- Rename buffer_create_wrap() to buffer_create_from_data().

This is laying groundwork for some more icon fixes I am working on
(making sure icons are loaded and rendered at the correct scale).
2024-10-06 16:51:14 +01:00
tokyo4j
328f873db3 theme: fix loading *-inactive.svg icons 2024-10-06 20:57:37 +09:00
John Lindgren
977d561695 icon-loader: fix a few more missing icons
By:
- stripping extensions from relative icon filenames (for example,
  gdmap.desktop has "Icon=gdmap_icon.png")
- using the WM_CLASS "instance" rather than "class" string, which
  is usually the same but lowercase
2024-10-05 21:01:55 +01:00
tokyo4j
c2a3a354db theme: refine the management of corner buttons
- 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.
2024-10-05 20:53:51 +01:00
tokyo4j
c413e65a20 xdg: fix crash on actions from menu opened by show_window_menu requests
Also removed a redundant line in show_menu() in action.c.
2024-10-05 07:40:09 +09:00
John Lindgren
b4bc6ffceb icon-loader: also match desktop entries StartupWMClass
GIMP for example sets its WM_CLASS to "gimp-2.10", which does not match
the "gimp.desktop" filename, but matches the StartupWMClass key listed
in it.

Thanks to @vyivel for the suggestion.
2024-10-04 22:25:37 +01:00
tokyo4j
eb8db30a86 build: allow disabling icon when libsfdo is installed system-wide 2024-10-04 20:29:32 +01:00
John Lindgren
45f3bde864 icon-loader: add a log handler for sfdo messages
Useful for debugging why an icon isn't being loaded.

v2: suggestions from @tokyo4j
2024-10-04 20:25:15 +01:00
tokyo4j
fb0c7a29c6 theme: draw hover overlay in the correct scale
The hover icon buffer on which the hover overlay is draw can be larger
than the button size when a large non-hover icon is provided by user. In
this case, we should scale up all the coorinates that are used to draw
the hover overlay. Before this commit, corner radius and padding.width
are not scaled correctly.

This commit fixes it by scaling the cairo context with cairo_scale()
when drawing the hover overlay.
2024-10-03 21:24:19 +01:00
tokyo4j
c06b86c345 theme: refactor rendering of rounded hover effect 2024-10-03 21:24:19 +01:00
John Lindgren
db3aab77fe ssd: limit icon size to ~85% of window_button_width
This ensures that the icon doesn't push right up to the window edge
(or left-aligned title) when using a large font or narrow button width.
In the default config (with 10pt font), it makes no difference since
the limiting factor on the icon size is the titlebar height anyway.

I spent way too much time over-thinking how to compute the padding.
I think 2px on each side is reasonable (and it should be equal on each
side), so window_button_width/10 (rounded down) should be fine.
Eventually the padding should probably be configurable anyway.
2024-10-03 21:17:21 +01:00
Weblate
f347408949 Translation updates from weblate
Co-authored-by: Dr. Ayhan YALÇINSOY <ayhanyalcinsoy@pisilinux.org>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/tr/
Translation: Labwc/labwc
2024-10-03 21:14:53 +01:00
Jens Peters
cf123dd78e
data: disable Inhibit D-BUS interface in xdg-portals configuration (#2205)
The GTK xdg-portal implementation, which is used as
the default behind the wlr xdg-portal implementation,
exposes the Inhibit interface even on a non-Gnome
session. Unfortunately this D-BUS interface does not
work on labwc.
By explicitly disabling this interface, firefox and may be
other applications are not tricked into using the
xdg-portal interface but use the Wayland IdleInhibit
protocol instead which labwc supports.
2024-10-02 21:32:47 +01:00
Johan Malm
c7983129d4 cosmic-workspaces: fix menu.c 2024-10-01 21:45:13 +01:00
Rick Calixte
5b774e6e99
Add labwc to XDG_CURRENT_DESKTOP to support a portals.conf (#1716)
The previous `UseIn` key was deprecated in xdg-desktop-portal 1.17/1.18.
It has been superceded by the portals.conf structure so that each
desktop can configure the precise desired structure for portals. In
addition, support was added to the Desktop Entry Specifications to
support a `DesktopNames` key that login managers will use to set
XDG_CURRENT_DESKTOP.

* [portals.conf
  Documentation](https://github.com/flatpak/xdg-desktop-portal/blob/main/doc/portals.conf.rst.in)
* [Example
  sway-portals.conf](https://salsa.debian.org/swaywm-team/sway/-/blob/debian/sid/debian/sway-portals.conf)
* [Desktop Entry
  Specifications](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html)

Ref: flatpak/xdg-desktop-portal#955
2024-10-01 21:33:45 +01: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
tokyo4j
1557cb774f cursor: prevent Drag mousebinds from running without button press
For `Drag` mousebinds, `pressed_in_context` is set by
`cursor_process_button_press()` and cleared by `cursor_process_motion()`
which runs actions bound to them. However, when `cursor_process_motion()`
is called while interactive move/resize, it doesn't clear
`pressed_in_context` due to the early-return and the `Drag` mousebinds are
unexpectedly executed on another call to `cursor_process_motion()` after
the interactive move/resize is finished by button release, even when the
button is not pressed.

So this commit fixes it by always clearing `pressed_in_context` on button
releases.
2024-10-01 21:26:19 +01:00
John Lindgren
452f45cd3d xdg: try to handle slow un-maximize with empty natural geometry better
In the case of an initially-maximized view which is taking a long time
to un-maximize (seen for example with Thunderbird on slow machines), we
may end up in handle_configure_timeout() with an empty pending geometry.
In that case we have no great options (we can't center the view since we
don't know the un-maximized size yet), so set a fallback position.

v2: check wlr_box_empty() before comparing pending and current

Fixes: #2191
2024-10-01 21:22:00 +01:00
tokyo4j
915d638f8a doc: update default value of <theme><titlebar><layout> 2024-10-01 15:11:43 +09:00
John Lindgren
c9e0a6e125 icon-loader: add a new loader for XPM icons, used by many legacy X11 apps
Adapted from gdk-pixbuf, see the original at:

  https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/gdk-pixbuf/io-xpm.c

rgb.txt is from X.org, see:

  https://gitlab.freedesktop.org/xorg/app/rgb/-/blob/master/rgb.txt

Differences from the gdk-pixbuf version:

- GdkPixbuf replaced with struct lab_data_buffer
- Progressive and in-memory loading code removed
- Two functions that had separate BSD copyright rewritten
- Stores colors as ARGB32 earlier in the decoding process for efficiency
- Limited to 1024x1024 px and 1024 colors to prevent abuse
- Uses struct buf to build strings, in place of manual g_new/g_realloc
- Uses xzalloc/xznew_n for other memory allocations
- Uses g_strlcpy in place of banned strcpy/strncpy/strncat
- Uses standard C types (int, bool, etc.) in place of the GLib ones
- Follows labwc coding style (whitespace, braces, letter case, etc.)
- Et cetera ...

v2: add Perl fixes from @domo141
2024-09-30 21:17:19 -04:00
John Lindgren
887ec70ba4 icon-loader: match more application icons via fuzzy match
Add fallback logic to match reverse-URL .desktop file names when
the app_id is just the base name (e.g. "thunderbird" ->
org.mozilla.Thunderbird.desktop).
2024-09-30 22:05:38 +01:00
Weblate
2f3cd205f3 Translation updates from weblate
Co-authored-by: Eric Migeon <weblate.tilux@spamgourmet.com>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/fr/
Translation: Labwc/labwc
2024-09-30 22:02:23 +01:00
John Lindgren
ce0ce2aae7 ssd: also add spacing between innermost button and title
Currently, left-aligned title text gets pushed right up to the window
icon with no spacing at all, which looks bad IMO.
2024-09-30 18:28:55 +01:00
tokyo4j
014d07651f xdg: fix de-synced SSD when shrinking Thunderbird window
On a slow mechine or heavy load, we sometimes see de-synced SSD with
Thunderbird windows when shrinking it. Here's how it happened:

1. Labwc sends a configure event.
2. The configure event timeouts and labwc resets view->{pending,current}
   with the old geometry.
3. Thunderbird updates the toplevel window geometry and the toplevel
   surface size, but not the subsurface size. Then it sends a commit.
4. Since now the committed window geometry and view->pending are
   different, the workaround for Qt apps is applied and the whole surface
   extent is set to view->current. Thus SSD stays in the old geometry.
5. Thunderbird finally updates the subsurface size.

So, this commit fixes this conflict between Thunderbird and the workaround
for Qt apps by using the toplevel surface size instead of the whole
surface extent to update view->current.
2024-09-30 10:19:54 +09:00
Johan Malm
3394f191a4 icon-loader: support absolute icon names 2024-09-28 12:38:18 +01:00
Johan Malm
be5472a840 icon-loader: refactor in preparation for supporting absolute icon names
No functional change intended.
2024-09-28 12:38:18 +01:00
Johan Malm
340733e494 ci: add libsfdo-devel for Void 2024-09-27 21:58:35 +01:00
Weblate
9b56cb6226 Translation updates from weblate
Co-authored-by: Giannis Antypas <gianni.antypas@gmail.com>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/el/
Translation: Labwc/labwc
2024-09-25 22:01:02 +01:00
tokyo4j
701679bae0 ssd: fix crash on app_id updates while the app is in fullscreen
`view->ssd_enabled && view->ssd == NULL` is possible during the client is
in fullscreen. So we need to check if `view->ssd` is NULL first in
`ssd_update_window_icon()`.
2024-09-25 21:44:33 +09:00
tokyo4j
a745f91169 ssd: support window icons
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.
2024-09-25 18:04:09 +09:00
Jens Peters
b9414d8b8d action: implicitely unmaximize when unsnapping
Co-authored-by: tokyo4j <hrak1529@gmail.com>
2024-09-25 17:59:10 +09:00
Jens Peters
694c5a7469 action: add UnSnap action
Same untiling behavior as ToggleSnapToEdge/Region,
but unconditionally.

Co-authored-by: tokyo4j <hrak1529@gmail.com>
2024-09-25 17:59:10 +09:00
Jens Peters
cb2e2c1016 action: add ToggleSnapToEdge/Region actions
Behaves identical like SnapToEdge and SnapToRegion, but
untiles the window when already being tiled to the given
region or direction.

Co-authored-by: tokyo4j <hrak1529@gmail.com>
2024-09-25 17:59:10 +09:00
Jens Peters
4fd7a8075c view: expose view_apply_natural_geometry()
Co-authored-by: tokyo4j <hrak1529@gmail.com>
2024-09-25 17:59:10 +09:00
Johan Malm
f1141c62d4 ci: disable debian build checks until dependencies can be met 2024-09-24 20:32:32 +01:00
Johan Malm
9d251a96b1 theme: fix incorrect default for <titlebar><showTitle> 2024-09-24 19:59:46 +01:00
Weblate
95bc420403 Translation updates from weblate
Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/uk/
Translation: Labwc/labwc
2024-09-24 19:49:30 +01:00
David Turner
ff012fa331 Don't detect edge-resizes in configure timeout
If a client times out responding to a configure request then the
handle_configure_timeout() callback is run.  This cleans up the pending
state and moves the view to the pending location, but keeps the current
size. The idea is to stop slow applications causing too much lag when
the user manipulates the window.  This callback used
view_impl_apply_geometry() to actually apply the changes.

view_impl_apply_geometry() contains some heuristics to detect if we're
resizing a window from the top, left, or top-left, and if so to do the
expected behaviour of keeping the window's bottom/right corner in the
same place.  However, that code was erroneously triggering in the case
when the user requests to change a window from maximized to fullscreen
but the client times out on the configure request.
handle_configure_timeout() decides to enact the movement of the window
but keep its size at the old size and tells view_impl_apply_geometry()
to do that.

The current view position and size is 0,64 1920x1016, the pending
position/size is 0,0 1920x1080, and the last committed size is
1920x1016.  Looking at the current and pending position and size, the
height changes while the bottom edge stays in the same place so this
looks like a top-edge-resize and view_impl_apply_geometry() decides to
keep the window's bottom edge in the same place while setting the
position according to the last-committed size.  This results in the
window staying at position 0,64 size 1920x1016 despite being marked as
fullscreen.

My solution to this is just to change handle_configure_timeout() to
directly change the view's position and call view_moved() if necessary.
The idea of handle_configure_timeout() is to action the window movement
now while discarding the size change, and let the size change take place
later on when the client catches up.  The logic of
view_impl_apply_geometry() doesn't make sense in this case so just avoid
it entirely.

Fixes #1922
2024-09-24 19:45:16 +01:00
Johan Malm
e5f60ce8a7 ci: use -Wno-expansion-to-defined to avoid Arch CI error
...with this warning message:

[100/161] Compiling C object labwc.p/src_button_button-svg.c.o
FAILED: labwc.p/src_button_button-svg.c.o
gcc -Ilabwc.p -I. -I.. -Iinclude -I../include -I/usr/include/wlroots-0.18 -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/lib/pkgconfig/../../include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O0 -g -DWLR_USE_UNSTABLE -Wundef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wstrict-prototypes -Wimplicit-fallthrough=2 -Wendif-labels -Wstrict-aliasing=2 -Woverflow -Wmissing-prototypes -Walloca -Wunused-macros -Wno-unused-parameter '-DLABWC_VERSION="0.8.0"' '-DGETTEXT_PACKAGE="labwc"' '-DLOCALEDIR="/usr/local/share/locale"' -pthread -MD -MQ labwc.p/src_button_button-svg.c.o -MF labwc.p/src_button_button-svg.c.o.d -o labwc.p/src_button_button-svg.c.o -c ../src/button/button-svg.c
In file included from ../src/button/button-svg.c:7:
/usr/lib/pkgconfig/../../include/librsvg-2.0/librsvg/rsvg.h:1331:1: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
 1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
      | ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
2024-09-24 07:15:13 +09:00