The variable clip_icon, that contains the Clip appicon is moved to the global workspace properties.
Now the screen is not needed to know the clip_icon. Signed-off-by: Rodolfo García Peñas (kix) <[email protected]> --- src/balloon.c | 2 +- src/defaults.c | 2 +- src/dock.c | 48 ++++++++++++++++++++++++------------------------ src/dockedapp.c | 4 +++- src/screen.c | 12 ++++-------- src/screen.h | 1 - src/workspace.c | 12 ++++++------ src/workspace.h | 3 +++ 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/balloon.c b/src/balloon.c index d6f0cfd..16bb225 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -440,7 +440,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 == wks_info.clip_icon) { if (strlen(wks_info.workspaces[wks_info.current_workspace]->name) > 5) { scr->balloon->text = wstrdup(wks_info.workspaces[wks_info.current_workspace]->name); } else { diff --git a/src/defaults.c b/src/defaults.c index 11cf23c..87b4167 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1230,7 +1230,7 @@ void wDefaultUpdateIcons(WScreen *scr) } if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) - wClipIconPaint(scr->clip_icon); + wClipIconPaint(wks_info.clip_icon); 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 75961f1..e6384b9 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 != wks_info.clip_icon) { char *command = NULL; if (!clickedIcon->command && !clickedIcon->editing) { @@ -820,8 +820,9 @@ static WAppIcon *mainIconCreate(WScreen *scr, int type, const char *name) switch(type) { case WM_CLIP: - if (scr->clip_icon) - return scr->clip_icon; + if (wks_info.clip_icon) + return wks_info.clip_icon; + btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP); btn->icon->core->descriptor.handle_expose = clipIconExpose; x_pos = 0; @@ -855,7 +856,7 @@ static WAppIcon *mainIconCreate(WScreen *scr, int type, const char *name) btn->docked = 1; if (type == WM_CLIP || (type == WM_DOCK && wPreferences.flags.clip_merged_in_dock)) - scr->clip_icon = btn; + wks_info.clip_icon = btn; return btn; } @@ -863,7 +864,6 @@ static WAppIcon *mainIconCreate(WScreen *scr, int type, const char *name) static void switchWSCommand(WMenu *menu, WMenuEntry *entry) { WAppIcon *btn, *icon = (WAppIcon *) entry->clientdata; - WScreen *scr = icon->icon->core->screen_ptr; WDock *src, *dest; WMArray *selectedIcons; int x, y; @@ -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 != wks_info.clip_icon) { if (wDockFindFreeSlot(dest, &x, &y)) { wDockMoveIconBetweenDocks(src, dest, icon, x, y); XUnmapWindow(dpy, icon->icon->core->window); @@ -979,7 +979,7 @@ static WMenu *makeWorkspaceMenu(WScreen *scr) if (!menu) wwarning(_("could not create workspace submenu for Clip menu")); - wMenuAddCallback(menu, "", switchWSCommand, (void *)scr->clip_icon); + wMenuAddCallback(menu, "", switchWSCommand, (void *)wks_info.clip_icon); menu->flags.realized = 0; wMenuRealize(menu); @@ -1417,7 +1417,7 @@ static void clipIconExpose(WObjDescriptor *desc, XEvent *event) static void dockIconPaint(WAppIcon *btn) { - if (btn == btn->icon->core->screen_ptr->clip_icon) { + if (btn == wks_info.clip_icon) { wClipIconPaint(btn); } else if (wIsADrawer(btn)) { wDrawerIconPaint(btn); @@ -1455,7 +1455,7 @@ 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 == wks_info.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); @@ -1587,7 +1587,7 @@ void wClipSaveState(WScreen *scr) { WMPropList *clip_state; - clip_state = make_icon_state(scr->clip_icon); + clip_state = make_icon_state(wks_info.clip_icon); WMPutInPLDictionary(scr->session_state, dClip, clip_state); @@ -1966,8 +1966,8 @@ 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) // TODO dande: understand the logic - scr->clip_icon = dock->icon_array[0]; + if (old_top == wks_info.clip_icon) /* TODO dande: understand the logic */ + wks_info.clip_icon = dock->icon_array[0]; wAppIconDestroy(old_top); } @@ -3275,7 +3275,7 @@ void wDockTrackWindowLaunch(WDock *dock, Window window) void wClipUpdateForWorkspaceChange(WScreen *scr, int workspace) { if (!wPreferences.flags.noclip) { - scr->clip_icon->dock = wks_info.workspaces[workspace]->clip; + wks_info.clip_icon->dock = wks_info.workspaces[workspace]->clip; if (wks_info.current_workspace != workspace) { WDock *old_clip = wks_info.workspaces[wks_info.current_workspace]->clip; WAppIconChain *chain = scr->global_icons; @@ -3431,7 +3431,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 == wks_info.clip_icon) { entry->callback = renameCallback; entry->clientdata = dock; entry->flags.indicator = 0; @@ -3455,7 +3455,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(aicon)); + wMenuSetEnabled(dock->menu, index, aicon != wks_info.clip_icon && !wIsADrawer(aicon)); /* select/unselect all icons */ entry = dock->menu->entries[++index]; @@ -3608,7 +3608,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 == wks_info.clip_icon) { if (getClipButton(event->xbutton.x, event->xbutton.y) != CLIP_IDLE) handleClipChangeWorkspace(dock->screen_ptr, event); else if (wPreferences.flags.clip_merged_in_dock) { @@ -3858,14 +3858,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 = wks_info.clip_icon->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(wks_info.clip_icon); done = 0; while (!done) { WMMaskEvent(dpy, ExposureMask | ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, &ev); @@ -3880,7 +3880,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(wks_info.clip_icon); } break; @@ -3912,7 +3912,7 @@ static void handleClipChangeWorkspace(WScreen *scr, XEvent *event) wWorkspaceChange(scr, wks_info.workspace_count - 1); } - wClipIconPaint(scr->clip_icon); + wClipIconPaint(wks_info.clip_icon); } static void iconMouseDown(WObjDescriptor *desc, XEvent *event) @@ -3944,7 +3944,7 @@ 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 != wks_info.clip_icon && dock->type != WM_DOCK) { wIconSelect(aicon->icon); return; } @@ -3960,7 +3960,7 @@ 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) { + } else if (event->xbutton.button == Button2 && aicon == wks_info.clip_icon) { if (!wks_info.clip_ws_menu) wks_info.clip_ws_menu = wWorkspaceMenuMake(scr, False); @@ -3983,7 +3983,7 @@ 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 != wks_info.clip_icon) { wClipMakeIconOmnipresent(aicon, !aicon->omnipresent); } else if (event->xbutton.button == Button3) { if (event->xbutton.send_event && @@ -4177,7 +4177,7 @@ 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 == wks_info.clip_icon) return WO_NOT_APPLICABLE; if (aicon->omnipresent == omnipresent) diff --git a/src/dockedapp.c b/src/dockedapp.c index 4c77cfa..283cdd9 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -38,7 +38,9 @@ #include "defaults.h" #include "framewin.h" #include "xinerama.h" +#include "workspace.h" +extern WWorkspace_info wks_info; static void updateCommand(WAppIcon * icon, char *command) { @@ -177,7 +179,7 @@ static void panelBtnCallback(WMWidget * self, void *data) WAppIcon *aicon = panel->editedIcon; // Cf dock.c:dockIconPaint(WAppIcon *aicon)? - if (aicon == aicon->icon->core->screen_ptr->clip_icon) + if (aicon == wks_info.clip_icon) wClipIconPaint(aicon); else if (wIsADrawer(aicon)) wDrawerIconPaint(aicon); diff --git a/src/screen.c b/src/screen.c index c296a33..e70776b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -71,6 +71,7 @@ /**** Global variables ****/ extern int wScreenCount; +extern WWorkspace_info wks_info; #ifdef KEEP_XKB_LOCK_STATUS extern int wXkbSupported; @@ -819,28 +820,23 @@ void wScreenRestoreState(WScreen * scr) wfree(path); } - if (!scr->session_state) { + if (!scr->session_state) scr->session_state = WMCreatePLDictionary(NULL, NULL); - } 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) { state = WMGetFromPLDictionary(scr->session_state, dClip); - scr->clip_icon = wClipRestoreState(scr, state); + wks_info.clip_icon = wClipRestoreState(scr, state); } - if (!wPreferences.flags.nodrawer) { + if (!wPreferences.flags.nodrawer) wDrawersRestoreState(scr); - } wWorkspaceRestoreState(scr); - wScreenUpdateUsableArea(scr); } diff --git a/src/screen.h b/src/screen.h index 0d667a5..4387ead 100644 --- a/src/screen.h +++ b/src/screen.h @@ -213,7 +213,6 @@ typedef struct _WScreen { struct WDock *dock; /* the application dock */ struct WPixmap *dock_dots; /* 3 dots for the Dock */ Window dock_shadow; /* shadow for dock buttons */ - struct WAppIcon *clip_icon; /* The clip main icon, or the dock's, if they are merged */ struct WDock *last_dock; WAppIconChain *global_icons; /* for omnipresent icons chain in clip */ int global_icon_count; /* How many global icons do we have */ diff --git a/src/workspace.c b/src/workspace.c index e5a1889..33680d0 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -621,11 +621,11 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (!wPreferences.flags.noclip && (wks_info.workspaces[workspace]->clip->auto_collapse || wks_info.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, wks_info.clip_icon->icon->core->window); + XMapWindow(dpy, wks_info.clip_icon->icon->core->window); } - else if (scr->clip_icon != NULL) { - wClipIconPaint(scr->clip_icon); + else if (wks_info.clip_icon != NULL) { + wClipIconPaint(wks_info.clip_icon); } wScreenUpdateUsableArea(scr); wNETWMUpdateDesktop(scr); @@ -700,8 +700,8 @@ void wWorkspaceRename(WScreen *scr, int workspace, const char *name) } } - if (scr->clip_icon) - wClipIconPaint(scr->clip_icon); + if (wks_info.clip_icon) + wClipIconPaint(wks_info.clip_icon); WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) workspace); } diff --git a/src/workspace.h b/src/workspace.h index 1000441..c645203 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -35,6 +35,9 @@ typedef struct WWorkspace_info { int last_used_workspace; /* last used workspace number */ WMFont *workspace_name_font; + /* Dock & Clip & Drawers stuff */ + struct WAppIcon *clip_icon; /* The clip main icon, or the dock's, if they are merged */ + /* Menus */ struct WMenu *workspace_menu; /* workspace operation */ struct WMenu *workspace_submenu; /* workspace list for window_menu */ -- 1.8.4.rc3 -- To unsubscribe, send mail to [email protected].
