From: Daniel Déchelotte <[email protected]>

The dock will have the up-right and down-left arrows to change workspaces and
the clip will be disabled. That is, if option ClipMergedInDock is set to yes in
GNUstep/Defaults/WindowMaker.
[not thoroughly tested]
---
 src/WindowMaker.h |    1 +
 src/appicon.c     |    2 ++
 src/defaults.c    |   14 ++++++++++++--
 src/dock.c        |   35 +++++++++++++++++++++++++----------
 src/screen.c      |    2 ++
 src/screen.h      |    4 ++--
 src/workspace.c   |   17 ++++++++---------
 7 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index 6ab085f..50d5dc2 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -433,6 +433,7 @@ typedef struct WPreferences {
     struct {
         unsigned int nodock:1;        /* don't display the dock */
         unsigned int noclip:1;         /* don't display the clip */
+        unsigned int clip_merged_in_dock:1; /* disable clip, dock gets its 
workspace switching functionality */
         unsigned int nodrawer:1;       /* don't use drawers */
         unsigned int wrap_appicons_in_dock:1; /* Whether to wrap appicons when 
Dock is moved up and down */
         unsigned int noupdates:1;      /* don't require ~/GNUstep (-static) */
diff --git a/src/appicon.c b/src/appicon.c
index d4384d7..b719d05 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -129,6 +129,8 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char 
*command, char *wm_instance,
        if (wm_instance)
                aicon->wm_instance = wstrdup(wm_instance);
 
+       if (strcmp(wm_class, "WMDock") == 0 && 
wPreferences.flags.clip_merged_in_dock)
+               tile = TILE_CLIP;
        aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, 
tile);
 
 #ifdef XDND
diff --git a/src/defaults.c b/src/defaults.c
index a018fd6..5de819e 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -113,6 +113,7 @@ static int getPropList();
 static int setJustify();
 static int setClearance();
 static int setIfDockPresent();
+static int setClipMergedInDock();
 static int setWrapAppiconsInDock();
 static int setStickyIcons();
 static int setWidgetColor();
@@ -328,6 +329,8 @@ WDefaultEntry staticOptionList[] = {
            NULL, getBool, setIfDockPresent, NULL, NULL},
        {"DisableDrawers", "NO", (void *)WM_DRAWER,
            NULL, getBool, setIfDockPresent, NULL, NULL},
+       {"ClipMergedInDock", "NO", NULL,
+           NULL, getBool, setClipMergedInDock, NULL, NULL},
        {"DisableMiniwindows", "NO", NULL,
            &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}
 };
@@ -1147,7 +1150,7 @@ void wDefaultUpdateIcons(WScreen *scr)
                aicon = aicon->next;
        }
 
-       if (!wPreferences.flags.noclip)
+       if (!wPreferences.flags.noclip || 
wPreferences.flags.clip_merged_in_dock)
                wClipIconPaint(scr->clip_icon);
 
        for (dc = scr->drawers; dc != NULL; dc = dc->next)
@@ -2349,6 +2352,13 @@ static int setIfDockPresent(WScreen * scr, WDefaultEntry 
* entry, char *flag, lo
        return 0;
 }
 
