[gnome-panel] xstuff.c: remove old unused code



commit 22f3fdb4483c8c14a49489223731c31dc1e53bef
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun May 25 14:55:30 2014 +0300

    xstuff.c: remove old unused code

 gnome-panel/xstuff.c |  313 --------------------------------------------------
 gnome-panel/xstuff.h |   22 ----
 2 files changed, 0 insertions(+), 335 deletions(-)
---
diff --git a/gnome-panel/xstuff.c b/gnome-panel/xstuff.c
index 4f8b605..101f71e 100644
--- a/gnome-panel/xstuff.c
+++ b/gnome-panel/xstuff.c
@@ -21,7 +21,6 @@
 #include <gtk/gtk.h>
 
 #include <X11/Xlib.h>
-#include <X11/Xatom.h>
 
 #include "panel-enums.h"
 #include "xstuff.h"
@@ -30,252 +29,6 @@ static int (* xstuff_old_xio_error_handler) (Display *) = NULL;
 static int (* xstuff_old_x_error_handler)   (Display *, XErrorEvent *);
 static gboolean xstuff_display_is_dead = FALSE;
 
-static Atom
-panel_atom_get (const char *atom_name)
-{
-       static GHashTable *atom_hash;
-       Display           *xdisplay;
-       Atom               retval;
-
-       g_return_val_if_fail (atom_name != NULL, None);
-
-       xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
-       if (!atom_hash)
-               atom_hash = g_hash_table_new_full (
-                               g_str_hash, g_str_equal, g_free, NULL);
-
-       retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
-       if (!retval) {
-               retval = XInternAtom (xdisplay, atom_name, FALSE);
-
-               if (retval != None)
-                       g_hash_table_insert (atom_hash, g_strdup (atom_name),
-                                            GUINT_TO_POINTER (retval));
-       }
-
-       return retval;
-}
-
-/* Stolen from deskguide */
-static gpointer
-get_typed_property_data (Display *xdisplay,
-                        Window   xwindow,
-                        Atom     property,
-                        Atom     requested_type,
-                        gint    *size_p,
-                        guint    expected_format)
-{
-  static const guint prop_buffer_lengh = 1024 * 1024;
-  unsigned char *prop_data = NULL;
-  Atom type_returned = 0;
-  unsigned long nitems_return = 0, bytes_after_return = 0;
-  int format_returned = 0;
-  gpointer data = NULL;
-  gboolean abort = FALSE;
-
-  g_return_val_if_fail (size_p != NULL, NULL);
-  *size_p = 0;
-
-  gdk_error_trap_push ();
-
-  abort = XGetWindowProperty (xdisplay,
-                             xwindow,
-                             property,
-                             0, prop_buffer_lengh,
-                             False,
-                             requested_type,
-                             &type_returned, &format_returned,
-                             &nitems_return,
-                             &bytes_after_return,
-                             &prop_data) != Success;
-  if (gdk_error_trap_pop () ||
-      type_returned == None)
-    abort++;
-  if (!abort &&
-      requested_type != AnyPropertyType &&
-      requested_type != type_returned)
-    {
-      g_warning ("%s(): Property has wrong type, probably on crack", G_STRFUNC);
-      abort++;
-    }
-  if (!abort && bytes_after_return)
-    {
-      g_warning ("%s(): Eeek, property has more than %u bytes, stored on harddisk?",
-                G_STRFUNC, prop_buffer_lengh);
-      abort++;
-    }
-  if (!abort && expected_format && expected_format != format_returned)
-    {
-      g_warning ("%s(): Expected format (%u) unmatched (%d), programmer was drunk?",
-                G_STRFUNC, expected_format, format_returned);
-      abort++;
-    }
-  if (!abort && prop_data && nitems_return && format_returned)
-    {
-      switch (format_returned)
-       {
-       case 32:
-         *size_p = nitems_return * 4;
-         if (sizeof (gulong) == 8)
-           {
-             guint32 i, *mem = g_malloc0 (*size_p + 1);
-             gulong *prop_longs = (gulong*) prop_data;
-
-             for (i = 0; i < *size_p / 4; i++)
-               mem[i] = prop_longs[i];
-             data = mem;
-           }
-         break;
-       case 16:
-         *size_p = nitems_return * 2;
-         break;
-       case 8:
-         *size_p = nitems_return;
-         break;
-       default:
-         g_warning ("Unknown property data format with %d bits (extraterrestrial?)",
-                    format_returned);
-         break;
-       }
-      if (!data && *size_p)
-       {
-         guint8 *mem = g_malloc (*size_p + 1);
-
-         memcpy (mem, prop_data, *size_p);
-         mem[*size_p] = 0;
-         data = mem;
-       }
-    }
-
-  if (prop_data)
-    XFree (prop_data);
-  
-  return data;
-}
-
-gboolean
-xstuff_is_compliant_wm (void)
-{
-       Display  *xdisplay;
-       Window    root_window;
-       gpointer  data;
-       int       size;
-
-       xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-       root_window = GDK_WINDOW_XID (gdk_get_default_root_window ());
-
-        /* FIXME this is totally broken; should be using
-         * gdk_net_wm_supports() on particular hints when we rely
-         * on those particular hints
-         */
-       data = get_typed_property_data (
-                       xdisplay, root_window,
-                       panel_atom_get ("_NET_SUPPORTED"),
-                       XA_ATOM, &size, 32);
-
-       if (!data)
-               return FALSE;
-
-       /* Actually checks for some of these */
-       g_free (data);
-       return TRUE;
-}
-
-/* This is such a broken stupid function. */   
-void
-xstuff_set_pos_size (GdkWindow *window, int x, int y, int w, int h)
-{
-       XSizeHints size_hints;
-       int old_x, old_y, old_w, old_h;
-
-       old_x = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "xstuff-cached-x"));
-       old_y = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "xstuff-cached-y"));
-       old_w = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "xstuff-cached-w"));
-       old_h = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "xstuff-cached-h"));
-
-       if (x == old_x && y == old_y && w == old_w && h == old_h)
-               return;
-
-       /* Do not add USPosition / USSize here, fix the damn WM */
-       size_hints.flags = PPosition | PSize | PMaxSize | PMinSize;
-       size_hints.x = 0; /* window managers aren't supposed to and  */
-       size_hints.y = 0; /* don't use these fields */
-       size_hints.width = w;
-       size_hints.height = h;
-       size_hints.min_width = w;
-               size_hints.min_height = h;
-       size_hints.max_width = w;
-       size_hints.max_height = h;
-  
-       gdk_error_trap_push ();
-
-       XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
-                          GDK_WINDOW_XID (window),
-                          &size_hints);
-
-       gdk_window_move_resize (window, x, y, w, h);
-
-       gdk_error_trap_pop_ignored ();
-
-       g_object_set_data (G_OBJECT (window), "xstuff-cached-x", GINT_TO_POINTER (x));
-       g_object_set_data (G_OBJECT (window), "xstuff-cached-y", GINT_TO_POINTER (y));
-       g_object_set_data (G_OBJECT (window), "xstuff-cached-w", GINT_TO_POINTER (w));
-       g_object_set_data (G_OBJECT (window), "xstuff-cached-h", GINT_TO_POINTER (h));
-}
-
-void
-xstuff_set_wmspec_dock_hints (GdkWindow *window,
-                             gboolean autohide)
-{
-        Atom atoms [2] = { None, None };
-        
-       if (!autohide)
-               atoms [0] = panel_atom_get ("_NET_WM_WINDOW_TYPE_DOCK");
-       else {
-               atoms [0] = panel_atom_get ("_GNOME_WINDOW_TYPE_AUTOHIDE_PANEL");
-               atoms [1] = panel_atom_get ("_NET_WM_WINDOW_TYPE_DOCK");
-       }
-
-        XChangeProperty (GDK_WINDOW_XDISPLAY (window),
-                         GDK_WINDOW_XID (window),
-                        panel_atom_get ("_NET_WM_WINDOW_TYPE"),
-                         XA_ATOM, 32, PropModeReplace,
-                         (unsigned char *) atoms, 
-                        autohide ? 2 : 1);
-}
-
-void
-xstuff_set_wmspec_strut (GdkWindow *window,
-                        int        left,
-                        int        right,
-                        int        top,
-                        int        bottom)
-{
-       long vals [4];
-        
-       vals [0] = left;
-       vals [1] = right;
-       vals [2] = top;
-       vals [3] = bottom;
-
-        XChangeProperty (GDK_WINDOW_XDISPLAY (window),
-                         GDK_WINDOW_XID (window),
-                        panel_atom_get ("_NET_WM_STRUT"),
-                         XA_CARDINAL, 32, PropModeReplace,
-                         (unsigned char *) vals, 4);
-}
-
-void
-xstuff_delete_property (GdkWindow *window, const char *name)
-{
-       Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
-       Window   xwindow  = GDK_WINDOW_XID (window);
-
-        XDeleteProperty (xdisplay, xwindow,
-                        panel_atom_get (name));
-}
-
 /* Zoom animation */
 #define MINIATURIZE_ANIMATION_FRAMES_Z   1
 #define MINIATURIZE_ANIMATION_STEPS_Z    6
