plasma-wm: support the application_menu signal

This allows displaying the menus of apps that export them via KDE's org_kde_kwin_appmenu_manager protocol.
This commit is contained in:
Kondor Dániel
2025-01-19 17:46:08 +01:00
parent de158714c4
commit 7178b96404

View File

@@ -63,6 +63,8 @@ struct _GldiPlasmaWindowActor {
unsigned int pid; // pid of the process associated with this window
unsigned int sigkill_timeout; // set to an event source if the user requested to kill this process
unsigned int cap_and_state; // capabilites and state that is not stored elsewhere
char *service_name; // appmenu service name
char *object_path; // appmenu object path
};
typedef struct _GldiPlasmaWindowActor GldiPlasmaWindowActor;
@@ -217,6 +219,13 @@ static void _kill (GldiWindowActor *actor)
pactor->sigkill_timeout = g_timeout_add (2000, _send_sigkill, pactor);
}
static void _get_menu_address (GldiWindowActor *actor, char **service_name, char **object_path)
{
GldiPlasmaWindowActor *pactor = (GldiPlasmaWindowActor*)actor;
if (service_name) *service_name = pactor->service_name;
if (object_path) *object_path = pactor->object_path;
}
/** callbacks **/
static void _gldi_toplevel_title_cb (void *data, G_GNUC_UNUSED pwhandle *handle, const char *title)
@@ -332,10 +341,15 @@ static void _gldi_toplevel_pid_changed_cb (void* data, G_GNUC_UNUSED pwhandle *h
if (pactor) pactor->pid = pid;
}
static void _gldi_toplevel_application_menu_cb (G_GNUC_UNUSED void* data, G_GNUC_UNUSED pwhandle *handle,
G_GNUC_UNUSED const char *service_name, G_GNUC_UNUSED const char *object_path)
static void _gldi_toplevel_application_menu_cb (void* data, G_GNUC_UNUSED pwhandle *handle,
const char *service_name, const char *object_path)
{
/* don't care */
GldiPlasmaWindowActor *pactor = (GldiPlasmaWindowActor*)data;
g_free (pactor->service_name);
g_free (pactor->object_path);
pactor->service_name = (service_name && *service_name) ? g_strdup (service_name) : NULL;
pactor->object_path = (object_path && *object_path ) ? g_strdup (object_path) : NULL;
cd_debug ("got app menu address: %s %s", service_name, object_path);
}
static struct org_kde_plasma_window_listener gldi_toplevel_handle_interface = {
@@ -454,6 +468,8 @@ void _reset_object (GldiObject* obj)
g_hash_table_remove (s_hIDTable, pactor->uuid);
g_free (pactor->uuid);
org_kde_plasma_window_destroy((pwhandle*)pactor->wactor.handle);
g_free (pactor->service_name);
g_free (pactor->object_path);
}
}
@@ -489,6 +505,7 @@ static void gldi_plasma_window_manager_init ()
wmb.set_sticky = _set_sticky;
wmb.can_minimize_maximize_close = _can_minimize_maximize_close;
// wmb.get_id = _get_id;
wmb.get_menu_address = _get_menu_address;
wmb.pick_window = gldi_wayland_wm_pick_window;
wmb.flags = GINT_TO_POINTER (GLDI_WM_NO_VIEWPORT_OVERLAP | GLDI_WM_GEOM_REL_TO_VIEWPORT | GLDI_WM_HAVE_WINDOW_GEOMETRY | GLDI_WM_HAVE_WORKSPACES);
wmb.name = "plasma";