From: "Rodolfo García Peñas (kix)" <[email protected]>

The functions that works with the Clip WAppIcon should call the right
icon, not always the clip_icon variable in the screen.h file.

Every Clip has a different WAppIcon (pointed to the same clip_icon),
stored in icon_array[0], but the functions working with the clip should
use the icon for the current Clip, not the common Clip icon image.

This patch replaces the calls to the clip_icon variables with the image
for the current workspace Clip image.

Signed-off-by: Rodolfo García Peñas (kix) <[email protected]>
---
 src/balloon.c   |    3 ++-
 src/defaults.c  |    2 +-
 src/dock.c      |   42 +++++++++++++++++++++++++-----------------
 src/dockedapp.c |    4 +++-
 src/workspace.c |   14 ++++++++------
 5 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/src/balloon.c b/src/balloon.c
index c00375a..d845291 100644
--- a/src/balloon.c
+++ b/src/balloon.c
@@ -39,6 +39,7 @@
 #include "framewin.h"
 #include "icon.h"
 #include "appicon.h"
+#include "dock.h"
 #include "funcs.h"
 #include "workspace.h"
 #include "balloon.h"
@@ -440,7 +441,7 @@ static void appiconBalloon(WObjDescriptor * object)
        char *tmp;
 
        /* Show balloon if it is the Clip and the workspace name is > 5 chars */
