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.
---
 src/balloon.c   |    3 ++-
 src/defaults.c  |    2 +-
 src/dock.c      |   46 ++++++++++++++++++++++++++++------------------
 src/dockedapp.c |    4 +++-
 src/workspace.c |   12 ++++++------
 5 files changed, 40 insertions(+), 27 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 53d8173..f810f04 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -1208,7 +1208,7 @@ void wDefaultUpdateIcons(WScreen *scr)
        }
 
        if (!wPreferences.flags.noclip || 
wPreferences.flags.clip_merged_in_dock)
-               wClipIconPaint(scr->clip_icon);
+               
wClipIconPaint(scr->workspaces[scr->current_workspace]->clip->icon_array[0]);
 
        for (dc = scr->drawers; dc != NULL; dc = dc->next)
                wDrawerIconPaint(dc->adrawer->icon_array[0]);
diff --git a/src/dock.c b/src/dock.c
index 2801617..3666f52 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -531,7 +531,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) {
@@ -884,7 +884,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)) {
                        wDockMoveIconBetweenDocks(src, dest, icon, x, y);
                        XUnmapWindow(dpy, icon->icon->core->window);
@@ -1491,7 +1491,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 if (wIsADrawer(btn->icon->core->screen_ptr, btn)) {
                wDrawerIconPaint(btn);
@@ -1503,6 +1505,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;
@@ -1529,10 +1532,12 @@ static WMPropList *make_icon_state(WAppIcon *btn)
 
                buggy = btn->buggy_app ? dYes : dNo;
 
-               if (!wPreferences.flags.clip_merged_in_dock && btn == 
btn->icon->core->screen_ptr->clip_icon)
+               if (!wPreferences.flags.clip_merged_in_dock &&
+                   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,
@@ -1661,7 +1666,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);
 
@@ -3505,7 +3510,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, 
XEvent *event)
                if (dock->type == WM_CLIP) {
                        /* 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;
@@ -3529,7 +3534,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 && 
!wIsADrawer(scr, aicon));
+               wMenuSetEnabled(dock->menu, index, aicon != 
scr->workspaces[scr->current_workspace]->clip->icon_array[0] && 
!wIsADrawer(scr, aicon));
 
                /* select/unselect all icons */
                entry = dock->menu->entries[++index];
@@ -3682,7 +3687,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)
                                        
handleClipChangeWorkspace(dock->screen_ptr, event);
                                else if 
(wPreferences.flags.clip_merged_in_dock) {
@@ -3932,14 +3937,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);
@@ -3954,7 +3959,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;
 
@@ -3986,7 +3991,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)
@@ -4018,7 +4023,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;
                }
@@ -4034,10 +4041,11 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent 
*event)
                        if (wPreferences.single_click && !hasMoved)
                                iconDblClick(desc, event);
                }
-       } else if (event->xbutton.button == Button2 && aicon == scr->clip_icon) 
{
-               if (!scr->clip_ws_menu) {
+       } else if (event->xbutton.button == Button2 &&
+                  aicon != 
scr->workspaces[scr->current_workspace]->clip->icon_array[0]) {
+               if (!scr->clip_ws_menu)
                        scr->clip_ws_menu = wWorkspaceMenuMake(scr, False);
-               }
+
                if (scr->clip_ws_menu) {
                        WMenu *wsMenu = scr->clip_ws_menu;
                        int xpos;
@@ -4057,7 +4065,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 &&
@@ -4251,7 +4260,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 cc592e0..61316a9 100644
--- a/src/dockedapp.c
+++ b/src/dockedapp.c
@@ -36,6 +36,7 @@
 #include "misc.h"
 #include "defaults.h"
 #include "framewin.h"
+#include "workspace.h"
 #include "xinerama.h"
 
 /**** Global variables ****/
@@ -176,9 +177,10 @@ static void panelBtnCallback(WMWidget * self, void *data)
                        wfree(buf);
                } else {
                        WAppIcon *aicon = panel->editedIcon;
+                       WScreen *scr = aicon->icon->core->screen_ptr;
 
                        // Cf dock.c:dockIconPaint(WAppIcon *aicon)?
-                       if (aicon == aicon->icon->core->screen_ptr->clip_icon)
+                       if (aicon == 
scr->workspaces[scr->current_workspace]->clip->icon_array[0])
                                wClipIconPaint(aicon);
                        else if (wIsADrawer(aicon->icon->core->screen_ptr, 
aicon))
                                wDrawerIconPaint(aicon);
diff --git a/src/workspace.c b/src/workspace.c
index b4cccd0..3289b86 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -626,11 +626,11 @@ void wWorkspaceForceChange(WScreen * scr, int workspace)
        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);
+               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 if (scr->clip_icon != NULL) {
-               wClipIconPaint(scr->clip_icon);
+       else if (scr->workspaces[workspace]->clip->icon_array[0]) {
+               wClipIconPaint(scr->workspaces[workspace]->clip->icon_array[0]);
        }
        wScreenUpdateUsableArea(scr);
        wNETWMUpdateDesktop(scr);
@@ -705,8 +705,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