@@ -619,72 +372,6 @@ xstuff_zoom_animate (GtkWidget *widget,
                g_object_unref (pixbuf);
 }
 
-int
-xstuff_get_current_workspace (GdkScreen *screen)
-{
-       Window  root_window;
-       Atom    type = None;
-       gulong  nitems;
-       gulong  bytes_after;
-       gulong *num;
-       int     format;
-       int     result;
-       int     retval;
-
-       root_window = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
-
-       gdk_error_trap_push ();
-       result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen)),
-                                    root_window,
-                                    panel_atom_get ("_NET_CURRENT_DESKTOP"),
-                                    0, G_MAXLONG,
-                                    False, XA_CARDINAL, &type, &format, &nitems,
-                                    &bytes_after, (gpointer) &num);
-       if (gdk_error_trap_pop () || result != Success)
-               return -1;
- 
-       if (type != XA_CARDINAL) {
-               XFree (num);
-               return -1;
-       }
-
-       retval = *num;
- 
-       XFree (num);
-
-       return retval;
-}
-
-void
-xstuff_grab_key_on_all_screens (int      keycode,
-                               guint    modifiers,
-                               gboolean grab)
-{
-       GdkDisplay *display;
-       int         n_screens;
-       int         i;
-
-       display   = gdk_display_get_default ();
-       n_screens = gdk_display_get_n_screens (display);
-
-       for (i = 0; i < n_screens; i++) {
-               GdkWindow *root;
-
-               root = gdk_screen_get_root_window (
-                               gdk_display_get_screen (display, i));
-
-               if (grab)
-                       XGrabKey (gdk_x11_display_get_xdisplay (display),
-                                 keycode, modifiers,
-                                 GDK_WINDOW_XID (root),
-                                 True, GrabModeAsync, GrabModeAsync);
-               else
-                       XUngrabKey (gdk_x11_display_get_xdisplay (display),
-                                   keycode, modifiers,
-                                   GDK_WINDOW_XID (root));
-       }
-}
-
 static int
 xstuff_xio_error_handler (Display *display)
 {
diff --git a/gnome-panel/xstuff.h b/gnome-panel/xstuff.h
index e441f18..507a1dd 100644
--- a/gnome-panel/xstuff.h
+++ b/gnome-panel/xstuff.h
@@ -4,33 +4,11 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
-void xstuff_delete_property            (GdkWindow *window,
-                                        const char *name);
-gboolean xstuff_is_compliant_wm                (void);
-
-void xstuff_unsetup_desktop_area       (void);
-void xstuff_set_pos_size               (GdkWindow *window,
-                                        int x, int y,
-                                        int w, int h);
-void xstuff_set_wmspec_dock_hints       (GdkWindow *window,
-                                        gboolean autohide);
-void xstuff_set_wmspec_strut           (GdkWindow *window,
-                                        int left,
-                                        int right,
-                                        int top,
-                                        int bottom);
-
 void xstuff_zoom_animate                (GtkWidget        *widget,
                                         GdkPixbuf        *pixbuf,
                                         PanelOrientation  orientation,
                                         GdkRectangle     *opt_src_rect);
 
-int  xstuff_get_current_workspace       (GdkScreen *screen);
-
-void xstuff_grab_key_on_all_screens     (int      keycode,
-                                        guint    modifiers,
-                                        gboolean grab);
-
 gboolean xstuff_is_display_dead         (void);
 
 void xstuff_init                        (void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]