48
bamf_xutils_get_window_hint (Window xid, const char *atom_name, Atom type)
48
bamf_xutils_get_string_window_hint_and_type (Window xid, const char *atom_name,
49
gchar** return_hint, Atom* return_type)
57
56
unsigned char *buffer;
58
gboolean close_display = FALSE;
60
g_return_val_if_fail ((xid != 0), NULL);
61
g_return_val_if_fail (atom_name, NULL);
57
gboolean close_display;
63
*return_type = AnyPropertyType;
65
g_return_if_fail (xid != 0);
66
g_return_if_fail (return_hint || return_type);
68
close_display = FALSE;
63
69
XDisplay = get_xdisplay (&close_display);
67
73
g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC);
71
atom = XInternAtom (XDisplay, atom_name, FALSE);
73
int result = XGetWindowProperty (XDisplay,
77
int result = XGetWindowProperty (XDisplay, xid,
78
gdk_x11_get_xatom_by_name (atom_name),
79
0, G_MAXINT, False, AnyPropertyType,
80
&type, &format, &numItems,
81
&bytesAfter, &buffer);
87
84
XCloseDisplay (XDisplay);
89
86
if (result == Success && numItems > 0)
91
if (buffer && buffer[0] != '\0')
92
hint = g_strdup ((char*) buffer);
91
if (return_hint && buffer && buffer[0] != '\0')
93
if (type == XA_STRING || type == gdk_x11_get_xatom_by_name("UTF8_STRING"))
94
*return_hint = g_strdup ((char*) buffer);
102
bamf_xutils_get_string_window_hint (Window xid, const char *atom_name)
105
bamf_xutils_get_string_window_hint_and_type (xid, atom_name, &hint, NULL);
101
bamf_xutils_set_window_hint (Window xid, const char *atom_name, Atom type, const char *data)
111
bamf_xutils_set_string_window_hint (Window xid, const char *atom_name, const char *value)
103
113
Display *XDisplay;
104
115
gboolean close_display = FALSE;
106
117
g_return_if_fail (xid != 0);
107
118
g_return_if_fail (atom_name);
108
g_return_if_fail (data);
119
g_return_if_fail (value);
110
121
XDisplay = get_xdisplay (&close_display);
118
XChangeProperty (XDisplay,
120
XInternAtom (XDisplay,
126
(unsigned char *) data,
129
bamf_xutils_get_string_window_hint_and_type (xid, atom_name, NULL, &type);
131
if (type == AnyPropertyType)
135
else if (type != XA_STRING && type != gdk_x11_get_xatom_by_name("UTF8_STRING"))
137
g_error ("Impossible to set the atom %s on Window %lu", atom_name, xid);
141
XChangeProperty (XDisplay, xid, gdk_x11_get_xatom_by_name (atom_name),
142
type, 8, PropModeReplace, (unsigned char *) value, strlen (value));
129
144
if (close_display)
130
145
XCloseDisplay (XDisplay);