From: "Rodolfo García Peñas (kix)" <k...@kix.es> 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. --- src/balloon.c | 4 ++-- 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 | 4 ++++ 8 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/balloon.c b/src/balloon.c index 59700be..82a8603 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -433,14 +433,14 @@ static void miniwindowBalloon(WObjDescriptor * object) } } -static void appiconBalloon(WObjDescriptor * object) +static void appiconBalloon(WObjDescriptor *object) { WAppIcon *aicon = (WAppIcon *) object->parent; WScreen *scr = aicon->icon->core->screen_ptr; 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_nfo.clip_icon) { if (strlen(wks_nfo.workspaces[wks_nfo.current_workspace]->name) > 5) { scr->balloon->text = wstrdup(wks_nfo.workspaces[wks_nfo.current_workspace]->name); } else { diff --git a/src/defaults.c b/src/defaults.c index 3604147..adcc7b0 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1231,7 +1231,7 @@ void wDefaultUpdateIcons(WScreen *scr) } if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) - wClipIconPaint(scr->clip_icon); + wClipIconPaint(wks_nfo.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 acb497e..5713d07 100644 --- a/src/dock.c +++ b/src/dock.c @@ -533,7 +533,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry) selectedIcons = getSelected(dock); if (!WMGetArrayItemCount(selectedIcons) - && clickedIcon != dock->screen_ptr->clip_icon) { + && clickedIcon != wks_nfo.clip_icon) { char *command = NULL; if (!clickedIcon->command && !clickedIcon->editing) { @@ -822,8 +822,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_nfo.clip_icon) + return wks_nfo.clip_icon; + btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP); btn->icon->core->descriptor.handle_expose = clipIconExpose; x_pos = 0; @@ -857,7 +858,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_nfo.clip_icon = btn; return btn; } @@ -865,7 +866,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; @@ -886,7 +886,7 @@ static void switchWSCommand(WMenu *menu, WMenuEntry *entry) XUnmapWindow(dpy, btn->icon->core->window); } } - } else if (icon != scr->clip_icon) { + } else if (icon != wks_nfo.clip_icon) { if (wDockFindFreeSlot(dest, &x, &y)) { wDockMoveIconBetweenDocks(src, dest, icon, x, y); XUnmapWindow(dpy, icon->icon->core->window); @@ -981,7 +981,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_nfo.clip_icon); menu->flags.realized = 0; wMenuRealize(menu); @@ -1419,7 +1419,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_nfo.clip_icon) { wClipIconPaint(btn); } else if (wIsADrawer(btn)) { wDrawerIconPaint(btn); @@ -1457,7 +1457,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_nfo.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); @@ -1589,7 +1589,7 @@ void wClipSaveState(WScreen *scr) { WMPropList *clip_state; - clip_state = make_icon_state(scr->clip_icon); + clip_state = make_icon_state(wks_nfo.clip_icon); WMPutInPLDictionary(scr->session_state, dClip, clip_state); @@ -1968,8 +1968,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_nfo.clip_icon) // TODO dande: understand the logic + wks_nfo.clip_icon = dock->icon_array[0]; wAppIconDestroy(old_top); } @@ -3277,7 +3277,7 @@ void wDockTrackWindowLaunch(WDock *dock, Window window) void wClipUpdateForWorkspaceChange(WScreen *scr, int workspace) { if (!wPreferences.flags.noclip) { - scr->clip_icon->dock = wks_nfo.workspaces[workspace]->clip; + wks_nfo.clip_icon->dock = wks_nfo.workspaces[workspace]->clip; if (wks_nfo.current_workspace != workspace) { WDock *old_clip = wks_nfo.workspaces[wks_nfo.current_workspace]->clip; WAppIconChain *chain = scr->global_icons; @@ -3433,7 +3433,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_nfo.clip_icon) { entry->callback = renameCallback; entry->clientdata = dock; entry->flags.indicator = 0; @@ -3457,7 +3457,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_nfo.clip_icon && !wIsADrawer(aicon)); /* select/unselect all icons */ entry = dock->menu->entries[++index]; @@ -3610,7 +3610,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_nfo.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) { @@ -3860,14 +3860,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_nfo.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_nfo.clip_icon); done = 0; while (!done) { WMMaskEvent(dpy, ExposureMask | ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, &ev); @@ -3882,7 +3882,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_nfo.clip_icon); } break; @@ -3914,7 +3914,7 @@ static void handleClipChangeWorkspace(WScreen *scr, XEvent *event) wWorkspaceChange(scr, wks_nfo.workspace_count - 1); } - wClipIconPaint(scr->clip_icon); + wClipIconPaint(wks_nfo.clip_icon); } static void iconMouseDown(WObjDescriptor *desc, XEvent *event) @@ -3946,7 +3946,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_nfo.clip_icon && dock->type != WM_DOCK) { wIconSelect(aicon->icon); return; } @@ -3962,7 +3962,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_nfo.clip_icon) { if (!wks_nfo.clip_ws_menu) wks_nfo.clip_ws_menu = wWorkspaceMenuMake(scr, False); @@ -3985,7 +3985,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_nfo.clip_icon) { wClipMakeIconOmnipresent(aicon, !aicon->omnipresent); } else if (event->xbutton.button == Button3) { if (event->xbutton.send_event && @@ -4179,7 +4179,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_nfo.clip_icon) return WO_NOT_APPLICABLE; if (aicon->omnipresent == omnipresent) diff --git a/src/dockedapp.c b/src/dockedapp.c index 52795a9..ac99088 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 wks_info wks_nfo; 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_nfo.clip_icon) wClipIconPaint(aicon); else if (wIsADrawer(aicon)) wDrawerIconPaint(aicon); diff --git a/src/screen.c b/src/screen.c index 32e45fa..f666902 100644 --- a/src/screen.c +++ b/src/screen.c @@ -75,6 +75,7 @@ extern Atom _XA_WINDOWMAKER_STATE; extern Atom _XA_WINDOWMAKER_NOTICEBOARD; extern int wScreenCount; +extern wks_info wks_nfo; #ifdef KEEP_XKB_LOCK_STATUS extern int wXkbSupported; @@ -823,28 +824,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_nfo.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 9a4c764..5f39dfe 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -626,11 +626,11 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (!wPreferences.flags.noclip && (wks_nfo.workspaces[workspace]->clip->auto_collapse || wks_nfo.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_nfo.clip_icon->icon->core->window); + XMapWindow(dpy, wks_nfo.clip_icon->icon->core->window); } - else if (scr->clip_icon != NULL) { - wClipIconPaint(scr->clip_icon); + else if (wks_nfo.clip_icon != NULL) { + wClipIconPaint(wks_nfo.clip_icon); } wScreenUpdateUsableArea(scr); wNETWMUpdateDesktop(scr); @@ -705,8 +705,8 @@ void wWorkspaceRename(WScreen *scr, int workspace, const char *name) } } - if (scr->clip_icon) - wClipIconPaint(scr->clip_icon); + if (wks_nfo.clip_icon) + wClipIconPaint(wks_nfo.clip_icon); WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) workspace); } diff --git a/src/workspace.h b/src/workspace.h index e469e1d..8d26bbd 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -28,12 +28,16 @@ typedef struct WWorkspace { } WWorkspace; typedef struct wks_info { + /* Workspace stuff */ struct WWorkspace **workspaces; /* workspace array */ int workspace_count; /* number of workspaces */ int current_workspace; /* current workspace number */ 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.7.10.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.