[Xfce4-commits] [xfce/xfwm4] 05/05: Code cleanup

noreply at xfce.org noreply at xfce.org
Sat Jan 24 22:41:09 CET 2015


This is an automated email from the git hooks/post-receive script.

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit 7cd4fdfe4c4b7dd38530cfc1299c2a3f23ea0656
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Sat Jan 24 22:37:12 2015 +0100

    Code cleanup
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/client.c     |    5 +---
 src/compositor.c |    3 ++-
 src/cycle.c      |    8 +++----
 src/events.c     |    4 +---
 src/hints.c      |    3 ++-
 src/hints.h      |    5 ++++
 src/icons.c      |   67 +++++++++++++++++++++++++++---------------------------
 src/icons.h      |   10 ++++----
 src/moveresize.c |   18 +++------------
 src/tabwin.c     |    6 +----
 src/xsync.c      |    1 -
 11 files changed, 56 insertions(+), 74 deletions(-)

diff --git a/src/client.c b/src/client.c
index af90e03..74dc65f 100644
--- a/src/client.c
+++ b/src/client.c
@@ -1410,7 +1410,6 @@ static void
 clientUpdateIconPix (Client *c)
 {
     ScreenInfo *screen_info;
-    DisplayInfo *display_info;
     gint size;
     GdkPixbuf *icon;
     int i;
@@ -1421,8 +1420,6 @@ clientUpdateIconPix (Client *c)
     TRACE ("entering clientUpdateIconPix for \"%s\" (0x%lx)", c->name, c->window);
 
     screen_info = c->screen_info;
-    display_info = screen_info->display_info;
-
     for (i = 0; i < STATE_TOGGLED; i++)
     {
         xfwmPixmapFree (&c->appmenu[i]);
@@ -1510,7 +1507,7 @@ clientSaveSizePos (Client *c)
 gboolean
 clientRestoreSizePos (Client *c)
 {
-    g_return_if_fail (c != NULL);
+    g_return_val_if_fail (c != NULL, FALSE);
 
     if (FLAG_TEST (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS))
     {
diff --git a/src/compositor.c b/src/compositor.c
index fba8dc5..0c23164 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -18,7 +18,7 @@
 
         xcompmgr - (c) 2003 Keith Packard
         metacity - (c) 2003, 2004 Red Hat, Inc.
-        xfwm4    - (c) 2005-2014 Olivier Fourdan
+        xfwm4    - (c) 2005-2015 Olivier Fourdan
 
 */
 
@@ -26,6 +26,7 @@
 #include "config.h"
 #endif
 
+#include <sys/ioctl.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
diff --git a/src/cycle.c b/src/cycle.c
index 717fd8d..eb32a86 100644
--- a/src/cycle.c
+++ b/src/cycle.c
@@ -246,7 +246,7 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
     eventFilterStatus status;
     KeyCode cancel, left, right, up, down;
     int key, modifiers;
-    gboolean key_pressed, cycling, gone;
+    gboolean cycling, gone;
     GList *li;
 
     TRACE ("entering clientCycleEventFilter");
@@ -437,7 +437,6 @@ clientCycle (Client * c, XKeyEvent * ev)
     DisplayInfo *display_info;
     ClientCycleData passdata;
     GList *client_list, *selected;
-    gboolean g1, g2;
     int key, modifier;
 
     g_return_if_fail (c != NULL);
@@ -482,10 +481,9 @@ clientCycle (Client * c, XKeyEvent * ev)
         return;
     }
 
-    g1 = myScreenGrabKeyboard (screen_info, ev->time);
-    g2 = myScreenGrabPointer (screen_info, TRUE, NoEventMask, None, ev->time);
+    myScreenGrabPointer (screen_info, TRUE, NoEventMask, None, ev->time);
     /* Grabbing the pointer may fail e.g. if the user is doing a drag'n drop */
-    if (!g1)
+    if (!myScreenGrabKeyboard (screen_info, ev->time))
     {
         TRACE ("grab failed in clientCycle");
 
diff --git a/src/events.c b/src/events.c
index 193f163..dfa6c70 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1374,11 +1374,10 @@ handleConfigureRequest (DisplayInfo *display_info, XConfigureRequestEvent * ev)
 static eventFilterStatus
 handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
 {
-    static guint32 lastresist = CurrentTime;
     ScreenInfo *screen_info;
     Client *c;
     int b;
-    gboolean warp_pointer, need_redraw;
+    gboolean need_redraw;
 
     /* See http://rfc-ref.org/RFC-TEXTS/1013/chapter12.html for details */
 
@@ -1393,7 +1392,6 @@ handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
 
     TRACE ("EnterNotify on window (0x%lx)", ev->window);
 
-    warp_pointer = FALSE;
     need_redraw = FALSE;
     c = myDisplayGetClientFromWindow (display_info, ev->window, SEARCH_FRAME | SEARCH_BUTTON);
     if (c)
diff --git a/src/hints.c b/src/hints.c
index b365d01..d955ac1 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -477,7 +477,8 @@ gboolean
 getCardinalList (DisplayInfo *display_info, Window w, int atom_id, unsigned long **cardinals_p, int *n_cardinals_p)
 {
     Atom type;
-    int i, format;
+    int format;
+    unsigned int i;
     unsigned long n_cardinals;
     unsigned long bytes_after;
     unsigned char *data;
diff --git a/src/hints.h b/src/hints.h
index 4648a3d..48cd814 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -205,6 +205,11 @@ void                     initNetDesktopInfo                     (DisplayInfo *,
                                                                  int,
                                                                  int,
                                                                  int);
+void                     setNetDesktopInfo                      (DisplayInfo *,
+                                                                 Window,
+                                                                 int,
+                                                                 int,
+                                                                 int);
 void                     setUTF8StringHint                      (DisplayInfo *,
                                                                  Window,
                                                                  int,
diff --git a/src/icons.c b/src/icons.c
index 259ad71..1105107 100644
--- a/src/icons.c
+++ b/src/icons.c
@@ -42,10 +42,10 @@
 #include "hints.h"
 
 static void
-downsize_ratio (int *width, int *height, int dest_w, int dest_h)
+downsize_ratio (guint *width, guint *height, guint dest_w, guint dest_h)
 {
     gdouble ratio;
-    int size;
+    guint size;
 
     g_return_if_fail (width != NULL);
     g_return_if_fail (height != NULL);
@@ -55,14 +55,14 @@ downsize_ratio (int *width, int *height, int dest_w, int dest_h)
     if (*width > *height)
     {
         ratio = ((gdouble) *width) / size;
-        *width = (int) size;
-        *height = (int) (((gdouble) *height) / ratio);
+        *width = (guint) size;
+        *height = (guint) (((gdouble) *height) / ratio);
     }
     else
     {
         ratio = ((gdouble) *height) / size;
-        *height = (int) size;
-        *width = (int) (((gdouble) *width) / ratio);
+        *height = (guint) size;
+        *width = (guint) (((gdouble) *width) / ratio);
     }
 }
 
@@ -70,7 +70,7 @@ downsize_ratio (int *width, int *height, int dest_w, int dest_h)
  * create a GdkPixbuf from inline data and scale it to a given size
  */
 static GdkPixbuf *
-inline_icon_at_size (const guint8 *data, int width, int height)
+inline_icon_at_size (const guint8 *data, guint width, guint height)
 {
     GdkPixbuf *base;
 
@@ -79,14 +79,15 @@ inline_icon_at_size (const guint8 *data, int width, int height)
     g_return_val_if_fail (base, NULL);
 
     if ((width <= 0 || height <= 0) ||
-        (gdk_pixbuf_get_width (base) == width && gdk_pixbuf_get_height (base) == height))
+        ((guint) gdk_pixbuf_get_width (base) == width &&
+         (guint) gdk_pixbuf_get_height (base) == height))
     {
         return base;
     }
     else
     {
         GdkPixbuf *scaled;
-        int w, h;
+        guint w, h;
 
         w = gdk_pixbuf_get_width (base);
         h = gdk_pixbuf_get_height (base);
@@ -101,9 +102,9 @@ inline_icon_at_size (const guint8 *data, int width, int height)
 
 
 static gboolean
-find_largest_sizes (gulong * data, gulong nitems, int *width, int *height)
+find_largest_sizes (gulong * data, gulong nitems, guint *width, guint *height)
 {
-    int w, h;
+    guint w, h;
 
     *width = 0;
     *height = 0;
@@ -134,13 +135,13 @@ find_largest_sizes (gulong * data, gulong nitems, int *width, int *height)
 }
 
 static gboolean
-find_best_size (gulong * data, gulong nitems, int ideal_width, int ideal_height,
-                int *width, int *height, gulong ** start)
+find_best_size (gulong * data, gulong nitems, gint ideal_width, gint ideal_height,
+                guint *width, guint *height, gulong ** start)
 {
     gulong *best_start;
-    int ideal_size;
-    int w, h, best_size, this_size;
-    int best_w, best_h, max_width, max_height;
+    guint ideal_size;
+    guint w, h, best_size, this_size;
+    guint best_w, best_h, max_width, max_height;
 
     *width = 0;
     *height = 0;
@@ -234,12 +235,12 @@ find_best_size (gulong * data, gulong nitems, int ideal_width, int ideal_height,
 }
 
 static void
-argbdata_to_pixdata (gulong * argb_data, int len, guchar ** pixdata)
+argbdata_to_pixdata (gulong * argb_data, guint len, guchar ** pixdata)
 {
     guchar *p;
     guint argb;
     guint rgba;
-    int i;
+    guint i;
 
     *pixdata = g_new (guchar, len * 4);
     p = *pixdata;
@@ -260,13 +261,13 @@ argbdata_to_pixdata (gulong * argb_data, int len, guchar ** pixdata)
 }
 
 static gboolean
-read_rgb_icon (DisplayInfo *display_info, Window window, int ideal_width, int ideal_height,
-               int *width, int *height, guchar ** pixdata)
+read_rgb_icon (DisplayInfo *display_info, Window window, guint ideal_width, guint ideal_height,
+               guint *width, guint *height, guchar ** pixdata)
 {
     gulong nitems;
     gulong *data;
     gulong *best;
-    int w, h;
+    guint w, h;
 
     data = NULL;
 
@@ -292,7 +293,7 @@ read_rgb_icon (DisplayInfo *display_info, Window window, int ideal_width, int id
 }
 
 static void
-get_pixmap_geometry (Display *dpy, Pixmap pixmap, unsigned int *w, unsigned int *h)
+get_pixmap_geometry (Display *dpy, Pixmap pixmap, guint *w, guint *h)
 {
     Window root;
     guint border_width;
@@ -308,8 +309,8 @@ apply_mask (GdkPixbuf * pixbuf, GdkPixbuf * mask)
     GdkPixbuf *with_alpha;
     guchar *src;
     guchar *dest;
-    int w, h, i, j;
-    int src_stride, dest_stride;
+    guint w, h, i, j;
+    guint src_stride, dest_stride;
 
     w = MIN (gdk_pixbuf_get_width (mask), gdk_pixbuf_get_width (pixbuf));
     h = MIN (gdk_pixbuf_get_height (mask), gdk_pixbuf_get_height (pixbuf));
@@ -395,8 +396,8 @@ get_cmap (GdkPixmap * pixmap, GdkScreen *gscreen)
 }
 
 static GdkPixbuf *
-get_pixbuf_from_pixmap (GdkScreen *gscreen, Pixmap xpixmap, int src_x, int src_y,
-                        int dest_x, int dest_y, int width, int height)
+get_pixbuf_from_pixmap (GdkScreen *gscreen, Pixmap xpixmap, guint src_x, guint src_y,
+                        gint dest_x, gint dest_y, guint width, guint height)
 {
     GdkDrawable *drawable;
     GdkPixbuf *retval;
@@ -436,12 +437,12 @@ get_pixbuf_from_pixmap (GdkScreen *gscreen, Pixmap xpixmap, int src_x, int src_y
 }
 
 static GdkPixbuf *
-try_pixmap_and_mask (ScreenInfo *screen_info, Pixmap src_pixmap, Pixmap src_mask, int width, int height)
+try_pixmap_and_mask (ScreenInfo *screen_info, Pixmap src_pixmap, Pixmap src_mask, guint width, guint height)
 {
     GdkPixbuf *unscaled;
     GdkPixbuf *icon;
     GdkPixbuf *mask;
-    unsigned int w, h;
+    guint w, h;
 
     if (src_pixmap == None)
     {
@@ -491,12 +492,10 @@ free_pixels (guchar * pixels, gpointer data)
 }
 
 static GdkPixbuf *
-scaled_from_pixdata (guchar * pixdata, int w, int h, int dest_w, int dest_h)
+scaled_from_pixdata (guchar * pixdata, guint w, guint h, guint dest_w, guint dest_h)
 {
     GdkPixbuf *src;
     GdkPixbuf *dest;
-    GdkPixbuf *tmp;
-    int size;
 
     src = gdk_pixbuf_new_from_data (pixdata, GDK_COLORSPACE_RGB, TRUE, 8, w, h, w * 4, free_pixels, NULL);
 
@@ -520,13 +519,13 @@ scaled_from_pixdata (guchar * pixdata, int w, int h, int dest_w, int dest_h)
 }
 
 GdkPixbuf *
-getAppIcon (ScreenInfo *screen_info, Window window, int width, int height)
+getAppIcon (ScreenInfo *screen_info, Window window, guint width, guint height)
 {
     XWMHints *hints;
     Pixmap pixmap;
     Pixmap mask;
     guchar *pixdata;
-    int w, h;
+    guint w, h;
 
     pixdata = NULL;
     pixmap = None;
@@ -579,7 +578,7 @@ getAppIcon (ScreenInfo *screen_info, Window window, int width, int height)
 }
 
 GdkPixbuf *
-getClientIcon (Client *c, int width, int height)
+getClientIcon (Client *c, guint width, guint height)
 {
     ScreenInfo *screen_info;
     GdkPixbuf *icon_pixbuf;
diff --git a/src/icons.h b/src/icons.h
index 1476f16..bccddea 100644
--- a/src/icons.h
+++ b/src/icons.h
@@ -18,7 +18,7 @@
 
         Metacity - (c) 2001 Havoc Pennington
         libwnck  - (c) 2001 Havoc Pennington
-        xfwm4    - (c) 2002-2011 Olivier Fourdan
+        xfwm4    - (c) 2002-2015 Olivier Fourdan
  */
 
 #ifndef INC_ICONS_H
@@ -37,10 +37,10 @@
 
 GdkPixbuf               *getAppIcon                             (ScreenInfo *,
                                                                  Window,
-                                                                 int,
-                                                                 int);
+                                                                 guint,
+                                                                 guint);
 GdkPixbuf               *getClientIcon                          (Client *,
-                                                                 int width,
-                                                                 int height);
+                                                                 guint,
+                                                                 guint);
 
 #endif /* INC_ICONS_H */
diff --git a/src/moveresize.c b/src/moveresize.c
index 08c68b1..e9c53d9 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -41,6 +41,7 @@
 #include "focus.h"
 #include "frame.h"
 #include "moveresize.h"
+#include "netwm.h"
 #include "placement.h"
 #include "poswin.h"
 #include "screen.h"
@@ -771,7 +772,6 @@ clientMoveTile (Client *c, XMotionEvent *xevent)
     ScreenInfo *screen_info;
     GdkRectangle rect;
     int x, y, disp_x, disp_y, disp_max_x, disp_max_y, dist, dist_corner;
-    NetWmDesktopLayout layout;
 
     screen_info = c->screen_info;
 
@@ -789,7 +789,6 @@ clientMoveTile (Client *c, XMotionEvent *xevent)
     disp_max_x = rect.x + rect.width;
     disp_max_y = rect.y + rect.height;
 
-    layout = screen_info->desktop_layout;
     dist = MIN (TILE_DISTANCE, frameDecorationTop (screen_info) / 2);
     dist_corner = (MIN (disp_max_x, disp_max_y)) / BORDER_TILE_LENGTH_RELATIVE;
 
@@ -1334,7 +1333,6 @@ clientResizeConfigure (Client *c, int pw, int ph)
 {
     ScreenInfo *screen_info;
     DisplayInfo *display_info;
-    XWindowChanges wc;
 
     screen_info = c->screen_info;
     display_info = screen_info->display_info;
@@ -1369,10 +1367,9 @@ clientResizeEventFilter (XEvent * xevent, gpointer data)
     GdkRectangle rect;
     MoveResizeData *passdata;
     eventFilterStatus status;
-    int prev_x, prev_y, prev_width, prev_height;
-    int cx, cy, disp_x, disp_y, disp_max_x, disp_max_y;
+    int prev_width, prev_height;
+    int cx, cy;
     int move_top, move_bottom, move_left, move_right;
-    gint min_visible;
     gboolean resizing;
     int right_edge; /* -Cliff */
     int bottom_edge; /* -Cliff */
@@ -1391,8 +1388,6 @@ clientResizeEventFilter (XEvent * xevent, gpointer data)
      */
     resizing = FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING);
 
-    min_visible = MAX (frameExtentTop (c), CLIENT_MIN_VISIBLE);
-
     cx = frameExtentX (c) + (frameExtentWidth (c) / 2);
     cy = frameExtentY (c) + (frameExtentHeight (c) / 2);
 
@@ -1415,14 +1410,7 @@ clientResizeEventFilter (XEvent * xevent, gpointer data)
 
     myScreenFindMonitorAtPoint (screen_info, cx, cy, &rect);
 
-    disp_x = rect.x;
-    disp_y = rect.y;
-    disp_max_x = rect.x + rect.width;
-    disp_max_y = rect.y + rect.height;
-
     /* Store previous values in case the resize puts the window title off bounds */
-    prev_x = c->x;
-    prev_y = c->y;
     prev_width = c->width;
     prev_height = c->height;
 
diff --git a/src/tabwin.c b/src/tabwin.c
index 023018f..a515fb2 100644
--- a/src/tabwin.c
+++ b/src/tabwin.c
@@ -603,7 +603,6 @@ createWindowlist (ScreenInfo *screen_info, TabwinWidget *tabwin_widget)
 static gboolean
 tabwinConfigure (TabwinWidget *tabwin_widget, GdkEventConfigure *event)
 {
-    Tabwin *tabwin;
     GtkWindow *window;
     GdkRectangle monitor;
     GdkScreen *screen;
@@ -686,14 +685,13 @@ tabwin_widget_class_init (TabwinWidgetClass *klass)
                                                                   G_PARAM_READABLE));
 }
 
-void
+static void
 computeTabwinData (ScreenInfo *screen_info, TabwinWidget *tabwin_widget)
 {
     Tabwin *tabwin;
     GdkPixbuf *icon_pixbuf;
     PangoLayout *layout;
     GList *client_list;
-    gint packpos;
     gint size_request;
     gboolean preview;
 
@@ -1093,14 +1091,12 @@ tabwinSelectDelta (Tabwin *tabwin, int row_delta, int col_delta)
 {
     GList *selected;
     int pos_current, col_current, row_current, nitems, cols, rows;
-    TabwinWidget *tabwin_widget;
     Client *c;
     ScreenInfo *screen_info;
 
     TRACE ("entering tabwinSelectDelta");
     g_return_val_if_fail (tabwin != NULL, NULL);
 
-    tabwin_widget = (TabwinWidget *) tabwin->tabwin_list->data;
     pos_current = g_list_position (*tabwin->client_list, tabwin->selected);
     nitems = g_list_length (*tabwin->client_list);
 
diff --git a/src/xsync.c b/src/xsync.c
index 5b687c8..55f69c4 100644
--- a/src/xsync.c
+++ b/src/xsync.c
@@ -48,7 +48,6 @@ clientCreateXSyncAlarm (Client *c)
 {
     ScreenInfo *screen_info;
     DisplayInfo *display_info;
-    XSyncValue current_value, next_value;
     XSyncAlarmAttributes attrs;
 
     g_return_val_if_fail (c != NULL, FALSE);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list