~azzar1/bamf/manually-complete-sn

« back to all changes in this revision

Viewing changes to src/bamf-xutils.c

  • Committer: CI Train Bot
  • Author(s): Andrea Azzarone
  • Date: 2016-04-15 11:57:23 UTC
  • mfrom: (629.1.11 bamf-export-actions-menu)
  • Revision ID: ci-train-bot@canonical.com-20160415115723-1f7bwhsiem1gqt4x
BamfWindow: Export window actions menu using dbusmenu Fixes: #1570812
Approved by: Marco Trevisan (Treviño)

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
      XGetErrorText (dpy, error_code, tmp, sizeof (tmp) - 1);
58
58
      tmp[sizeof (tmp) - 1] = '\0';
59
59
 
60
 
      g_warning("Got an X error: %s\n", tmp);
 
60
      g_warning ("Got an X error: %s\n", tmp);
61
61
 
62
62
      return TRUE;
63
63
    }
103
103
                                   &type, &format, &numItems,
104
104
                                   &bytesAfter, &buffer);
105
105
 
 
106
  gboolean x_error = gdk_error_trap_pop_and_print (XDisplay);
 
107
 
106
108
  if (close_display)
107
109
    XCloseDisplay (XDisplay);
108
110
 
109
 
  if (result == Success && numItems > 0 && !gdk_error_trap_pop_and_print (XDisplay))
 
111
  if (x_error)
 
112
    {
 
113
      XFree (buffer);
 
114
      return;
 
115
    }
 
116
 
 
117
  if (result == Success && numItems > 0)
110
118
    {
111
119
      if (return_type)
112
120
        *return_type = type;
113
121
 
114
122
      if (return_hint && buffer && buffer[0] != '\0')
115
123
        {
116
 
          if (type == XA_STRING || type == gdk_x11_get_xatom_by_name("UTF8_STRING"))
 
124
          if (type == XA_STRING || type == gdk_x11_get_xatom_by_name ("UTF8_STRING"))
117
125
            *return_hint = g_strdup ((char*) buffer);
118
126
        }
119
127
 
155
163
    {
156
164
      type = XA_STRING;
157
165
    }
158
 
  else if (type != XA_STRING && type != gdk_x11_get_xatom_by_name("UTF8_STRING"))
 
166
  else if (type != XA_STRING && type != gdk_x11_get_xatom_by_name ("UTF8_STRING"))
159
167
    {
160
168
      g_error ("Impossible to set the atom %s on Window %lu", atom_name, xid);
161
169
 
177
185
}
178
186
 
179
187
void
 
188
bamf_xutils_unset_window_hint (Window xid, const char *atom_name)
 
189
{
 
190
  Display *XDisplay;
 
191
  gboolean close_display = FALSE;
 
192
 
 
193
  g_return_if_fail (xid != 0);
 
194
  g_return_if_fail (atom_name);
 
195
 
 
196
  XDisplay = get_xdisplay (&close_display);
 
197
 
 
198
  if (!XDisplay)
 
199
  {
 
200
    g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC);
 
201
    return;
 
202
  }
 
203
 
 
204
  gdk_error_trap_push ();
 
205
  XDeleteProperty (XDisplay, xid, gdk_x11_get_xatom_by_name (atom_name));
 
206
  gdk_error_trap_pop_and_print (XDisplay);
 
207
 
 
208
  if (close_display)
 
209
    XCloseDisplay (XDisplay);
 
210
}
 
211
 
 
212
void
180
213
bamf_xutils_get_window_class_hints (Window xid, char **class_instance_name, char **class_name)
181
214
{
182
215
  Display *xdisplay;
196
229
 
197
230
  gdk_error_trap_push ();
198
231
 
199
 
  XGetClassHint(xdisplay, xid, &class_hint);
 
232
  XGetClassHint (xdisplay, xid, &class_hint);
200
233
 
201
234
  if (!gdk_error_trap_pop_and_print (xdisplay))
202
235
    {