+static int setClipMergedInDock(WScreen *scr, WDefaultEntry *entry, char *flag, 
void *foo)
+{
+       wPreferences.flags.clip_merged_in_dock = *flag;
+       wPreferences.flags.noclip = wPreferences.flags.noclip || *flag;
+       return 0;
+}
+
 static int setWrapAppiconsInDock(WScreen *scr, WDefaultEntry *entry, char 
*flag, void *foo)
 {
        wPreferences.flags.wrap_appicons_in_dock = *flag;
@@ -2392,7 +2402,7 @@ static int setIconTile(WScreen * scr, WDefaultEntry * 
entry, WTexture ** texture
        /* put the icon in the noticeboard hint */
        PropSetIconTileHint(scr, img);
 
-       if (!wPreferences.flags.noclip) {
+       if (!wPreferences.flags.noclip || 
wPreferences.flags.clip_merged_in_dock) {
                if (scr->clip_tile) {
                        RReleaseImage(scr->clip_tile);
                }
diff --git a/src/dock.c b/src/dock.c
index 1625de9..b20bfe1 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -824,6 +824,8 @@ WAppIcon *mainIconCreate(WScreen *scr, int type, char *name)
        case WM_DOCK:
        default: /* to avoid a warning about btn and x_pos, basically */
                btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMDock", 
TILE_NORMAL);
+               if (wPreferences.flags.clip_merged_in_dock)
+                       btn->icon->core->descriptor.handle_expose = 
clipIconExpose;
                x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE;
                break;
        case WM_DRAWER:
@@ -846,7 +848,8 @@ WAppIcon *mainIconCreate(WScreen *scr, int type, char *name)
        btn->x_pos = x_pos;
        btn->y_pos = 0;
        btn->docked = 1;
-       if (type == WM_CLIP)
+       if (type == WM_CLIP ||
+               (type == WM_DOCK && wPreferences.flags.clip_merged_in_dock))
                scr->clip_icon = btn;
 
        return btn;
@@ -1377,7 +1380,7 @@ void wClipIconPaint(WAppIcon *aicon)
        snprintf(ws_number, sizeof(ws_number), "%i", scr->current_workspace + 
1);
        nlength = strlen(ws_number);
 
-       if (!workspace->clip->collapsed)
+       if (wPreferences.flags.noclip || !workspace->clip->collapsed)
                color = scr->clip_title_color[CLIP_NORMAL];
        else
                color = scr->clip_title_color[CLIP_COLLAPSED];
@@ -1447,7 +1450,7 @@ static WMPropList *make_icon_state(WAppIcon *btn)
 
                buggy = btn->buggy_app ? dYes : dNo;
 
-               if (btn == btn->icon->core->screen_ptr->clip_icon)
+               if (!wPreferences.flags.clip_merged_in_dock && btn == 
btn->icon->core->screen_ptr->clip_icon)
                        snprintf(buffer, sizeof(buffer), "%i,%i", btn->x_pos, 
btn->y_pos);
                else
                        snprintf(buffer, sizeof(buffer), "%hi,%hi", 
btn->xindex, btn->yindex);
@@ -1958,7 +1961,7 @@ WDock *wDockRestoreState(WScreen *scr, WMPropList 
*dock_state, int type)
                 * incremented in the loop above.
                 */
        } else if (old_top != dock->icon_array[0]) {
-               if (old_top == scr->clip_icon)
+               if (old_top == scr->clip_icon) // TODO dande: understand the 
logic
                        scr->clip_icon = dock->icon_array[0];
 
                wAppIconDestroy(old_top);
@@ -3592,10 +3595,22 @@ static void iconDblClick(WObjDescriptor *desc, XEvent 
*event)
                                /* raise/lower dock */
                                toggleLowered(dock);
                        } else if (btn == dock->screen_ptr->clip_icon) {
-                               if (getClipButton(event->xbutton.x, 
event->xbutton.y) == CLIP_IDLE)
-                                       toggleCollapsed(dock);
-                               else
+                               if (getClipButton(event->xbutton.x, 
event->xbutton.y) != CLIP_IDLE)
                                        
handleClipChangeWorkspace(dock->screen_ptr, event);
+                               else if 
(wPreferences.flags.clip_merged_in_dock) {
+                                       // Is actually the dock
+                                       if (btn->command)
+                                       {
+                                               if (!btn->launching && 
(!btn->running || (event->xbutton.state & ControlMask)))
+                                                       
launchDockedApplication(btn, False);
+                                       }
+                                       else
+                                       {
+                                               
wShowInfoPanel(dock->screen_ptr);
+                                       }
+                               }
+                               else
+                                       toggleCollapsed(dock);
                        } else if (wIsADrawer(dock->screen_ptr, btn)) {
                                toggleCollapsed(dock);
                        } else if (btn->command) {
@@ -3921,8 +3936,8 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent 
*event)
                }
 
                if (aicon->yindex == 0 && aicon->xindex == 0) {
-                       if (getClipButton(event->xbutton.x, event->xbutton.y) 
!= CLIP_IDLE
-                           && dock->type == WM_CLIP)
+                       if (getClipButton(event->xbutton.x, event->xbutton.y) 
!= CLIP_IDLE &&
+                               (dock->type == WM_CLIP || (dock->type == 
WM_DOCK && wPreferences.flags.clip_merged_in_dock)))
                                handleClipChangeWorkspace(scr, event);
                        else
                                handleDockMove(dock, aicon, event);
@@ -3931,7 +3946,7 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent 
*event)
                        if (wPreferences.single_click && !hasMoved)
                                iconDblClick(desc, event);
                }
