antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/xshell arguments.c decoration.c decor...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/xshell arguments.c decoration.c decor...
Date: Tue, 07 Aug 2007 12:49:45 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/08/07 12:49:45

Modified files:
        xshell         : arguments.c decoration.c decoration.h layout.c 
                         xshell.c xshell.h 

Log message:
        Code refactorings done for xshell, duplicate functions eliminated
        and made publically accessable.  Added convenience macro for default
        GC initialization.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/arguments.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/decoration.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/decoration.h?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/layout.c?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell.c?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell.h?cvsroot=antiright&r1=1.2&r2=1.3

Patches:
Index: arguments.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/arguments.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- arguments.c 5 Aug 2007 02:18:16 -0000       1.5
+++ arguments.c 7 Aug 2007 12:49:44 -0000       1.6
@@ -62,6 +62,18 @@
 }
 
 static void
+set_override_redirect(XShell * xsh)
+{
+       XSetWindowAttributes attr;
+
+       attr.override_redirect=True;
+       XUnmapWindow(xsh->gui.display, xsh->gui.widgets->window);
+       XChangeWindowAttributes(xsh->gui.display, xsh->gui.widgets->window,
+               CWOverrideRedirect, &attr);
+       XMapRaised(xsh->gui.display, xsh->gui.widgets->window);
+}
+
+static void
 handle_option_options(XShell * xsh, int argc, char ** argv,
        unsigned int * counter)
 {
@@ -69,39 +81,15 @@
        {
                case 'g':
                {
-                       unsigned int plus_ind=0;
-                       size_t len;
-                       char * x;
-                       char * y;
-
-                       (*counter)++;
-                       len=strlen(argv[*counter]);
-                       while(argv[*counter][plus_ind++]!='+'
-                               && (plus_ind<len));
-                       x=argv[*counter];
-                       x[plus_ind-1]='\0';
-                       y=&(x[plus_ind]);
-                       xsh->gui.widgets->geometry.x=atoi(x);
-                       xsh->gui.widgets->geometry.y=atoi(y);
-#ifdef DEBUG
-                       printf("x:%s,y:%s\n", x, y);
-#endif /* DEBUG */
+                       XWindowAttributes *geometry
+                               = &(xsh->gui.widgets->geometry);
+                       XParseGeometry(argv[++(*counter)], 
+                               &(geometry->x), &(geometry->y), 
+                               &(geometry->width), &(geometry->height)); 
                }
                        break;
                case 'n':
-               {
-                       XSetWindowAttributes attr;
-                       attr.override_redirect=True;
-                       XUnmapWindow(xsh->gui.display,
-                               xsh->gui.widgets->window);
-                       XChangeWindowAttributes(
-                               xsh->gui.display,
-                               xsh->gui.widgets->window,
-                               CWOverrideRedirect,
-                               &attr);
-                       XMapRaised(xsh->gui.display,
-                               xsh->gui.widgets->window);
-               }
+                       set_override_redirect(xsh);
                        break;
                case 'r':
                        (*counter)++;
@@ -112,37 +100,6 @@
        }
 }
 
-static void
-set_override_redirect(XShell * xsh)
-{
-       XSetWindowAttributes attr;
-
-       attr.override_redirect=True;
-       XUnmapWindow(xsh->gui.display, xsh->gui.widgets->window);
-       XChangeWindowAttributes(xsh->gui.display, xsh->gui.widgets->window,
-               CWOverrideRedirect, &attr);
-       XMapRaised(xsh->gui.display, xsh->gui.widgets->window);
-}
-
-static void
-parse_geometry_string(XShell * xsh, const char * geometry)
-{
-       unsigned int plus_ind=0;
-       size_t len;
-       char * x;
-       char * y;
-
-       len=strlen(geometry);
-       while(geometry[plus_ind++]!='+' && (plus_ind<len));
-       x=(char *)geometry;
-       x[plus_ind-1]='\0';
-       y=&(x[plus_ind]);
-       xsh->gui.widgets->geometry.x=atoi(x);
-       xsh->gui.widgets->geometry.y=atoi(y);
-#ifdef DEBUG
-       printf("x:%s,y:%s\n", x, y);
-#endif /* DEBUG */
-}
 
 static void
 handle_options(XShell * xsh, int argc, char ** argv, unsigned int * counter)

Index: decoration.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/decoration.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- decoration.c        6 Aug 2007 20:26:24 -0000       1.5
+++ decoration.c        7 Aug 2007 12:49:45 -0000       1.6
@@ -25,11 +25,6 @@
 
 #define GRADIENT_DELTA 16
 
