mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-13 07:03:54 +00:00
Add D-Bus notification driver
Use the core and portal notification implementations to dispatch system notifications.
This commit is contained in:
1581
src/notification/unix/SDL_dbusnotification.c
Normal file
1581
src/notification/unix/SDL_dbusnotification.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,8 @@
|
||||
#include "SDL_waylandutil.h"
|
||||
#include "xdg-activation-v1-client-protocol.h"
|
||||
|
||||
#include "../../notification/SDL_notification_c.h"
|
||||
|
||||
#define WAYLAND_HANDLE_PREFIX "wayland:"
|
||||
|
||||
typedef struct Wayland_ActivationParams
|
||||
@@ -66,6 +68,9 @@ bool Wayland_GetActivationTokenForExport(SDL_VideoDevice *_this, char **token, c
|
||||
}
|
||||
|
||||
const char *xdg_activation_token = SDL_getenv("XDG_ACTIVATION_TOKEN");
|
||||
if (!xdg_activation_token) {
|
||||
xdg_activation_token = SDL_GetNotificationActivationToken();
|
||||
}
|
||||
if (xdg_activation_token) {
|
||||
*token = SDL_strdup(xdg_activation_token);
|
||||
if (!*token) {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../core/unix/SDL_appid.h"
|
||||
#include "../../notification/SDL_notification_c.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
#include "SDL_waylandevents_c.h"
|
||||
#include "SDL_waylandmouse.h"
|
||||
@@ -2564,6 +2565,29 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_
|
||||
|
||||
void Wayland_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoData *viddata = _this->internal;
|
||||
SDL_WindowData *wind = window->internal;
|
||||
|
||||
if (viddata->activation_manager) {
|
||||
/* Check for an activation token, in case the window is being
|
||||
* raised in response to a system notification.
|
||||
*
|
||||
* Note that we don't check for empty strings, as that is still
|
||||
* considered a valid activation token!
|
||||
*/
|
||||
const char *activation_token = SDL_GetNotificationActivationToken();
|
||||
if (activation_token) {
|
||||
xdg_activation_v1_activate(viddata->activation_manager,
|
||||
activation_token,
|
||||
wind->surface);
|
||||
|
||||
// Clear this variable, per the protocol's request.
|
||||
SDL_unsetenv_unsafe("XDG_ACTIVATION_TOKEN");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// No token? Try to activate the window via an event serial.
|
||||
Wayland_activate_window(_this->internal, window->internal, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ static SDL_NotificationAction actions[] = {
|
||||
{ .button = { SDL_NOTIFICATION_ACTION_TYPE_BUTTON, "action_1", "OK" } },
|
||||
{ .button = { SDL_NOTIFICATION_ACTION_TYPE_BUTTON, "action_2", "Cancel" } }
|
||||
};
|
||||
static SDL_NotificationAction *action_array[SDL_arraysize(actions) + 1];
|
||||
|
||||
static bool transient;
|
||||
static int sound;
|
||||
|
||||
Reference in New Issue
Block a user