-       } else if (event->xbutton.button == Button2 && dock->type == WM_CLIP && 
aicon == scr->clip_icon) {
+       } else if (event->xbutton.button == Button2 && aicon == scr->clip_icon) 
{
                if (!scr->clip_ws_menu) {
                        scr->clip_ws_menu = wWorkspaceMenuMake(scr, False);
                }
diff --git a/src/screen.c b/src/screen.c
index 8d1c46c..aa4662b 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -859,6 +859,8 @@ void wScreenRestoreState(WScreen * scr)
        if (!wPreferences.flags.nodock) {
                state = WMGetFromPLDictionary(scr->session_state, dDock);
                scr->dock = wDockRestoreState(scr, state, WM_DOCK);
+               /* If clip_merged_in_dock, setting scr->clip_icon is done by
+                * wDockRestoreState()->wDockCreate()->mainIconCreate() */
        }
 
        if (!wPreferences.flags.noclip) {
diff --git a/src/screen.h b/src/screen.h
index 66af6d7..5f817e3 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -222,7 +222,7 @@ typedef struct _WScreen {
     struct WMenu *dock_pos_menu;       /* Dock position menu */
     struct WPixmap *dock_dots;        /* 3 dots for the Dock */
     Window dock_shadow;                       /* shadow for dock buttons */
-    struct WAppIcon *clip_icon;        /* The clip main icon */
+    struct WAppIcon *clip_icon;        /* The clip main icon, or the dock's, 
if they are merged */
     struct WMenu *clip_menu;           /* Menu for clips */
     struct WMenu *clip_submenu;        /* Workspace list for clips */
     struct WMenu *clip_options;               /* Options for Clip */
@@ -244,7 +244,7 @@ typedef struct _WScreen {
     WMScreen *wmscreen;                       /* for widget library */
 
     struct RImage *icon_tile;
-    struct RImage *clip_tile;
+    struct RImage *clip_tile;          /* tile with arrows to change workspace 
*/
     struct RImage *drawer_tile;        /* tile for a drawer (tile + arrow) */
     Pixmap icon_tile_pixmap;           /* For app supplied icons */
 
diff --git a/src/workspace.c b/src/workspace.c
index 23f2c19..dd4e2cd 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -613,15 +613,14 @@ void wWorkspaceForceChange(WScreen * scr, int workspace)
        if (scr->dock)
                wAppIconPaint(scr->dock->icon_array[0]);
 
-       if (scr->clip_icon) {
-               if (scr->workspaces[workspace]->clip->auto_collapse ||
-                   scr->workspaces[workspace]->clip->auto_raise_lower) {
-                       /* to handle enter notify. This will also */
-                       XUnmapWindow(dpy, scr->clip_icon->icon->core->window);
-                       XMapWindow(dpy, scr->clip_icon->icon->core->window);
-               } else {
-                       wClipIconPaint(scr->clip_icon);
-               }
+       if (!wPreferences.flags.noclip && 
(scr->workspaces[workspace]->clip->auto_collapse ||
+                                               
scr->workspaces[workspace]->clip->auto_raise_lower)) {
+               /* to handle enter notify. This will also */
+               XUnmapWindow(dpy, scr->clip_icon->icon->core->window);
+               XMapWindow(dpy, scr->clip_icon->icon->core->window);
+       }
+       else if (scr->clip_icon != NULL) {
+               wClipIconPaint(scr->clip_icon);
        }
        wScreenUpdateUsableArea(scr);
        wNETWMUpdateDesktop(scr);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to