Skip to content

feat: Wayland detection, text sizing fix, signal handling#314

Open
mg-dev25 wants to merge 1 commit intov1cont:masterfrom
Mgdev-25:feat/wayland-text-signals
Open

feat: Wayland detection, text sizing fix, signal handling#314
mg-dev25 wants to merge 1 commit intov1cont:masterfrom
Mgdev-25:feat/wayland-text-signals

Conversation

@mg-dev25
Copy link
Contributor

Combined improvements

This commit addresses multiple related issues:

1. Wayland backend detection and warnings

Addresses #159, #261, #158, #216, #49

On Wayland, X11-only features now show clear warnings instead of failing silently:

WARNING: --mouse option is not supported on Wayland.
WARNING: Window positioning (--posx/--posy) is controlled by the Wayland compositor.

2. Text sizing fix

Fixes #107, #140, #32, #297, #300

Dialog windows no longer grow excessively large when --text contains long content with --wrap enabled. The --width and --geometry options now properly constrain text.

3. Graceful signal handling

Addresses #181

SIGTERM/SIGINT now trigger graceful exit instead of abrupt termination.

Files changed

  • src/yad.h: Function declarations
  • src/main.c: Detection logic, text sizing, signal handling
  • src/cpicker.c, src/print.c: Wayland warnings
  • src/notebook.c, src/paned.c: Timeout messages

Test

# Text sizing
yad --text="Long text" --wrap --width=400

# Wayland warning
GDK_BACKEND=wayland yad --text="Test" --posx=100

# Signal handling
yad --form --field="Test" &
kill -TERM $!

Core improvements to YAD:

Wayland Detection:
- Add yad_check_x11() and yad_check_wayland() functions
- Detect display backend at startup using GDK macros
- Warn when using X11-only features on Wayland:
  * --posx/--posy positioning (compositor-controlled on Wayland)
  * --mouse positioning (not supported on Wayland)
  * --plug mode (requires X11)
  * notebook/paned/notification modes (X11-only)
  * color picker (screen capture requires X11 or portal)
- Provide guidance for GDK_BACKEND=x11 workaround

Text Sizing Fix:
- Add text_size_allocate_cb() callback for proper line wrapping
- Set width request on size-allocate to enable text wrap
- Constrain label max_width_chars when --width specified
- Connect size-allocate signal when --geometry or --width used
- Prevents windows from becoming excessively large with long text

Signal Handling:
- Add sa_term() handler for SIGTERM and SIGINT
- Enable graceful shutdown instead of immediate termination
- Properly exit with CANCEL response (1) on signals

Footer Widget Support:
- Retrieve footer widget from dialog data (set by form.c)
- Pack into button box as secondary, non-homogeneous child
- Enables @footer@ form fields feature

Fixes v1cont#107, v1cont#140, v1cont#32, v1cont#297, v1cont#300
Addresses v1cont#159, v1cont#261, v1cont#158, v1cont#216, v1cont#49, v1cont#181
@v1cont
Copy link
Owner

v1cont commented Dec 1, 2025

hi and thank you. but can you split your pr into a separate parts which fixes different issues?

and some comments:

  • in signal handling more reasonable will be use an existing sa_usr2() handler instead of adding the same
  • for wayland detection the variable is_x11 is more than enough. no need to add a new variable with the almost same functionality and getter/setter functions for them

mg-dev25 added a commit to Mgdev-25/yad that referenced this pull request Dec 2, 2025
Per maintainer feedback on PR v1cont#312:
- AppIndicator should be a separate dialog type, not combined with notification
- Code follows html.c pattern: separate file conditionally compiled

Changes:
- Add src/appindicator.c with yad_appindicator_run()
- Add --indicator option for StatusNotifier/AppIndicator support
- Add AM_CONDITIONAL([APPINDICATOR], ...) in configure.ac
- Add if APPINDICATOR block in Makefile.am
- Add YAD_MODE_APPINDICATOR enum value

Also incorporates PR v1cont#314 maintainer feedback:
- Remove is_wayland variable (use !is_x11 instead)
- Remove yad_check_wayland() (use !yad_check_x11() instead)
- Remove sa_term() handler (use existing sa_usr2() for SIGTERM/SIGINT)

Fixes v1cont#172, v1cont#86, v1cont#246, v1cont#244 (AppIndicator)
Addresses v1cont#159, v1cont#261, v1cont#158 (Wayland)
Addresses v1cont#181 (Signal handling)
mg-dev25 added a commit to Mgdev-25/yad that referenced this pull request Dec 2, 2025
Per maintainer feedback on PR v1cont#314:
- No need for is_wayland/yad_check_wayland when is_x11 already exists
- Use !yad_check_x11() for Wayland detection
- Update cpicker.c and print.c to use simplified API
@mg-dev25
Copy link
Contributor Author

mg-dev25 commented Dec 2, 2025

Closing per maintainer feedback to split into separate atomic changes.

The Wayland API simplification (using existing is_x11 instead of adding redundant is_wayland) will be submitted as a separate PR if still needed.

The signal handling improvements (using existing sa_usr2 instead of new sa_term) have been incorporated into the updated PR #312.

Thanks for the feedback!

@mg-dev25 mg-dev25 closed this Dec 2, 2025
mg-dev25 added a commit to Mgdev-25/yad that referenced this pull request Dec 2, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
mg-dev25 added a commit to Mgdev-25/yad that referenced this pull request Dec 2, 2025
Adds handlers for SIGTERM and SIGINT signals using the existing sa_usr2()
handler, which cleanly exits with YAD_RESPONSE_CANCEL.

This allows scripts to properly terminate YAD dialogs when interrupted
(Ctrl+C) or when receiving SIGTERM from process managers.

Follows feedback from PR v1cont#314 about reusing existing handlers instead of
creating new ones.
mg-dev25 added a commit to Mgdev-25/yad that referenced this pull request Dec 2, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
@mg-dev25 mg-dev25 deleted the feat/wayland-text-signals branch December 7, 2025 10:52
@mg-dev25 mg-dev25 restored the feat/wayland-text-signals branch December 7, 2025 23:18
@mg-dev25 mg-dev25 reopened this Dec 7, 2025
mg-dev25 added a commit to mg-dev25/yad that referenced this pull request Dec 10, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
mg-dev25 added a commit to mg-dev25/yad that referenced this pull request Dec 10, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
mg-dev25 added a commit to mg-dev25/yad that referenced this pull request Dec 10, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
mg-dev25 added a commit to mg-dev25/yad that referenced this pull request Dec 10, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
mg-dev25 added a commit to mg-dev25/yad that referenced this pull request Dec 10, 2025
Adds a simple API for checking if running on X11 display server.
Used by cpicker.c and print.c to warn about or skip X11-only features.

Changes:
- Add yad_check_x11() in main.c returning the is_x11 variable
- Add declaration in yad.h
- cpicker.c: Warn and skip color picker on non-X11 (needs screen grab)
- print.c: Skip mouse positioning on Wayland (compositor-controlled)

Addresses feedback from PR v1cont#314 about simplifying Wayland detection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YAD 7.3: Dialog height too large

2 participants