-       if (object->parent == scr->clip_icon) {
+       if (object->parent == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
                if (strlen(scr->workspaces[scr->current_workspace]->name) > 5) {
                        scr->balloon->text = 
wstrdup(scr->workspaces[scr->current_workspace]->name);
                } else {
diff --git a/src/defaults.c b/src/defaults.c
index 6c23064..fdd76c2 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -1190,7 +1190,7 @@ void wDefaultUpdateIcons(WScreen *scr)
        }
 
        if (!wPreferences.flags.noclip)
-               wClipIconPaint(scr->clip_icon);
+               
wClipIconPaint(scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
 
        while (wwin) {
                if (wwin->icon && wwin->flags.miniaturized)
diff --git a/src/dock.c b/src/dock.c
index 09d2804..cb6af0b 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -506,7 +506,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry 
*entry)
        selectedIcons = getSelected(dock);
 
        if (!WMGetArrayItemCount(selectedIcons)
-           && clickedIcon != dock->screen_ptr->clip_icon) {
+           && clickedIcon != 
dock->screen_ptr->workspaces[dock->screen_ptr->current_workspace]->clip->icon_array[0])
 {
                char *command = NULL;
 
                if (!clickedIcon->command && !clickedIcon->editing) {
@@ -777,7 +777,7 @@ static void switchWSCommand(WMenu *menu, WMenuEntry *entry)
                                XUnmapWindow(dpy, btn->icon->core->window);
                        }
                }
-       } else if (icon != scr->clip_icon) {
+       } else if (icon != 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
                if (wDockFindFreeSlot(dest, &x, &y)) {
                        moveIconBetweenDocks(src, dest, icon, x, y);
                        XUnmapWindow(dpy, icon->icon->core->window);
@@ -1206,7 +1206,9 @@ static void clipIconExpose(WObjDescriptor *desc, XEvent 
*event)
 
 static void dockIconPaint(WAppIcon *btn)
 {
-       if (btn == btn->icon->core->screen_ptr->clip_icon) {
+       WScreen *scr = btn->icon->core->screen_ptr;
+
+       if (btn == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
                wClipIconPaint(btn);
        } else {
                wAppIconPaint(btn);
@@ -1216,6 +1218,7 @@ static void dockIconPaint(WAppIcon *btn)
 
 static WMPropList *make_icon_state(WAppIcon *btn)
 {
+       WScreen *scr = btn->icon->core->screen_ptr;
        WMPropList *node = NULL;
        WMPropList *command, *autolaunch, *lock, *name, *forced;
        WMPropList *position, *buggy, *omnipresent;
@@ -1239,13 +1242,13 @@ static WMPropList *make_icon_state(WAppIcon *btn)
                wfree(tmp);
 
                forced = btn->forced_dock ? dYes : dNo;
-
                buggy = btn->buggy_app ? dYes : dNo;
 
-               if (btn == btn->icon->core->screen_ptr->clip_icon)
+               if (btn == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0])
                        snprintf(buffer, sizeof(buffer), "%i,%i", btn->x_pos, 
btn->y_pos);
                else
                        snprintf(buffer, sizeof(buffer), "%hi,%hi", 
btn->xindex, btn->yindex);
+
                position = WMCreatePLString(buffer);
 
                node = WMCreatePLDictionary(dCommand, command,
@@ -1372,7 +1375,7 @@ void wClipSaveState(WScreen *scr)
 {
        WMPropList *clip_state;
 
-       clip_state = make_icon_state(scr->clip_icon);
+       clip_state = 
make_icon_state(scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
 
        WMPutInPLDictionary(scr->session_state, dClip, clip_state);
 
@@ -3143,7 +3146,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, 
XEvent *event)
 
                /* Rename Workspace */
                entry = dock->menu->entries[++index];
-               if (aicon == scr->clip_icon) {
+               if (aicon == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
                        entry->callback = renameCallback;
                        entry->clientdata = dock;
                        entry->flags.indicator = 0;
@@ -3166,7 +3169,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, 
XEvent *event)
                entry = dock->menu->entries[++index];
                entry->clientdata = aicon;
                entry->flags.indicator_on = aicon->icon->selected;
-               wMenuSetEnabled(dock->menu, index, aicon != scr->clip_icon);
+               wMenuSetEnabled(dock->menu, index, aicon != 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
 
                /* select/unselect all icons */
                entry = dock->menu->entries[++index];
@@ -3309,7 +3312,7 @@ static void iconDblClick(WObjDescriptor *desc, XEvent 
*event)
                        if (event->xbutton.state & MOD_MASK) {
                                /* raise/lower dock */
                                toggleLowered(dock);
-                       } else if (btn == dock->screen_ptr->clip_icon) {
+                       } else if (btn == 
dock->screen_ptr->workspaces[dock->screen_ptr->current_workspace]->clip->icon_array[0])
 {
                                if (getClipButton(event->xbutton.x, 
event->xbutton.y) == CLIP_IDLE)
                                        toggleCollapsed(dock);
                                else
@@ -3694,14 +3697,14 @@ static void handleClipChangeWorkspace(WScreen *scr, 
XEvent *event)
        XEvent ev;
        int done, direction, new_ws;
        int new_dir;
-       WDock *clip = scr->clip_icon->dock;
+       WDock *clip = 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]->dock;
 
        direction = getClipButton(event->xbutton.x, event->xbutton.y);
 
        clip->lclip_button_pushed = direction == CLIP_REWIND;
        clip->rclip_button_pushed = direction == CLIP_FORWARD;
 
-       wClipIconPaint(scr->clip_icon);
+       
wClipIconPaint(scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
        done = 0;
        while (!done) {
                WMMaskEvent(dpy, ExposureMask | ButtonMotionMask | 
ButtonReleaseMask | ButtonPressMask, &ev);
@@ -3716,7 +3719,7 @@ static void handleClipChangeWorkspace(WScreen *scr, 
XEvent *event)
                                direction = new_dir;
                                clip->lclip_button_pushed = direction == 
CLIP_REWIND;
                                clip->rclip_button_pushed = direction == 
CLIP_FORWARD;
-                               wClipIconPaint(scr->clip_icon);
+                               
wClipIconPaint(scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
                        }
                        break;
 
@@ -3748,7 +3751,7 @@ static void handleClipChangeWorkspace(WScreen *scr, 
XEvent *event)
                        wWorkspaceChange(scr, scr->workspace_count - 1);
        }
 
-       wClipIconPaint(scr->clip_icon);
+       
wClipIconPaint(scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
 }
 
 static void iconMouseDown(WObjDescriptor *desc, XEvent *event)
@@ -3780,7 +3783,9 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent 
*event)
                else
                        wDockRaise(dock);
 
-               if ((event->xbutton.state & ShiftMask) && aicon != 
scr->clip_icon && dock->type != WM_DOCK) {
+               if ((event->xbutton.state & ShiftMask) &&
+                    aicon != 
scr->workspaces[scr->current_workspace]->clip->icon_array[0] &&
+                    dock->type != WM_DOCK) {
                        wIconSelect(aicon->icon);
                        return;
                }
@@ -3796,7 +3801,8 @@ 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 && dock->type == WM_CLIP &&
+                  aicon == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
                if (scr->clip_ws_menu) {
                        WMenu *wsMenu = scr->clip_ws_menu;
                        int xpos;
@@ -3816,7 +3822,8 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent 
*event)
                        (*desc->handle_mousedown) (desc, event);
                }
        } else if (event->xbutton.button == Button2 && dock->type == WM_CLIP &&
-                  (event->xbutton.state & ShiftMask) && aicon != 
scr->clip_icon) {
+                  (event->xbutton.state & ShiftMask) &&
+                  aicon != 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
                wClipMakeIconOmnipresent(aicon, !aicon->omnipresent);
        } else if (event->xbutton.button == Button3) {
                if (event->xbutton.send_event &&
@@ -4010,7 +4017,8 @@ int wClipMakeIconOmnipresent(WAppIcon *aicon, int 
omnipresent)
        WAppIconChain *new_entry, *tmp, *tmp1;
        int status = WO_SUCCESS;
 
-       if ((scr->dock && aicon->dock == scr->dock) || aicon == scr->clip_icon)
+       if ((scr->dock && aicon->dock == scr->dock) ||
+           aicon == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0])
                return WO_NOT_APPLICABLE;
 
        if (aicon->omnipresent == omnipresent)
diff --git a/src/dockedapp.c b/src/dockedapp.c
index 6c6d1f0..13dad2b 100644
--- a/src/dockedapp.c
+++ b/src/dockedapp.c
@@ -36,6 +36,7 @@
 #include "funcs.h"
 #include "defaults.h"
 #include "framewin.h"
+#include "workspace.h"
 #include "xinerama.h"
 
 /**** Global variables ****/
@@ -176,8 +177,9 @@ static void panelBtnCallback(WMWidget * self, void *data)
                        wfree(buf);
                } else {
                        WAppIcon *aicon = panel->editedIcon;
+                       WScreen *scr = aicon->icon->core->screen_ptr;
 
-                       if (aicon == aicon->icon->core->screen_ptr->clip_icon)
+                       if (aicon == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0])
                                wClipIconPaint(aicon);
                        else
                                wAppIconPaint(aicon);
diff --git a/src/workspace.c b/src/workspace.c
index 2f94427..f333e10 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -603,17 +603,19 @@ void wWorkspaceForceChange(WScreen * scr, int workspace)
        if (!wPreferences.sticky_icons)
                wArrangeIcons(scr, False);
 
+       /* The Dock */
        if (scr->dock)
                wAppIconPaint(scr->dock->icon_array[0]);
 
-       if (scr->clip_icon) {
+       /* The Clip in the current workspace */
+       if (scr->workspaces[workspace]->clip->icon_array[0]) {
                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);
+                       XUnmapWindow(dpy, 
scr->workspaces[workspace]->clip->icon_array[0]->icon->core->window);
+                       XMapWindow(dpy, 
scr->workspaces[workspace]->clip->icon_array[0]->icon->core->window);
                } else {
-                       wClipIconPaint(scr->clip_icon);
+                       
wClipIconPaint(scr->workspaces[workspace]->clip->icon_array[0]);
                }
        }
        wScreenUpdateUsableArea(scr);
@@ -689,8 +691,8 @@ void wWorkspaceRename(WScreen * scr, int workspace, char 
*name)
                }
        }
 
-       if (scr->clip_icon)
-               wClipIconPaint(scr->clip_icon);
+       if (scr->workspaces[workspace]->clip->icon_array[0])
+               wClipIconPaint(scr->workspaces[workspace]->clip->icon_array[0]);
 
        WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void 
*)(uintptr_t) workspace);
 }
-- 
1.7.10.4


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

Reply via email to