mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
url-mode: add support for XDG activation when opening URLs
First, add a ‘token’ argument to spawn(). When non-NULL, spawn() will set the ‘XDG_ACTIVATION_TOKEN’ environment variable in the forked process. If DISPLAY is non-NULL, we also set DESKTOP_STARTUP_ID, for compatibility with X11 applications. Note that failing to set either of these environment variables are considered non-fatal - i.e. we ignore failures. Next, add a helper function, wayl_get_activation_token(), to generate an XDG activation token, and call a user-provided callback when it’s ‘done (since token generation is asynchronous). This function takes an optional ‘seat’ and ‘serial’ arguments - when both are non-NULL/zero, we set the serial on the token. ‘win’ is a required argument, used to set the surface on the token. Re-write wayl_win_set_urgent() to use the new helper function. Finally, rewrite activate_url() to first try to get an activation token (and spawn the URL launcher in the token callback). If that fails, or if we don’t have XDG activation support, spawn the URL launcher immediately (like before this patch). Closes #1058
This commit is contained in:
parent
bd8dd9ff7e
commit
ea1aac88db
9 changed files with 209 additions and 69 deletions
24
wayland.h
24
wayland.h
|
|
@ -295,6 +295,22 @@ struct wl_url {
|
|||
|
||||
enum csd_mode {CSD_UNKNOWN, CSD_NO, CSD_YES};
|
||||
|
||||
#if defined(HAVE_XDG_ACTIVATION)
|
||||
typedef void (*activation_token_cb_t)(const char *token, void *data);
|
||||
|
||||
/*
|
||||
* This context holds data used both in the token::done callback, and
|
||||
* when cleaning up created, by not-yet-done tokens in
|
||||
* wayl_win_destroy().
|
||||
*/
|
||||
struct xdg_activation_token_context {
|
||||
struct wl_window *win; /* Need for win->xdg_tokens */
|
||||
struct xdg_activation_token_v1 *xdg_token; /* Used to match token in done() */
|
||||
activation_token_cb_t cb; /* User provided callback */
|
||||
void *cb_data; /* Callback user pointer */
|
||||
};
|
||||
#endif
|
||||
|
||||
struct wayland;
|
||||
struct wl_window {
|
||||
struct terminal *term;
|
||||
|
|
@ -302,7 +318,7 @@ struct wl_window {
|
|||
struct xdg_surface *xdg_surface;
|
||||
struct xdg_toplevel *xdg_toplevel;
|
||||
#if defined(HAVE_XDG_ACTIVATION)
|
||||
struct xdg_activation_token_v1 *xdg_activation_token;
|
||||
tll(struct xdg_activation_token_context *) xdg_tokens;
|
||||
#endif
|
||||
|
||||
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
||||
|
|
@ -417,3 +433,9 @@ bool wayl_win_subsurface_new_with_custom_parent(
|
|||
struct wl_window *win, struct wl_surface *parent,
|
||||
struct wl_surf_subsurf *surf, bool allow_pointer_input);
|
||||
void wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf);
|
||||
|
||||
#if defined(HAVE_XDG_ACTIVATION)
|
||||
bool wayl_get_activation_token(
|
||||
struct wayland *wayl, struct seat *seat, uint32_t serial,
|
||||
struct wl_window *win, activation_token_cb_t cb, void *cb_data);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue