Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for GTK3 builds in Wayland sessions #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/pasystray.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <glib.h>
#include <gtk/gtk.h>
#if GTK_CHECK_VERSION(3,0,0) && defined(GDK_WINDOWING_X11)
#include <gdk/gdkx.h>
#endif

#include "pasystray.h"
#include "options.h"
Expand All @@ -35,11 +38,15 @@

static GMainLoop* loop;
static menu_infos_t* mis;
gboolean gdkisx11 = FALSE;

int main(int argc, char *argv[])
{
GOptionEntry* options = get_options();
GError *error = NULL;
#if GTK_CHECK_VERSION(3,10,0) && !defined(HAVE_APPINDICATOR)
gdk_set_allowed_backends("x11");
#endif
gtk_init_with_args(&argc, &argv, NULL, options, NULL, &error);
if(error)
{
Expand Down Expand Up @@ -76,8 +83,14 @@ void init(settings_t* settings)
avahi_start(mis);

#ifdef HAVE_X11
if (settings->key_grabbing)
key_grabber_grab_keys(mis);
#if GTK_CHECK_VERSION(3,0,0)
gdkisx11 = GDK_IS_X11_DISPLAY(gdk_display_get_default());
#else
gdkisx11 = TRUE;
#endif
if (settings->key_grabbing && gdkisx11)
key_grabber_grab_keys(mis);

#endif
}

Expand All @@ -89,8 +102,8 @@ void quit()
void destroy(settings_t* settings)
{
#ifdef HAVE_X11
if (settings->key_grabbing)
key_grabber_ungrab_keys(mis);
if (settings->key_grabbing && gdkisx11)
key_grabber_ungrab_keys(mis);
#endif

pulseaudio_destroy();
Expand Down
9 changes: 9 additions & 0 deletions src/x11-property.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ char* x11_property_get(const char* key){ return NULL; }

static Display* display = NULL;
static Window window;
extern gboolean gdkisx11;

void x11_property_init()
{
if (!gdkisx11)
return;
display = gdk_x11_get_default_xdisplay();
window = RootWindow(display, 0);
}

void x11_property_set(const char* key, const char* value)
{
if (!gdkisx11)
return;
g_debug("[x11-property] setting '%s' to '%s'", key, value);

Atom atom = XInternAtom(display, key, False);
Expand All @@ -57,6 +62,8 @@ void x11_property_set(const char* key, const char* value)

void x11_property_del(const char* key)
{
if (!gdkisx11)
return;
g_debug("[x11-property] deleting '%s'", key);

Atom atom = XInternAtom(display, key, False);
Expand All @@ -65,6 +72,8 @@ void x11_property_del(const char* key)

char* x11_property_get(const char* key)
{
if (!gdkisx11)
return NULL;
Atom property = XInternAtom(display, key, False);
Atom actual_type;
int actual_format;
Expand Down
Loading