-static GC
-setup_gc(Display * display, Window window)
-{
-       return XCreateGC(display, window, 0, NULL);
-}
 
 unsigned long 
 xsh_get_color(Display * display, 
@@ -141,8 +136,7 @@
        Window window;
 
        xsh=xsh_get_XShell_for_widget(widget);
-       gc=setup_gc(display=xsh->gui.display, window=widget->window);
-/*     XClearWindow(display, window); */
+       gc=XSH_SETUP_GC(display=xsh->gui.display, window=widget->window);
 
        /* Draw decoration */
        {

Index: decoration.h
===================================================================
RCS file: /sources/antiright/antiright/xshell/decoration.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- decoration.h        6 Aug 2007 20:26:24 -0000       1.4
+++ decoration.h        7 Aug 2007 12:49:45 -0000       1.5
@@ -28,6 +28,9 @@
 #define XSH_DECOR_IN 1
 #define XSH_DECOR_OUT -1
 
+#define XSH_SETUP_GC(display, window)\
+       XCreateGC(display, window, 0, NULL);
+
 void
 xsh_decorate(XWidget * widget, int order);
 

Index: layout.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/layout.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- layout.c    22 Jul 2007 21:54:10 -0000      1.3
+++ layout.c    7 Aug 2007 12:49:45 -0000       1.4
@@ -26,11 +26,13 @@
 void
 xsh_layout_widgets(XShell * xsh)
 {
+       XShellGUILayout *layout=&(xsh->gui.layout);
+       unsigned int column_count = layout->column_count;
+
        XResizeWindow(xsh->gui.display, xsh->gui.widgets->window,
-               XSH_WIDGET_WIDTH*(xsh->gui.layout.column_count+1),
-               XSH_WIDGET_HEIGHT*(xsh->gui.layout.column_count>0 
-               ? xsh->gui.layout.max_row_count 
-               : xsh->gui.layout.row_count));
+               XSH_WIDGET_WIDTH*(column_count+1),
+               XSH_WIDGET_HEIGHT*(column_count>0 
+               ? layout->max_row_count : layout->row_count+1));
 }
 
 

Index: xshell.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/xshell.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- xshell.c    3 Aug 2007 20:24:30 -0000       1.3
+++ xshell.c    7 Aug 2007 12:49:45 -0000       1.4
@@ -65,24 +65,6 @@
 }
 
 static void
-setup_gc(XShell * xsh)
-{
-       XGCValues values;
-       Display * dpy;
-
-       dpy=xsh->gui.display;
-       values.foreground=
-#ifndef XSH_DECORATE
-               WhitePixel(dpy, DefaultScreen(dpy));
-#else /* XSH_DECORATE */
-               BlackPixel(dpy, DefaultScreen(dpy));
-#endif /* not XSH_DECORATE */
-       xsh->gui.gc=XCreateGC(dpy, xsh->gui.widgets->window, 
-               GCForeground, &values);
-}
-
-
-static void
 show_main_window(Display * dpy, XShell * xsh)
 {
        Window toplevel;
@@ -98,6 +80,7 @@
 {
        XShell xsh;
        Display * dpy;
+
        if(argc<=1)
        {
                
@@ -108,7 +91,7 @@
        dpy=xsh.gui.display=XOpenDisplay(NULL);
        /* Main window.  */
        xshell_XWidget_new(&xsh, NULL, 0, 0, 100, 16);
-       setup_gc(&xsh);
+       xsh.gui.gc=XSH_SETUP_GC(dpy, xsh.gui.widgets->window);
 #ifdef XSH_USE_GRADIENT
        xsh_setup_gradients(&xsh);
 #endif /* XSH_USE_GRADIENT */

Index: xshell.h
===================================================================
RCS file: /sources/antiright/antiright/xshell/xshell.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- xshell.h    23 Jul 2007 01:58:46 -0000      1.2
+++ xshell.h    7 Aug 2007 12:49:45 -0000       1.3
@@ -40,8 +40,7 @@
 {
        Window window;
        XWindowAttributes geometry;
-       struct
-       {
+       struct {
                void (*expose)(struct XWidget *);
                void (*button_press)(struct XWidget *);
                void (*button_release)(struct XWidget *);
@@ -60,9 +59,23 @@
 
 #define XSH_OVERRIDE_REDIRECT 1
 
-struct XShell
+#ifdef XSH_USE_GRADIENT
+typedef struct 
+{
+       Pixmap outset;
+       Pixmap inset;
+}XShellGUIPixbufs;
+#endif /* XSH_USE_GRADIENT */
+
+typedef struct 
+{
+       unsigned int row_count;
+       unsigned int max_row_count;
+       unsigned int column_count;
+}XShellGUILayout;
+
+typedef struct 
 {
-       struct {
                Display * display;
                XWidget * widgets;
                XWidget * last_widget;
@@ -70,24 +83,16 @@
                GC gc;
 
 #ifdef XSH_USE_GRADIENT
-               struct
-               {
-                       Pixmap outset;
-                       Pixmap inset;
-               } pixbufs;
+       XShellGUIPixbufs pixbufs;
 #endif /* XSH_USE_GRADIENT */
-               struct
-               {
-                       unsigned int row_count;
-                       unsigned int max_row_count;
-                       unsigned int column_count;
-               } layout;
-       } gui;
+       XShellGUILayout layout;
+} XShellGUI;
 
+typedef struct 
+{
+       XShellGUI gui;
        XSHBitmask options;
-};
-
-typedef struct XShell XShell;
+} XShell;
 
 #include "widget.h"
 #include "button.h"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]