summaryrefslogtreecommitdiff
path: root/plugins/xsettings/wm-common.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2018-02-05 15:22:57 -0500
committerraveit65 <[email protected]>2018-02-06 17:19:42 +0100
commitdaa7f5881476e1b09ee81ec21a4dd40180f69441 (patch)
tree8a23ee840ac3b510abc275b349f2f31f2c69dda3 /plugins/xsettings/wm-common.c
parent16137a4d4c51fae1d577ea4c534af4a89f5c1558 (diff)
downloadmate-settings-daemon-daa7f5881476e1b09ee81ec21a4dd40180f69441.tar.bz2
mate-settings-daemon-daa7f5881476e1b09ee81ec21a4dd40180f69441.tar.xz
Load xsettings during initialization phase
Also set QT_* env variables during init, and restart marco, mate-panel, toggle desktop icons when changing scales
Diffstat (limited to 'plugins/xsettings/wm-common.c')
-rw-r--r--plugins/xsettings/wm-common.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/plugins/xsettings/wm-common.c b/plugins/xsettings/wm-common.c
new file mode 100644
index 0000000..ccb9629
--- /dev/null
+++ b/plugins/xsettings/wm-common.c
@@ -0,0 +1,108 @@
+#include <X11/Xatom.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdk.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+#include "wm-common.h"
+
+/* Our WM Window */
+static Window wm_window = None;
+
+static char *
+wm_common_get_window_manager_property (Atom atom)
+{
+ Atom utf8_string, type;
+ int result;
+ char *retval;
+ int format;
+ gulong nitems;
+ gulong bytes_after;
+ gchar *val;
+
+ if (wm_window == None)
+ return NULL;
+
+ utf8_string = gdk_x11_get_xatom_by_name ("UTF8_STRING");
+
+ gdk_error_trap_push ();
+
+ val = NULL;
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+ wm_window,
+ atom,
+ 0, G_MAXLONG,
+ False, utf8_string,
+ &type, &format, &nitems,
+ &bytes_after, (guchar **) &val);
+
+ if (gdk_error_trap_pop () || result != Success ||
+ type != utf8_string || format != 8 || nitems == 0 ||
+ !g_utf8_validate (val, nitems, NULL))
+ {
+ retval = NULL;
+ }
+ else
+ {
+ retval = g_strndup (val, nitems);
+ }
+
+ if (val)
+ XFree (val);
+
+ return retval;
+}
+
+char*
+wm_common_get_current_window_manager (void)
+{
+ Atom atom = gdk_x11_get_xatom_by_name ("_NET_WM_NAME");
+ char *result;
+
+ result = wm_common_get_window_manager_property (atom);
+ if (result)
+ return result;
+ else
+ return g_strdup (WM_COMMON_UNKNOWN);
+}
+
+static void
+update_wm_window (void)
+{
+ Window *xwindow;
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW (),
+ gdk_x11_get_xatom_by_name ("_NET_SUPPORTING_WM_CHECK"),
+ 0, G_MAXLONG, False, XA_WINDOW, &type, &format,
+ &nitems, &bytes_after, (guchar **) &xwindow);
+
+ if (type != XA_WINDOW)
+ {
+ wm_window = None;
+ return;
+ }
+
+ gdk_error_trap_push ();
+ XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), *xwindow, StructureNotifyMask | PropertyChangeMask);
+ XSync (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False);
+
+ if (gdk_error_trap_pop ())
+ {
+ XFree (xwindow);
+ wm_window = None;
+ return;
+ }
+
+ wm_window = *xwindow;
+ XFree (xwindow);
+}
+
+void
+wm_common_update_window ()
+{
+ update_wm_window();
+}