diff --git a/src/actions.c b/src/actions.c index d7b141b9..f0a06e31 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1833,8 +1833,10 @@ void wHideApplication(WApplication *wapp) if (wlist->flags.focused) hadfocus = 1; if (wApplicationGetAppIcon(wapp)) { - hideWindow(wApplicationGetAppIcon(wapp)->icon, wApplicationGetAppIcon(wapp)->x_pos, - wApplicationGetAppIcon(wapp)->y_pos, wlist, animate); + hideWindow(wAppIconGetIcon(wApplicationGetAppIcon(wapp)), + wAppIconGetXPos(wApplicationGetAppIcon(wapp)), + wAppIconGetYPos(wApplicationGetAppIcon(wapp)), + wlist, animate); animate = False; } } @@ -1968,8 +1970,8 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren } WMPostNotificationName(WMNChangedState, wlist, "hide"); } else if (wlist->flags.hidden) { - unhideWindow(wApplicationGetAppIcon(wapp)->icon, wApplicationGetAppIcon(wapp)->x_pos, - wApplicationGetAppIcon(wapp)->y_pos, wlist, animate, bringToCurrentWS); + unhideWindow(wAppIconGetIcon(wApplicationGetAppIcon(wapp)), wAppIconGetXPos(wApplicationGetAppIcon(wapp)), + wAppIconGetYPos(wApplicationGetAppIcon(wapp)), wlist, animate, bringToCurrentWS); animate = False; } else { if (bringToCurrentWS && wlist->frame->workspace != scr->current_workspace) @@ -2128,20 +2130,20 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll) /* arrange application icons */ aicon = scr->app_icon_list; /* reverse them to avoid unnecessarily sliding of icons */ - while (aicon && aicon->next) - aicon = aicon->next; + while (aicon && wAppIconGetNext(aicon)) + aicon = wAppIconGetNext(aicon); while (aicon) { - if (!aicon->docked) { + if (!wAppIconIsDocked(aicon)) { /* CHECK: can icon be NULL here ? */ /* The intention here is to place the AppIcon on the head that * contains most of the applications _main_ window. */ - head = wGetHeadForWindow(aicon->icon->owner); + head = wGetHeadForWindow(wAppIconGetIcon(aicon)->owner); - if (aicon->x_pos != X || aicon->y_pos != Y) { + if (wAppIconGetXPos(aicon) != X || wAppIconGetYPos(aicon) != Y) { #ifdef USE_ANIMATIONS if (!wPreferences.no_animations) - slide_window(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, X, Y); + slide_window(wAppIconGetIcon(aicon)->core->window, wAppIconGetXPos(aicon), wAppIconGetYPos(aicon), X, Y); #endif /* USE_ANIMATIONS */ } wAppIconMove(aicon, X, Y); @@ -2151,7 +2153,7 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll) vars[head].si++; } } - aicon = aicon->prev; + aicon = wAppIconGetPrev(aicon); } /* arrange miniwindows */ diff --git a/src/appicon.c b/src/appicon.c index e8cb96f7..9e94b961 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -55,6 +55,255 @@ #include "xdnd.h" #endif +struct WAppIcon { + short xindex; + short yindex; + struct WAppIcon *next; + struct WAppIcon *prev; + WIcon *icon; + int x_pos, y_pos; /* absolute screen coordinate */ + char *command; /* command used to launch app */ +#ifdef USE_DOCK_XDND + char *dnd_command; /* command to use when something is */ + /* dropped on us */ +#endif + char *paste_command; /* command to run when + * something is pasted */ + char *wm_class; + char *wm_instance; + pid_t pid; /* for apps launched from the dock */ + Window main_window; + struct WDock *dock; /* In which dock is docked. */ + struct _AppSettingsPanel *panel; /* Settings Panel */ + unsigned int docked:1; + unsigned int omnipresent:1; /* If omnipresent when + * docked in clip */ + unsigned int attracted:1; /* If it was attracted by the clip */ + unsigned int launching:1; + unsigned int running:1; /* application is already running */ + unsigned int relaunching:1; /* launching 2nd instance */ + unsigned int forced_dock:1; + unsigned int auto_launch:1; /* launch app on startup */ + unsigned int remote_start:1; + unsigned int updated:1; + unsigned int editing:1; /* editing docked icon */ + unsigned int drop_launch:1; /* launching from drop action */ + unsigned int paste_launch:1; /* launching from paste action */ + unsigned int destroyed:1; /* appicon was destroyed */ + unsigned int buggy_app:1; /* do not make dock rely on hints + * set by app */ + unsigned int lock:1; /* do not allow to be destroyed */ +}; + +/******** Accessors/mutators ********/ +short wAppIconGetXIndex(WAppIcon *aicon) { + return aicon->xindex; +} +void wAppIconSetXIndex(WAppIcon *aicon, short xindex) { + aicon->xindex = xindex; +} + +short wAppIconGetYIndex(WAppIcon *aicon) { + return aicon->yindex; +} +void wAppIconSetYIndex(WAppIcon *aicon, short yindex) { + aicon->yindex = yindex; +} + +struct WAppIcon *wAppIconGetNext(WAppIcon *aicon) { + return aicon->next; +} + +struct WAppIcon *wAppIconGetPrev(WAppIcon *aicon) { + return aicon->prev; +} + +int wAppIconGetXPos(WAppIcon *aicon) { + return aicon->x_pos; +} +void wAppIconSetXPos(WAppIcon *aicon, int x_pos) { + aicon->x_pos = x_pos; +} + +int wAppIconGetYPos(WAppIcon *aicon) { + return aicon->y_pos; +} +void wAppIconSetYPos(WAppIcon *aicon, int y_pos) { + aicon->y_pos = y_pos; +} + +WIcon *wAppIconGetIcon(WAppIcon *aicon) { + return aicon->icon; +} + +char *wAppIconGetCommand(WAppIcon *aicon) { + return aicon->command; +} +void wAppIconSetCommand(WAppIcon *aicon, char *command) { + if (aicon->command) + wfree(aicon->command); + if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { + wfree(command); + command = NULL; + } + aicon->command = command; +} + +#ifdef USE_DOCK_XDND +char *wAppIconGetDnDCommand(WAppIcon *aicon) { + return aicon->dnd_command; +} +void wAppIconSetDnDCommand(WAppIcon *aicon, char *command) { + if (aicon->dnd_command) + wfree(aicon->dnd_command); + if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { + wfree(command); + command = NULL; + } + aicon->dnd_command = command; +} +#endif // USE_DOCK_XDND + +char *wAppIconGetPasteCommand(WAppIcon *aicon) { + return aicon->paste_command; +} +void wAppIconSetPasteCommand(WAppIcon *aicon, char *command) { + if (aicon->paste_command) + wfree(aicon->paste_command); + if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { + wfree(command); + command = NULL; + } + aicon->paste_command = command; +} + +char *wAppIconGetWmClass(WAppIcon *aicon) { + return aicon->wm_class; +} + +char *wAppIconGetWmInstance(WAppIcon *aicon) { + return aicon->wm_instance; +} + +pid_t wAppIconGetPid(WAppIcon *aicon) { + return aicon->pid; +} +void wAppIconSetPid(WAppIcon *aicon, pid_t pid) { + aicon->pid = pid; +} + +Window wAppIconGetMainWindow(WAppIcon *aicon) { + return aicon->main_window; +} +void wAppIconSetMainWindow(WAppIcon *aicon, Window main_window) { + aicon->main_window = main_window; +} + +struct WDock *wAppIconGetDock(WAppIcon *aicon) { + return aicon->dock; +} +void wAppIconSetDock(WAppIcon *aicon, struct WDock *dock) { + aicon->dock = dock; +} + +struct _AppSettingsPanel *wAppIconGetPanel(WAppIcon *aicon) { + return aicon->panel; +} +void wAppIconSetPanel(WAppIcon *aicon, struct _AppSettingsPanel *panel) { + aicon->panel = panel; +} + +int wAppIconIsDocked(WAppIcon *aicon) { + return aicon->docked; +} +void wAppIconSetDocked(WAppIcon *aicon, int docked) { + aicon->docked = !!docked; +} + +int wAppIconIsOmnipresent(WAppIcon *aicon) { + return aicon->omnipresent; +} +void wAppIconSetOmnipresent(WAppIcon *aicon, int omnipresent) { + aicon->omnipresent = !!omnipresent; +} + +int wAppIconIsAttracted(WAppIcon *aicon) { + return aicon->attracted; +} +void wAppIconSetAttracted(WAppIcon *aicon, int attracted) { + aicon->attracted = !!attracted; +} + +int wAppIconIsLaunching(WAppIcon *aicon) { + return aicon->launching; +} +void wAppIconSetLaunching(WAppIcon *aicon, int launching) { + aicon->launching = !!launching; +} + +int wAppIconIsRunning(WAppIcon *aicon) { + return aicon->running; +} +void wAppIconSetRunning(WAppIcon *aicon, int running) { + aicon->running = !!running; +} + +int wAppIconIsRelaunching(WAppIcon *aicon) { + return aicon->relaunching; +} +void wAppIconSetRelaunching(WAppIcon *aicon, int relaunching) { + aicon->relaunching = !!relaunching; +} + +int wAppIconIsForceDocked(WAppIcon *aicon) { + return aicon->forced_dock; +} +void wAppIconSetForceDocked(WAppIcon *aicon, int forced_dock) { + aicon->forced_dock = !!forced_dock; +} + +int wAppIconIsAutoLaunch(WAppIcon *aicon) { + return aicon->auto_launch; +} +void wAppIconSetAutoLaunch(WAppIcon *aicon, int auto_launch) { + aicon->auto_launch = !!auto_launch; +} + +int wAppIconIsEditing(WAppIcon *aicon) { + return aicon->editing; +} +void wAppIconSetEditing(WAppIcon *aicon, int editing) { + aicon->editing = !!editing; +} + +int wAppIconIsDropLaunch(WAppIcon *aicon) { + return aicon->drop_launch; +} +void wAppIconSetDropLaunch(WAppIcon *aicon, int drop_launch) { + aicon->drop_launch = !!drop_launch; +} + +int wAppIconIsPasteLaunch(WAppIcon *aicon) { + return aicon->paste_launch; +} +void wAppIconSetPasteLaunch(WAppIcon *aicon, int paste_launch) { + aicon->paste_launch = !!paste_launch; +} + +int wAppIconIsBuggyApp(WAppIcon *aicon) { + return aicon->buggy_app; +} +void wAppIconSetBuggyApp(WAppIcon *aicon, int buggy_app) { + aicon->buggy_app = !!buggy_app; +} + +int wAppIconIsLocked(WAppIcon *aicon) { + return aicon->lock; +} +void wAppIconSetLocked(WAppIcon *aicon, int lock) { + aicon->lock = !!lock; +} + /* * icon_file for the dock is got from the preferences file by * using the classname/instancename diff --git a/src/appicon.h b/src/appicon.h index 44913b81..ce53613f 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -29,46 +29,94 @@ #include "icon.h" #include "application.h" -typedef struct WAppIcon { - short xindex; - short yindex; - struct WAppIcon *next; - struct WAppIcon *prev; - WIcon *icon; - int x_pos, y_pos; /* absolute screen coordinate */ - char *command; /* command used to launch app */ -#ifdef USE_DOCK_XDND - char *dnd_command; /* command to use when something is */ - /* dropped on us */ -#endif - char *paste_command; /* command to run when - * something is pasted */ - char *wm_class; - char *wm_instance; - pid_t pid; /* for apps launched from the dock */ - Window main_window; - struct WDock *dock; /* In which dock is docked. */ - struct _AppSettingsPanel *panel; /* Settings Panel */ - unsigned int docked:1; - unsigned int omnipresent:1; /* If omnipresent when - * docked in clip */ - unsigned int attracted:1; /* If it was attracted by the clip */ - unsigned int launching:1; - unsigned int running:1; /* application is already running */ - unsigned int relaunching:1; /* launching 2nd instance */ - unsigned int forced_dock:1; - unsigned int auto_launch:1; /* launch app on startup */ - unsigned int remote_start:1; - unsigned int updated:1; - unsigned int editing:1; /* editing docked icon */ - unsigned int drop_launch:1; /* launching from drop action */ - unsigned int paste_launch:1; /* launching from paste action */ - unsigned int destroyed:1; /* appicon was destroyed */ - unsigned int buggy_app:1; /* do not make dock rely on hints - * set by app */ - unsigned int lock:1; /* do not allow to be destroyed */ -} WAppIcon; +typedef struct WAppIcon WAppIcon; +/******** Accessors/mutators ********/ +short wAppIconGetXIndex(WAppIcon *aicon); +void wAppIconSetXIndex(WAppIcon *aicon, short x_index); + +short wAppIconGetYIndex(WAppIcon *aicon); +void wAppIconSetYIndex(WAppIcon *aicon, short y_index); + +struct WAppIcon *wAppIconGetNext(WAppIcon *aicon); + +struct WAppIcon *wAppIconGetPrev(WAppIcon *aicon); + +int wAppIconGetXPos(WAppIcon *aicon); +void wAppIconSetXPos(WAppIcon *aicon, int x_pos); + +int wAppIconGetYPos(WAppIcon *aicon); +void wAppIconSetYPos(WAppIcon *aicon, int y_pos); + +WIcon *wAppIconGetIcon(WAppIcon *aicon); + +char *wAppIconGetCommand(WAppIcon *aicon); +void wAppIconSetCommand(WAppIcon *aicon, char *command); + +#ifdef USE_DOCK_XDND +char *wAppIconGetDnDCommand(WAppIcon *aicon); +void wAppIconSetDnDCommand(WAppIcon *aicon, char *command); +#endif // USE_DOCK_XDND + +char *wAppIconGetPasteCommand(WAppIcon *aicon); +void wAppIconSetPasteCommand(WAppIcon *aicon, char *command); + +char *wAppIconGetWmClass(WAppIcon *aicon); + +char *wAppIconGetWmInstance(WAppIcon *aicon); + +pid_t wAppIconGetPid(WAppIcon *aicon); +void wAppIconSetPid(WAppIcon *aicon, pid_t pid); + +Window wAppIconGetMainWindow(WAppIcon *aicon); +void wAppIconSetMainWindow(WAppIcon *aicon, Window main_window); + +struct WDock *wAppIconGetDock(WAppIcon *aicon); +void wAppIconSetDock(WAppIcon *aicon, struct WDock *dock); + +struct _AppSettingsPanel *wAppIconGetPanel(WAppIcon *aicon); +void wAppIconSetPanel(WAppIcon *aicon, struct _AppSettingsPanel *panel); + +int wAppIconIsDocked(WAppIcon *aicon); +void wAppIconSetDocked(WAppIcon *aicon, int docked); + +int wAppIconIsOmnipresent(WAppIcon *aicon); +void wAppIconSetOmnipresent(WAppIcon *aicon, int omnipresent); + +int wAppIconIsAttracted(WAppIcon *aicon); +void wAppIconSetAttracted(WAppIcon *aicon, int attracted); + +int wAppIconIsLaunching(WAppIcon *aicon); +void wAppIconSetLaunching(WAppIcon *aicon, int launching); + +int wAppIconIsRunning(WAppIcon *aicon); +void wAppIconSetRunning(WAppIcon *aicon, int running); + +int wAppIconIsRelaunching(WAppIcon *aicon); +void wAppIconSetRelaunching(WAppIcon *aicon, int relaunching); + +int wAppIconIsForceDocked(WAppIcon *aicon); +void wAppIconSetForceDocked(WAppIcon *aicon, int forced_dock); + +int wAppIconIsAutoLaunch(WAppIcon *aicon); +void wAppIconSetAutoLaunch(WAppIcon *aicon, int auto_launch); + +int wAppIconIsEditing(WAppIcon *aicon); +void wAppIconSetEditing(WAppIcon *aicon, int editing); + +int wAppIconIsDropLaunch(WAppIcon *aicon); +void wAppIconSetDropLaunch(WAppIcon *aicon, int drop_launch); + +int wAppIconIsPasteLaunch(WAppIcon *aicon); +void wAppIconSetPasteLaunch(WAppIcon *aicon, int paste_launch); + +int wAppIconIsBuggyApp(WAppIcon *aicon); +void wAppIconSetBuggyApp(WAppIcon *aicon, int buggy_app); + +int wAppIconIsLocked(WAppIcon *aicon); +void wAppIconSetLocked(WAppIcon *aicon, int locked); + +/******** Lifecycle/resource management ********/ WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *wm_instance, const char *wm_class, int tile); Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event); diff --git a/src/application.c b/src/application.c index 464f09d1..1b3dc5b4 100644 --- a/src/application.c +++ b/src/application.c @@ -199,8 +199,8 @@ WApplication *wApplicationCreate(WWindow * wwin) wapp = wApplicationOf(main_window); if (wapp) { wapp->refcount++; - if (wapp->app_icon && wapp->app_icon->docked && - wapp->app_icon->relaunching && wapp->main_window_desc->fake_group) + if (wapp->app_icon && wAppIconIsDocked(wapp->app_icon) && + wAppIconIsRelaunching(wapp->app_icon) && wapp->main_window_desc->fake_group) wDockFinishLaunch(wapp->app_icon); return wapp; @@ -319,7 +319,7 @@ void wApplicationClearRefcount(WApplication *wapp) void wApplicationActivate(WApplication *wapp) { if (wapp->app_icon) { - wIconSetHighlited(wapp->app_icon->icon, True); + wIconSetHighlited(wAppIconGetIcon(wapp->app_icon), True); wAppIconPaint(wapp->app_icon); } } @@ -327,7 +327,7 @@ void wApplicationActivate(WApplication *wapp) void wApplicationDeactivate(WApplication *wapp) { if (wapp->app_icon) { - wIconSetHighlited(wapp->app_icon->icon, False); + wIconSetHighlited(wAppIconGetIcon(wapp->app_icon), False); wAppIconPaint(wapp->app_icon); } } diff --git a/src/balloon.c b/src/balloon.c index 056d4399..7f29e5d5 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -507,7 +507,7 @@ static void miniwindowBalloon(WObjDescriptor *object) static void appiconBalloon(WObjDescriptor *object) { WAppIcon *aicon = (WAppIcon *) object->parent; - WScreen *scr = aicon->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; char *tmp; /* Show balloon if it is the Clip and the workspace name is > 5 chars */ @@ -518,15 +518,15 @@ static void appiconBalloon(WObjDescriptor *object) wBalloonHide(scr); return; } - } else if (aicon->command && aicon->wm_class) { + } else if (wAppIconGetCommand(aicon) && wAppIconGetWmClass(aicon)) { int len; WApplication *app; unsigned int app_win_cnt = 0; const char *display_name; if (object->parent_type == WCLASS_DOCK_ICON) { - if (aicon->main_window) { - app = wApplicationOf(aicon->main_window); + if (wAppIconGetMainWindow(aicon)) { + app = wApplicationOf(wAppIconGetMainWindow(aicon)); if (app && wApplicationGetMainWindowDesc(app) && wApplicationGetMainWindowDesc(app)->fake_group) app_win_cnt = wApplicationGetMainWindowDesc(app)->fake_group->retainCount - 1; } @@ -537,38 +537,38 @@ static void appiconBalloon(WObjDescriptor *object) * instead of the class, otherwise the user will not be able to distinguish what * is being referred. */ - if (strcmp(aicon->wm_class, "GNUstep") == 0) - display_name = aicon->wm_instance; + if (strcmp(wAppIconGetWmClass(aicon), "GNUstep") == 0) + display_name = wAppIconGetWmInstance(aicon); else - display_name = aicon->wm_class; + display_name = wAppIconGetWmClass(aicon); - len = strlen(aicon->command) + strlen(display_name) + 8; + len = strlen(wAppIconGetCommand(aicon)) + strlen(display_name) + 8; if (app_win_cnt > 0) len += 1 + snprintf(NULL, 0, "%u", app_win_cnt); tmp = wmalloc(len); if (app_win_cnt > 0) - snprintf(tmp, len, "%u %s\n(%s)", app_win_cnt, display_name, aicon->command); + snprintf(tmp, len, "%u %s\n(%s)", app_win_cnt, display_name, wAppIconGetCommand(aicon)); else - snprintf(tmp, len, "%s\n(%s)", aicon->wm_instance, aicon->command); + snprintf(tmp, len, "%s\n(%s)", wAppIconGetWmInstance(aicon), wAppIconGetCommand(aicon)); scr->balloon->text = tmp; - } else if (aicon->command) { - scr->balloon->text = wstrdup(aicon->command); - } else if (aicon->wm_class) { + } else if (wAppIconGetCommand(aicon)) { + scr->balloon->text = wstrdup(wAppIconGetCommand(aicon)); + } else if (wAppIconGetWmClass(aicon)) { /* Check to see if it is a GNUstep App */ - if (strcmp(aicon->wm_class, "GNUstep") == 0) - scr->balloon->text = wstrdup(aicon->wm_instance); + if (strcmp(wAppIconGetWmClass(aicon), "GNUstep") == 0) + scr->balloon->text = wstrdup(wAppIconGetWmInstance(aicon)); else - scr->balloon->text = wstrdup(aicon->wm_class); + scr->balloon->text = wstrdup(wAppIconGetWmClass(aicon)); } else { wBalloonHide(scr); return; } - scr->balloon->h = aicon->icon->core->height - 2; + scr->balloon->h = wAppIconGetIcon(aicon)->core->height - 2; - scr->balloon->objectWindow = aicon->icon->core->window; + scr->balloon->objectWindow = wAppIconGetIcon(aicon)->core->window; if ((scr->balloon->prevType == object->parent_type || scr->balloon->prevType == WCLASS_MINIWINDOW) && scr->balloon->ignoreTimer) { XUnmapWindow(dpy, scr->balloon->window); diff --git a/src/client.c b/src/client.c index 19a38db5..e452f2df 100644 --- a/src/client.c +++ b/src/client.c @@ -324,14 +324,12 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) WApplication *wapp = wApplicationOf(wwin->main_window); char *command; - if (!wapp || !wApplicationGetAppIcon(wapp) || wApplicationGetAppIcon(wapp)->docked) + if (!wapp || !wApplicationGetAppIcon(wapp) || wAppIconIsDocked(wApplicationGetAppIcon(wapp))) break; command = GetCommandForWindow(wwin->main_window); if (command) { - if (wApplicationGetAppIcon(wapp)->command) - wfree(wApplicationGetAppIcon(wapp)->command); - wApplicationGetAppIcon(wapp)->command = command; + wAppIconSetCommand(wApplicationGetAppIcon(wapp), command); } } break; @@ -461,7 +459,7 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) wapp = wApplicationOf(wwin->main_window); if (wapp && wApplicationGetAppIcon(wapp)) { - wIconUpdate(wApplicationGetAppIcon(wapp)->icon); + wIconUpdate(wAppIconGetIcon(wApplicationGetAppIcon(wapp))); wAppIconPaint(wApplicationGetAppIcon(wapp)); } } diff --git a/src/defaults.c b/src/defaults.c index cb261163..26961e60 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1309,9 +1309,9 @@ void wDefaultUpdateIcons(WScreen *scr) while (aicon) { /* Get the application icon, default included */ - wIconChangeImageFile(aicon->icon, NULL); + wIconChangeImageFile(wAppIconGetIcon(aicon), NULL); wAppIconPaint(aicon); - aicon = aicon->next; + aicon = wAppIconGetNext(aicon); } if (!wPreferences.flags.noclip || wPreferences.flags.clip_merged_in_dock) diff --git a/src/dock.c b/src/dock.c index 40fe909e..d59cf35c 100644 --- a/src/dock.c +++ b/src/dock.c @@ -307,12 +307,12 @@ static void killCallback(WMenu *menu, WMenuEntry *entry) icon = (WAppIcon *) entry->clientdata; - icon->editing = 1; + wAppIconSetEditing(icon, 1); WCHANGE_STATE(WSTATE_MODAL); /* strip away dir names */ - shortname = basename(icon->command); + shortname = basename(wAppIconGetCommand(icon)); /* separate out command options */ wtokensplit(shortname, &argv, &argc); @@ -320,11 +320,11 @@ static void killCallback(WMenu *menu, WMenuEntry *entry) _(" will be forcibly closed.\n" "Any unsaved changes will be lost.\n" "Please confirm.")); - if (icon->icon && icon->icon->owner) { - fPtr = icon->icon->owner->fake_group; + if (wAppIconGetIcon(icon) && wAppIconGetIcon(icon)->owner) { + fPtr = wAppIconGetIcon(icon)->owner->fake_group; } else { /* is this really necessary? can we kill a non-running dock icon? */ - Window win = icon->main_window; + Window win = wAppIconGetMainWindow(icon); int index; index = WMFindInArray(scr->fakeGroupLeaders, matchWindow, (void *)win); @@ -348,15 +348,15 @@ static void killCallback(WMenu *menu, WMenuEntry *entry) wwin = twin; } - } else if (icon->icon && icon->icon->owner) { - wClientKill(icon->icon->owner); + } else if (wAppIconGetIcon(icon) && wAppIconGetIcon(icon)->owner) { + wClientKill(wAppIconGetIcon(icon)->owner); } } wfree(buffer); wtokenfree(argv, argc); - icon->editing = 0; + wAppIconSetEditing(icon, 0); WCHANGE_STATE(WSTATE_NORMAL); } @@ -370,7 +370,7 @@ static int numberOfSelectedIcons(WDock *dock) n = 0; for (i = 1; i < dock->max_icons; i++) { aicon = dock->icon_array[i]; - if (aicon && aicon->icon->selected) + if (aicon && wAppIconGetIcon(aicon)->selected) n++; } @@ -385,7 +385,7 @@ static WMArray *getSelected(WDock *dock) for (i = 1; i < dock->max_icons; i++) { btn = dock->icon_array[i]; - if (btn && btn->icon->selected) + if (btn && wAppIconGetIcon(btn)->selected) WMAddToArray(ret, btn); } @@ -394,8 +394,8 @@ static WMArray *getSelected(WDock *dock) static void paintClipButtons(WAppIcon *clipIcon, Bool lpushed, Bool rpushed) { - Window win = clipIcon->icon->core->window; - WScreen *scr = clipIcon->icon->core->screen_ptr; + Window win = wAppIconGetIcon(clipIcon)->core->window; + WScreen *scr = wAppIconGetIcon(clipIcon)->core->screen_ptr; XPoint p[4]; int pt = CLIP_BUTTON_SIZE * ICON_SIZE / 64; int tp = ICON_SIZE - pt; @@ -518,7 +518,7 @@ static void omnipresentCallback(WMenu *menu, WMenuEntry *entry) assert(entry->clientdata != NULL); - dock = clickedIcon->dock; + dock = wAppIconGetDock(clickedIcon); selectedIcons = getSelected(dock); @@ -527,10 +527,10 @@ static void omnipresentCallback(WMenu *menu, WMenuEntry *entry) failed = 0; WM_ITERATE_ARRAY(selectedIcons, aicon, iter) { - if (wClipMakeIconOmnipresent(aicon, !aicon->omnipresent) == WO_FAILED) + if (wClipMakeIconOmnipresent(aicon, !wAppIconIsOmnipresent(aicon)) == WO_FAILED) failed++; - else if (aicon->icon->selected) - wIconSelect(aicon->icon); + else if (wAppIconGetIcon(aicon)->selected) + wIconSelect(wAppIconGetIcon(aicon)); } WMFreeArray(selectedIcons); @@ -558,15 +558,17 @@ static void removeIcons(WMArray *icons, WDock *dock) WMArrayIterator it; WM_ITERATE_ARRAY(icons, aicon, it) { - keepit = aicon->running && wApplicationOf(aicon->main_window); + keepit = wAppIconIsRunning(aicon) && wApplicationOf(wAppIconGetMainWindow(aicon)); wDockDetach(dock, aicon); if (keepit) { - /* XXX: can: aicon->icon == NULL ? */ - PlaceIcon(dock->screen_ptr, &aicon->x_pos, &aicon->y_pos, - wGetHeadForWindow(aicon->icon->owner)); - XMoveWindow(dpy, aicon->icon->core->window, aicon->x_pos, aicon->y_pos); + /* XXX: can: wAppIconGetIcon(aicon) == NULL ? */ + int x = wAppIconGetXPos(aicon), y = wAppIconGetYPos(aicon); + PlaceIcon(dock->screen_ptr, &x, &y, wGetHeadForWindow(wAppIconGetIcon(aicon)->owner)); + wAppIconSetXPos(aicon, x); + wAppIconSetYPos(aicon, y); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, x, y); if (!dock->mapped || wDockIsCollapsed(dock)) - XMapWindow(dpy, aicon->icon->core->window); + XMapWindow(dpy, wAppIconGetIcon(aicon)->core->window); } } WMFreeArray(icons); @@ -586,7 +588,7 @@ static void removeIconsCallback(WMenu *menu, WMenuEntry *entry) assert(clickedIcon != NULL); - dock = clickedIcon->dock; + dock = wAppIconGetDock(clickedIcon); selectedIcons = getSelected(dock); @@ -599,7 +601,7 @@ static void removeIconsCallback(WMenu *menu, WMenuEntry *entry) return; } } else { - if (clickedIcon->xindex == 0 && clickedIcon->yindex == 0) { + if (wAppIconGetXIndex(clickedIcon) == 0 && wAppIconGetYIndex(clickedIcon) == 0) { WMFreeArray(selectedIcons); return; } @@ -625,7 +627,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry) (void) menu; assert(clickedIcon != NULL); - dock = clickedIcon->dock; + dock = wAppIconGetDock(clickedIcon); selectedIcons = getSelected(dock); @@ -633,18 +635,18 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry) && clickedIcon != dock->screen_ptr->clip_icon) { char *command = NULL; - if (!clickedIcon->command && !clickedIcon->editing) { - clickedIcon->editing = 1; + if (!wAppIconGetCommand(clickedIcon) && !wAppIconIsEditing(clickedIcon)) { + wAppIconSetEditing(clickedIcon, 1); if (wInputDialog(dock->screen_ptr, _("Keep Icon"), _("Type the command used to launch the application"), &command)) { if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { wfree(command); command = NULL; } - clickedIcon->command = command; - clickedIcon->editing = 0; + wAppIconSetCommand(clickedIcon, command); + wAppIconSetEditing(clickedIcon, 0); } else { - clickedIcon->editing = 0; + wAppIconSetEditing(clickedIcon, 0); if (command) wfree(command); WMFreeArray(selectedIcons); @@ -656,19 +658,19 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry) } WM_ITERATE_ARRAY(selectedIcons, aicon, it) { - if (aicon->icon->selected) - wIconSelect(aicon->icon); + if (wAppIconGetIcon(aicon)->selected) + wIconSelect(wAppIconGetIcon(aicon)); - if (aicon->attracted && aicon->command) { - aicon->attracted = 0; - if (aicon->icon->shadowed) { - aicon->icon->shadowed = 0; + if (wAppIconIsAttracted(aicon) && wAppIconGetCommand(aicon)) { + wAppIconSetAttracted(aicon, 0); + if (wAppIconGetIcon(aicon)->shadowed) { + wAppIconGetIcon(aicon)->shadowed = 0; /* * Update icon pixmap, RImage doesn't change, * so call wIconUpdate is not needed */ - update_icon_pixmap(aicon->icon); + update_icon_pixmap(wAppIconGetIcon(aicon)); /* Paint it */ wAppIconPaint(aicon); @@ -725,7 +727,7 @@ static void selectCallback(WMenu *menu, WMenuEntry *entry) assert(icon != NULL); - wIconSelect(icon->icon); + wIconSelect(wAppIconGetIcon(icon)); wMenuPaint(menu); } @@ -742,27 +744,27 @@ static void attractIconsCallback(WMenu *menu, WMenuEntry *entry) (void) menu; assert(entry->clientdata != NULL); - clip = clickedIcon->dock; + clip = wAppIconGetDock(clickedIcon); aicon = clip->screen_ptr->app_icon_list; while (aicon) { - if (!aicon->docked && wDockFindFreeSlot(clip, &x, &y)) { + if (!wAppIconIsDocked(aicon) && wDockFindFreeSlot(clip, &x, &y)) { x_pos = clip->x_pos + x * ICON_SIZE; y_pos = clip->y_pos + y * ICON_SIZE; - if (aicon->x_pos != x_pos || aicon->y_pos != y_pos) - move_window(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, x_pos, y_pos); + if (wAppIconGetXPos(aicon) != x_pos || wAppIconGetYPos(aicon) != y_pos) + move_window(wAppIconGetIcon(aicon)->core->window, wAppIconGetXPos(aicon), wAppIconGetYPos(aicon), x_pos, y_pos); - aicon->attracted = 1; - if (!aicon->icon->shadowed) { - aicon->icon->shadowed = 1; + wAppIconSetAttracted(aicon, 1); + if (!wAppIconGetIcon(aicon)->shadowed) { + wAppIconGetIcon(aicon)->shadowed = 1; update_icon = True; } wDockAttachIcon(clip, aicon, x, y, update_icon); if (wDockIsCollapsed(clip) || !clip->mapped) - XUnmapWindow(dpy, aicon->icon->core->window); + XUnmapWindow(dpy, wAppIconGetIcon(aicon)->core->window); } - aicon = aicon->next; + aicon = wAppIconGetNext(aicon); } } @@ -776,19 +778,19 @@ static void selectIconsCallback(WMenu *menu, WMenuEntry *entry) int i; assert(clickedIcon != NULL); - dock = clickedIcon->dock; + dock = wAppIconGetDock(clickedIcon); selectedIcons = getSelected(dock); if (!WMGetArrayItemCount(selectedIcons)) { for (i = 1; i < dock->max_icons; i++) { btn = dock->icon_array[i]; - if (btn && !btn->icon->selected) - wIconSelect(btn->icon); + if (btn && !wAppIconGetIcon(btn)->selected) + wIconSelect(wAppIconGetIcon(btn)); } } else { WM_ITERATE_ARRAY(selectedIcons, btn, iter) { - wIconSelect(btn->icon); + wIconSelect(wAppIconGetIcon(btn)); } } WMFreeArray(selectedIcons); @@ -869,7 +871,7 @@ static void settingsCallback(WMenu *menu, WMenuEntry *entry) /* Parameter not used, but tell the compiler that it is ok */ (void) menu; - if (btn->editing) + if (wAppIconIsEditing(btn)) return; ShowDockAppSettingsPanel(btn); } @@ -882,10 +884,10 @@ static void hideCallback(WMenu *menu, WMenuEntry *entry) /* Parameter not used, but tell the compiler that it is ok */ (void) menu; - wapp = wApplicationOf(btn->icon->owner->main_window); + wapp = wApplicationOf(wAppIconGetIcon(btn)->owner->main_window); if (wApplicationIsHidden(wapp)) { - wWorkspaceChange(btn->icon->core->screen_ptr, wApplicationGetLastWorkspace(wapp)); + wWorkspaceChange(wAppIconGetIcon(btn)->core->screen_ptr, wApplicationGetLastWorkspace(wapp)); wUnhideApplication(wapp, False, False); } else { wHideApplication(wapp); @@ -900,7 +902,7 @@ static void unhideHereCallback(WMenu *menu, WMenuEntry *entry) /* Parameter not used, but tell the compiler that it is ok */ (void) menu; - wapp = wApplicationOf(btn->icon->owner->main_window); + wapp = wApplicationOf(wAppIconGetIcon(btn)->owner->main_window); wUnhideApplication(wapp, False, True); } @@ -942,36 +944,36 @@ static WAppIcon *mainIconCreate(WScreen *scr, int type, const char *name) return scr->clip_icon; btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP); - btn->icon->core->descriptor.handle_expose = clipIconExpose; + wAppIconGetIcon(btn)->core->descriptor.handle_expose = clipIconExpose; x_pos = 0; break; 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; + wAppIconGetIcon(btn)->core->descriptor.handle_expose = clipIconExpose; x_pos = getDockXPosition(scr, True); break; case WM_DRAWER: if (name == NULL) name = findUniqueName(scr, "Drawer"); btn = wAppIconCreateForDock(scr, NULL, name, "WMDrawer", TILE_DRAWER); - btn->icon->core->descriptor.handle_expose = drawerIconExpose; + wAppIconGetIcon(btn)->core->descriptor.handle_expose = drawerIconExpose; x_pos = 0; } - btn->xindex = 0; - btn->yindex = 0; + wAppIconSetXIndex(btn, 0); + wAppIconSetYIndex(btn, 0); - btn->icon->core->descriptor.handle_mousedown = iconMouseDown; - btn->icon->core->descriptor.handle_enternotify = clipEnterNotify; - btn->icon->core->descriptor.handle_leavenotify = clipLeaveNotify; - btn->icon->core->descriptor.parent_type = WCLASS_DOCK_ICON; - btn->icon->core->descriptor.parent = btn; - XMapWindow(dpy, btn->icon->core->window); - btn->x_pos = x_pos; - btn->y_pos = 0; - btn->docked = 1; + wAppIconGetIcon(btn)->core->descriptor.handle_mousedown = iconMouseDown; + wAppIconGetIcon(btn)->core->descriptor.handle_enternotify = clipEnterNotify; + wAppIconGetIcon(btn)->core->descriptor.handle_leavenotify = clipLeaveNotify; + wAppIconGetIcon(btn)->core->descriptor.parent_type = WCLASS_DOCK_ICON; + wAppIconGetIcon(btn)->core->descriptor.parent = btn; + XMapWindow(dpy, wAppIconGetIcon(btn)->core->window); + wAppIconSetXPos(btn, x_pos); + wAppIconSetYPos(btn, 0); + wAppIconSetDocked(btn, 1); if (type == WM_CLIP || (type == WM_DOCK && wPreferences.flags.clip_merged_in_dock)) scr->clip_icon = btn; @@ -982,7 +984,7 @@ 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; + WScreen *scr = wAppIconGetIcon(icon)->core->screen_ptr; WDock *src, *dest; WMArray *selectedIcons; int x, y; @@ -993,7 +995,7 @@ static void switchWSCommand(WMenu *menu, WMenuEntry *entry) if (entry->order == scr->current_workspace) return; - src = icon->dock; + src = wAppIconGetDock(icon); dest = scr->workspaces[entry->order]->clip; selectedIcons = getSelected(src); @@ -1004,13 +1006,13 @@ static void switchWSCommand(WMenu *menu, WMenuEntry *entry) WM_ITERATE_ARRAY(selectedIcons, btn, iter) { if (wDockFindFreeSlot(dest, &x, &y)) { wDockMoveIconBetweenDocks(src, dest, btn, x, y); - XUnmapWindow(dpy, btn->icon->core->window); + XUnmapWindow(dpy, wAppIconGetIcon(btn)->core->window); } } } else if (icon != scr->clip_icon) { if (wDockFindFreeSlot(dest, &x, &y)) { wDockMoveIconBetweenDocks(src, dest, icon, x, y); - XUnmapWindow(dpy, icon->icon->core->window); + XUnmapWindow(dpy, wAppIconGetIcon(icon)->core->window); } } WMFreeArray(selectedIcons); @@ -1018,43 +1020,44 @@ static void switchWSCommand(WMenu *menu, WMenuEntry *entry) static void launchDockedApplication(WAppIcon *btn, Bool withSelection) { - WScreen *scr = btn->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(btn)->core->screen_ptr; - if (!btn->launching && - ((!withSelection && btn->command != NULL) || (withSelection && btn->paste_command != NULL))) { - if (!btn->forced_dock) { - btn->relaunching = btn->running; - btn->running = 1; + if (!wAppIconIsLaunching(btn) && + ((!withSelection && wAppIconGetCommand(btn) != NULL) || (withSelection && wAppIconGetPasteCommand(btn) != NULL))) { + if (!wAppIconIsForceDocked(btn)) { + wAppIconSetRelaunching(btn, wAppIconIsRunning(btn)); + wAppIconSetRunning(btn, 1); } - if (btn->wm_instance || btn->wm_class) { + if (wAppIconGetWmInstance(btn) || wAppIconGetWmClass(btn)) { WWindowAttributes attr; memset(&attr, 0, sizeof(WWindowAttributes)); - wDefaultFillAttributes(btn->wm_instance, btn->wm_class, &attr, NULL, True); + wDefaultFillAttributes(wAppIconGetWmInstance(btn), wAppIconGetWmClass(btn), &attr, NULL, True); - if (!attr.no_appicon && !btn->buggy_app) - btn->launching = 1; + if (!attr.no_appicon && !wAppIconIsBuggyApp(btn)) + wAppIconSetLaunching(btn, 1); else - btn->running = 0; + wAppIconSetRunning(btn, 0); } - btn->drop_launch = 0; - btn->paste_launch = withSelection; - scr->last_dock = btn->dock; - btn->pid = execCommand(btn, (withSelection ? btn->paste_command : btn->command), NULL); - if (btn->pid > 0) { - if (btn->buggy_app) { + wAppIconSetDropLaunch(btn, 0); + wAppIconSetPasteLaunch(btn, withSelection); + scr->last_dock = wAppIconGetDock(btn); + wAppIconSetPid(btn, + execCommand(btn, (withSelection ? wAppIconGetPasteCommand(btn) : wAppIconGetCommand(btn)), NULL)); + if (wAppIconGetPid(btn) > 0) { + if (wAppIconIsBuggyApp(btn)) { /* give feedback that the app was launched */ - btn->launching = 1; + wAppIconSetLaunching(btn, 1); dockIconPaint(btn); - btn->launching = 0; + wAppIconSetLaunching(btn, 0); WMAddTimerHandler(200, (WMCallback *) dockIconPaint, btn); } else { dockIconPaint(btn); } } else { - wwarning(_("could not launch application %s"), btn->command); - btn->launching = 0; - if (!btn->relaunching) - btn->running = 0; + wwarning(_("could not launch application %s"), wAppIconGetCommand(btn)); + wAppIconSetLaunching(btn, 0); + if (!wAppIconIsRelaunching(btn)) + wAppIconSetRunning(btn, 0); } } } @@ -1435,10 +1438,10 @@ WDock *wDockCreate(WScreen *scr, int type, const char *name) btn = mainIconCreate(scr, type, name); - btn->dock = dock; + wAppIconSetDock(btn, dock); - dock->x_pos = btn->x_pos; - dock->y_pos = btn->y_pos; + dock->x_pos = wAppIconGetXPos(btn); + dock->y_pos = wAppIconGetYPos(btn); dock->screen_ptr = scr; dock->type = type; dock->icon_count = 1; @@ -1455,8 +1458,8 @@ WDock *wDockCreate(WScreen *scr, int type, const char *name) dock->attract_icons = 0; dock->lowered = 1; dock->icon_array[0] = btn; - wRaiseFrame(btn->icon->core); - XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); + wRaiseFrame(wAppIconGetIcon(btn)->core); + XMoveWindow(dpy, wAppIconGetIcon(btn)->core->window, wAppIconGetXPos(btn), wAppIconGetYPos(btn)); /* create dock menu */ dock->menu = dockMenuCreate(scr, type); @@ -1477,15 +1480,18 @@ void wDockDestroy(WDock *dock) for (i = (dock->type == WM_CLIP) ? 1 : 0; i < dock->max_icons; i++) { aicon = dock->icon_array[i]; if (aicon) { - int keepit = aicon->running && wApplicationOf(aicon->main_window); + int keepit = wAppIconIsRunning(aicon) && wApplicationOf(wAppIconGetMainWindow(aicon)); wDockDetach(dock, aicon); if (keepit) { - /* XXX: can: aicon->icon == NULL ? */ - PlaceIcon(dock->screen_ptr, &aicon->x_pos, &aicon->y_pos, - wGetHeadForWindow(aicon->icon->owner)); - XMoveWindow(dpy, aicon->icon->core->window, aicon->x_pos, aicon->y_pos); + /* XXX: can: wAppIconGetIcon(aicon) == NULL ? */ + int x = wAppIconGetXPos(aicon), y = wAppIconGetYPos(aicon); + PlaceIcon(dock->screen_ptr, &x, &y, + wGetHeadForWindow(wAppIconGetIcon(aicon)->owner)); + wAppIconSetXPos(aicon, x); + wAppIconSetYPos(aicon, y); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, x, y); if (!dock->mapped || wDockIsCollapsed(dock)) - XMapWindow(dpy, aicon->icon->core->window); + XMapWindow(dpy, wAppIconGetIcon(aicon)->core->window); } } } @@ -1501,15 +1507,15 @@ void wDockDestroy(WDock *dock) void wClipIconPaint(WAppIcon *aicon) { - WScreen *scr = aicon->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; WWorkspace *workspace = scr->workspaces[scr->current_workspace]; WMColor *color; - Window win = aicon->icon->core->window; + Window win = wAppIconGetIcon(aicon)->core->window; int length, nlength; char *ws_name, ws_number[sizeof scr->current_workspace * CHAR_BIT / 3 + 1]; int ty, tx; - wIconPaint(aicon->icon); + wIconPaint(wAppIconGetIcon(aicon)); length = strlen(workspace->name); ws_name = wmalloc(length + 1); @@ -1535,11 +1541,11 @@ void wClipIconPaint(WAppIcon *aicon) wfree(ws_name); - if (aicon->launching) - XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc, + if (wAppIconIsLaunching(aicon)) + XFillRectangle(dpy, wAppIconGetIcon(aicon)->core->window, scr->stipple_gc, 0, 0, wPreferences.icon_size, wPreferences.icon_size); - paintClipButtons(aicon, aicon->dock->lclip_button_pushed, aicon->dock->rclip_button_pushed); + paintClipButtons(aicon, wAppIconGetDock(aicon)->lclip_button_pushed, wAppIconGetDock(aicon)->rclip_button_pushed); } static void clipIconExpose(WObjDescriptor *desc, XEvent *event) @@ -1553,7 +1559,7 @@ static void clipIconExpose(WObjDescriptor *desc, XEvent *event) static void dockIconPaint(WAppIcon *btn) { - if (btn == btn->icon->core->screen_ptr->clip_icon) { + if (btn == wAppIconGetIcon(btn)->core->screen_ptr->clip_icon) { wClipIconPaint(btn); } else if (wIsADrawer(btn)) { wDrawerIconPaint(btn); @@ -1572,29 +1578,29 @@ static WMPropList *make_icon_state(WAppIcon *btn) char buffer[64]; if (btn) { - if (!btn->command) + if (!wAppIconGetCommand(btn)) command = WMCreatePLString("-"); else - command = WMCreatePLString(btn->command); + command = WMCreatePLString(wAppIconGetCommand(btn)); - autolaunch = btn->auto_launch ? dYes : dNo; + autolaunch = wAppIconIsAutoLaunch(btn) ? dYes : dNo; - lock = btn->lock ? dYes : dNo; + lock = wAppIconIsLocked(btn) ? dYes : dNo; - tmp = EscapeWM_CLASS(btn->wm_instance, btn->wm_class); + tmp = EscapeWM_CLASS(wAppIconGetWmInstance(btn), wAppIconGetWmClass(btn)); name = WMCreatePLString(tmp); wfree(tmp); - forced = btn->forced_dock ? dYes : dNo; + forced = wAppIconIsForceDocked(btn) ? dYes : dNo; - buggy = btn->buggy_app ? dYes : dNo; + buggy = wAppIconIsBuggyApp(btn) ? dYes : dNo; - 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); + if (!wPreferences.flags.clip_merged_in_dock && btn == wAppIconGetIcon(btn)->core->screen_ptr->clip_icon) + snprintf(buffer, sizeof(buffer), "%i,%i", wAppIconGetXPos(btn), wAppIconGetYPos(btn)); else - snprintf(buffer, sizeof(buffer), "%hi,%hi", btn->xindex, btn->yindex); + snprintf(buffer, sizeof(buffer), "%hi,%hi", wAppIconGetXIndex(btn), wAppIconGetYIndex(btn)); position = WMCreatePLString(buffer); node = WMCreatePLDictionary(dCommand, command, @@ -1606,20 +1612,20 @@ static WMPropList *make_icon_state(WAppIcon *btn) WMReleasePropList(name); WMReleasePropList(position); - omnipresent = btn->omnipresent ? dYes : dNo; - if (btn->dock != btn->icon->core->screen_ptr->dock && (btn->xindex != 0 || btn->yindex != 0)) + omnipresent = wAppIconIsOmnipresent(btn) ? dYes : dNo; + if (wAppIconGetDock(btn) != wAppIconGetIcon(btn)->core->screen_ptr->dock && (wAppIconGetXIndex(btn) != 0 || wAppIconGetYIndex(btn) != 0)) WMPutInPLDictionary(node, dOmnipresent, omnipresent); #ifdef USE_DOCK_XDND - if (btn->dnd_command) { - command = WMCreatePLString(btn->dnd_command); + if (wAppIconGetDnDCommand(btn)) { + command = WMCreatePLString(wAppIconGetDnDCommand(btn)); WMPutInPLDictionary(node, dDropCommand, command); WMReleasePropList(command); } #endif /* USE_DOCK_XDND */ - if (btn->paste_command) { - command = WMCreatePLString(btn->paste_command); + if (wAppIconGetPasteCommand(btn)) { + command = WMCreatePLString(wAppIconGetPasteCommand(btn)); WMPutInPLDictionary(node, dPasteCommand, command); WMReleasePropList(command); } @@ -1641,7 +1647,7 @@ static WMPropList *dockSaveState(WDock *dock) for (i = (dock->type == WM_DOCK ? 0 : 1); i < dock->max_icons; i++) { WAppIcon *btn = dock->icon_array[i]; - if (!btn || btn->attracted) + if (!btn || wAppIconIsAttracted(btn)) continue; icon_info = make_icon_state(dock->icon_array[i]); @@ -1791,65 +1797,67 @@ static WAppIcon *restore_icon_state(WScreen *scr, WMPropList *info, int type, in wfree(command); - aicon->icon->core->descriptor.handle_mousedown = iconMouseDown; - aicon->icon->core->descriptor.handle_enternotify = clipEnterNotify; - aicon->icon->core->descriptor.handle_leavenotify = clipLeaveNotify; - aicon->icon->core->descriptor.parent_type = WCLASS_DOCK_ICON; - aicon->icon->core->descriptor.parent = aicon; + wAppIconGetIcon(aicon)->core->descriptor.handle_mousedown = iconMouseDown; + wAppIconGetIcon(aicon)->core->descriptor.handle_enternotify = clipEnterNotify; + wAppIconGetIcon(aicon)->core->descriptor.handle_leavenotify = clipLeaveNotify; + wAppIconGetIcon(aicon)->core->descriptor.parent_type = WCLASS_DOCK_ICON; + wAppIconGetIcon(aicon)->core->descriptor.parent = aicon; #ifdef USE_DOCK_XDND cmd = WMGetFromPLDictionary(info, dDropCommand); if (cmd) - aicon->dnd_command = wstrdup(WMGetFromPLString(cmd)); + wAppIconSetDnDCommand(aicon, wstrdup(WMGetFromPLString(cmd))); #endif cmd = WMGetFromPLDictionary(info, dPasteCommand); if (cmd) - aicon->paste_command = wstrdup(WMGetFromPLString(cmd)); + wAppIconSetPasteCommand(aicon, wstrdup(WMGetFromPLString(cmd))); /* check auto launch */ value = WMGetFromPLDictionary(info, dAutoLaunch); - aicon->auto_launch = getBooleanDockValue(value, dAutoLaunch); + wAppIconSetAutoLaunch(aicon, getBooleanDockValue(value, dAutoLaunch)); /* check lock */ value = WMGetFromPLDictionary(info, dLock); - aicon->lock = getBooleanDockValue(value, dLock); + wAppIconSetLocked(aicon, getBooleanDockValue(value, dLock)); /* check if it wasn't normally docked */ value = WMGetFromPLDictionary(info, dForced); - aicon->forced_dock = getBooleanDockValue(value, dForced); + wAppIconSetForceDocked(aicon, getBooleanDockValue(value, dForced)); /* check if we can rely on the stuff in the app */ value = WMGetFromPLDictionary(info, dBuggyApplication); - aicon->buggy_app = getBooleanDockValue(value, dBuggyApplication); + wAppIconSetBuggyApp(aicon, getBooleanDockValue(value, dBuggyApplication)); /* get position in the dock */ value = WMGetFromPLDictionary(info, dPosition); if (value && WMIsPLString(value)) { - if (sscanf(WMGetFromPLString(value), "%hi,%hi", &aicon->xindex, &aicon->yindex) != 2) + short x = wAppIconGetXIndex(aicon), y = wAppIconGetYIndex(aicon); + if (sscanf(WMGetFromPLString(value), "%hi,%hi", &x, &y) != 2) wwarning(_("bad value in docked icon state info %s"), WMGetFromPLString(dPosition)); - + wAppIconSetXIndex(aicon, x); + wAppIconSetYIndex(aicon, y); /* check position sanity */ /* *Very* incomplete section! */ if (type == WM_DOCK) { - aicon->xindex = 0; + wAppIconSetXIndex(aicon, 0); } } else { - aicon->yindex = index; - aicon->xindex = 0; + wAppIconSetYIndex(aicon, index); + wAppIconSetXIndex(aicon, 0); } /* check if icon is omnipresent */ value = WMGetFromPLDictionary(info, dOmnipresent); - aicon->omnipresent = getBooleanDockValue(value, dOmnipresent); + wAppIconSetOmnipresent(aicon, getBooleanDockValue(value, dOmnipresent)); - aicon->running = 0; - aicon->docked = 1; + wAppIconSetRunning(aicon, 0); + wAppIconSetDocked(aicon, 1); return aicon; } @@ -1876,23 +1884,29 @@ WAppIcon *wClipRestoreState(WScreen *scr, WMPropList *clip_state) if (!WMIsPLString(value)) { COMPLAIN("Position"); } else { - if (sscanf(WMGetFromPLString(value), "%i,%i", &icon->x_pos, &icon->y_pos) != 2) + int x = wAppIconGetXPos(icon), y = wAppIconGetYPos(icon); + if (sscanf(WMGetFromPLString(value), "%i,%i", &x, &y) != 2) COMPLAIN("Position"); + wAppIconSetXPos(icon, x); + wAppIconSetYPos(icon, y); /* check position sanity */ - if (!onScreen(scr, icon->x_pos, icon->y_pos)) - wScreenKeepInside(scr, &icon->x_pos, &icon->y_pos, ICON_SIZE, ICON_SIZE); + if (!onScreen(scr, x, y)) { + wScreenKeepInside(scr, &x, &y, ICON_SIZE, ICON_SIZE); + wAppIconSetXPos(icon, x); + wAppIconSetYPos(icon, y); + } } } #ifdef USE_DOCK_XDND value = WMGetFromPLDictionary(clip_state, dDropCommand); if (value && WMIsPLString(value)) - icon->dnd_command = wstrdup(WMGetFromPLString(value)); + wAppIconSetDnDCommand(icon, wstrdup(WMGetFromPLString(value))); #endif value = WMGetFromPLDictionary(clip_state, dPasteCommand); if (value && WMIsPLString(value)) - icon->paste_command = wstrdup(WMGetFromPLString(value)); + wAppIconSetPasteCommand(icon, wstrdup(WMGetFromPLString(value))); WMReleasePropList(clip_state); @@ -2069,20 +2083,20 @@ WDock *wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) dock->icon_array[dock->icon_count] = aicon; if (aicon) { - aicon->dock = dock; - aicon->x_pos = dock->x_pos + (aicon->xindex * ICON_SIZE); - aicon->y_pos = dock->y_pos + (aicon->yindex * ICON_SIZE); + wAppIconSetDock(aicon, dock); + wAppIconSetXPos(aicon, dock->x_pos + (wAppIconGetXIndex(aicon) * ICON_SIZE)); + wAppIconSetYPos(aicon, dock->y_pos + (wAppIconGetYIndex(aicon) * ICON_SIZE)); if (dock->lowered) - ChangeStackingLevel(aicon->icon->core, WMNormalLevel); + ChangeStackingLevel(wAppIconGetIcon(aicon)->core, WMNormalLevel); else - ChangeStackingLevel(aicon->icon->core, WMDockLevel); + ChangeStackingLevel(wAppIconGetIcon(aicon)->core, WMDockLevel); - wCoreConfigure(aicon->icon->core, aicon->x_pos, aicon->y_pos, 0, 0); + wCoreConfigure(wAppIconGetIcon(aicon)->core, wAppIconGetXPos(aicon), wAppIconGetYPos(aicon), 0, 0); if (!dock->collapsed) - XMapWindow(dpy, aicon->icon->core->window); + XMapWindow(dpy, wAppIconGetIcon(aicon)->core->window); - wRaiseFrame(aicon->icon->core); + wRaiseFrame(wAppIconGetIcon(aicon)->core); dock->icon_count++; } else if (dock->icon_count == 0 && type == WM_DOCK) { @@ -2093,15 +2107,15 @@ WDock *wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) /* if the first icon is not defined, use the default */ if (dock->icon_array[0] == NULL) { /* update default icon */ - old_top->x_pos = dock->x_pos; - old_top->y_pos = dock->y_pos; + wAppIconSetXPos(old_top, dock->x_pos); + wAppIconSetYPos(old_top, dock->y_pos); if (dock->lowered) - ChangeStackingLevel(old_top->icon->core, WMNormalLevel); + ChangeStackingLevel(wAppIconGetIcon(old_top)->core, WMNormalLevel); else - ChangeStackingLevel(old_top->icon->core, WMDockLevel); + ChangeStackingLevel(wAppIconGetIcon(old_top)->core, WMDockLevel); dock->icon_array[0] = old_top; - XMoveWindow(dpy, old_top->icon->core->window, dock->x_pos, dock->y_pos); + XMoveWindow(dpy, wAppIconGetIcon(old_top)->core->window, dock->x_pos, dock->y_pos); /* we don't need to increment dock->icon_count here because it was * incremented in the loop above. */ @@ -2120,15 +2134,15 @@ finish: void wDockLaunchWithState(WAppIcon *btn, WSavedState *state) { - if (btn && btn->command && !btn->running && !btn->launching) { - btn->drop_launch = 0; - btn->paste_launch = 0; + if (btn && wAppIconGetCommand(btn) && !wAppIconIsRunning(btn) && !wAppIconIsLaunching(btn)) { + wAppIconSetDropLaunch(btn, 0); + wAppIconSetPasteLaunch(btn, 0); - btn->pid = execCommand(btn, btn->command, state); + wAppIconSetPid(btn, execCommand(btn, wAppIconGetCommand(btn), state)); - if (btn->pid > 0) { - if (!btn->forced_dock && !btn->buggy_app) { - btn->launching = 1; + if (wAppIconGetPid(btn) > 0) { + if (!wAppIconIsForceDocked(btn) && !wAppIconIsBuggyApp(btn)) { + wAppIconSetLaunching(btn, 1); dockIconPaint(btn); } } @@ -2145,7 +2159,7 @@ void wDockDoAutoLaunch(WDock *dock, int workspace) for (i = 0; i < dock->max_icons; i++) { btn = dock->icon_array[i]; - if (!btn || !btn->auto_launch) + if (!btn || !wAppIconIsAutoLaunch(btn)) continue; state = wmalloc(sizeof(WSavedState)); @@ -2166,7 +2180,7 @@ static WDock *findDock(WScreen *scr, XEvent *event, int *icon_pos) if (dock != NULL) { for (i = 0; i < dock->max_icons; i++) { if (dock->icon_array[i] && - dock->icon_array[i]->icon->core->window == event->xclient.window) { + wAppIconGetIcon(dock->icon_array[i])->core->window == event->xclient.window) { *icon_pos = i; return dock; } @@ -2177,7 +2191,7 @@ static WDock *findDock(WScreen *scr, XEvent *event, int *icon_pos) if (dock != NULL) { for (i = 0; i < dock->max_icons; i++) { if (dock->icon_array[i] && - dock->icon_array[i]->icon->core->window == event->xclient.window) { + wAppIconGetIcon(dock->icon_array[i])->core->window == event->xclient.window) { *icon_pos = i; return dock; } @@ -2203,39 +2217,39 @@ int wDockReceiveDNDDrop(WScreen *scr, XEvent *event) * In this case, let the ClientMessage handler redirect the * message to the app. */ - if (dock->icon_array[icon_pos]->icon->icon_win != None) + if (wAppIconGetIcon(dock->icon_array[icon_pos])->icon_win != None) return True; - if (dock->icon_array[icon_pos]->dnd_command != NULL) { + if (wAppIconGetDnDCommand(dock->icon_array[icon_pos]) != NULL) { scr->flags.dnd_data_convertion_status = 0; btn = dock->icon_array[icon_pos]; - if (!btn->forced_dock) { - btn->relaunching = btn->running; - btn->running = 1; + if (!wAppIconIsForceDocked(btn)) { + wAppIconSetRelaunching(btn, wAppIconIsRunning(btn)); + wAppIconSetRunning(btn, 1); } - if (btn->wm_instance || btn->wm_class) { + if (wAppIconGetWmInstance(btn) || wAppIconGetWmClass(btn)) { WWindowAttributes attr; memset(&attr, 0, sizeof(WWindowAttributes)); - wDefaultFillAttributes(btn->wm_instance, btn->wm_class, &attr, NULL, True); + wDefaultFillAttributes(wAppIconGetWmInstance(btn), wAppIconGetWmClass(btn), &attr, NULL, True); if (!attr.no_appicon) - btn->launching = 1; + wAppIconSetLaunching(btn, 1); else - btn->running = 0; + wAppIconSetRunning(btn, 0); } - btn->paste_launch = 0; - btn->drop_launch = 1; + wAppIconSetPasteLaunch(btn, 0); + wAppIconSetDropLaunch(btn, 1); scr->last_dock = dock; - btn->pid = execCommand(btn, btn->dnd_command, NULL); - if (btn->pid > 0) { + wAppIconSetPid(btn, execCommand(btn, wAppIconGetDnDCommand(btn), NULL)); + if (wAppIconGetPid(btn) > 0) { dockIconPaint(btn); } else { - btn->launching = 0; - if (!btn->relaunching) - btn->running = 0; + wAppIconSetLaunching(btn, 0); + if (!wAppIconIsRelaunching(btn)) + wAppIconSetRunning(btn, 0); } } return False; @@ -2249,43 +2263,43 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon char *command = NULL; int index; - icon->editing = 0; + wAppIconSetEditing(icon, 0); if (update_icon) lupdate_icon = True; - if (icon->command == NULL) { + if (wAppIconGetCommand(icon) == NULL) { /* If icon->owner exists, it means the application is running */ - if (icon->icon->owner) { - wwin = icon->icon->owner; + if (wAppIconGetIcon(icon)->owner) { + wwin = wAppIconGetIcon(icon)->owner; command = GetCommandForWindow(wwin->client_win); } if (command) { - icon->command = command; + wAppIconSetCommand(icon, command); } else { /* icon->forced_dock = 1; */ - if (dock->type != WM_CLIP || !icon->attracted) { - icon->editing = 1; + if (dock->type != WM_CLIP || !wAppIconIsAttracted(icon)) { + wAppIconSetEditing(icon, 1); if (wInputDialog(dock->screen_ptr, _("Dock Icon"), _("Type the command used to launch the application"), &command)) { if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { wfree(command); command = NULL; } - icon->command = command; - icon->editing = 0; + wAppIconSetCommand(icon, command); + wAppIconSetEditing(icon, 0); } else { - icon->editing = 0; + wAppIconSetEditing(icon, 0); if (command) wfree(command); /* If the target is the dock, reject the icon. If * the target is the clip, make it an attracted icon */ if (dock->type == WM_CLIP) { - icon->attracted = 1; - if (!icon->icon->shadowed) { - icon->icon->shadowed = 1; + wAppIconSetAttracted(icon, 1); + if (!wAppIconGetIcon(icon)->shadowed) { + wAppIconGetIcon(icon)->shadowed = 1; lupdate_icon = True; } } else { @@ -2305,35 +2319,35 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon assert(index < dock->max_icons); dock->icon_array[index] = icon; - icon->yindex = y; - icon->xindex = x; + wAppIconSetYIndex(icon, y); + wAppIconSetXIndex(icon, x); - icon->omnipresent = 0; + wAppIconSetOmnipresent(icon, 0); - icon->x_pos = dock->x_pos + x * ICON_SIZE; - icon->y_pos = dock->y_pos + y * ICON_SIZE; + wAppIconSetXPos(icon, dock->x_pos + x * ICON_SIZE); + wAppIconSetYPos(icon, dock->y_pos + y * ICON_SIZE); dock->icon_count++; - icon->running = 1; - icon->launching = 0; - icon->docked = 1; - icon->dock = dock; - icon->icon->core->descriptor.handle_mousedown = iconMouseDown; - icon->icon->core->descriptor.handle_enternotify = clipEnterNotify; - icon->icon->core->descriptor.handle_leavenotify = clipLeaveNotify; - icon->icon->core->descriptor.parent_type = WCLASS_DOCK_ICON; - icon->icon->core->descriptor.parent = icon; + wAppIconSetRunning(icon, 1); + wAppIconSetLaunching(icon, 0); + wAppIconSetDocked(icon, 1); + wAppIconSetDock(icon, dock); + wAppIconGetIcon(icon)->core->descriptor.handle_mousedown = iconMouseDown; + wAppIconGetIcon(icon)->core->descriptor.handle_enternotify = clipEnterNotify; + wAppIconGetIcon(icon)->core->descriptor.handle_leavenotify = clipLeaveNotify; + wAppIconGetIcon(icon)->core->descriptor.parent_type = WCLASS_DOCK_ICON; + wAppIconGetIcon(icon)->core->descriptor.parent = icon; - MoveInStackListUnder(dock->icon_array[index - 1]->icon->core, icon->icon->core); - wAppIconMove(icon, icon->x_pos, icon->y_pos); + MoveInStackListUnder(wAppIconGetIcon(dock->icon_array[index - 1])->core, wAppIconGetIcon(icon)->core); + wAppIconMove(icon, wAppIconGetXPos(icon), wAppIconGetYPos(icon)); /* * Update icon pixmap, RImage doesn't change, * so call wIconUpdate is not needed */ if (lupdate_icon) - update_icon_pixmap(icon->icon); + update_icon_pixmap(wAppIconGetIcon(icon)); /* Paint it */ wAppIconPaint(icon); @@ -2345,17 +2359,17 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon wArrangeIcons(dock->screen_ptr, True); #ifdef USE_DOCK_XDND - if (icon->command && !icon->dnd_command) { - int len = strlen(icon->command) + 8; - icon->dnd_command = wmalloc(len); - snprintf(icon->dnd_command, len, "%s %%d", icon->command); + if (wAppIconGetCommand(icon) && !wAppIconGetDnDCommand(icon)) { + int len = strlen(wAppIconGetCommand(icon)) + 8; + wAppIconSetDnDCommand(icon, wmalloc(len)); + snprintf(wAppIconGetDnDCommand(icon), len, "%s %%d", wAppIconGetCommand(icon)); } #endif - if (icon->command && !icon->paste_command) { - int len = strlen(icon->command) + 8; - icon->paste_command = wmalloc(len); - snprintf(icon->paste_command, len, "%s %%s", icon->command); + if (wAppIconGetCommand(icon) && !wAppIconGetPasteCommand(icon)) { + int len = strlen(wAppIconGetCommand(icon)) + 8; + wAppIconSetPasteCommand(icon, wmalloc(len)); + snprintf(wAppIconGetPasteCommand(icon), len, "%s %%s", wAppIconGetCommand(icon)); } return True; @@ -2371,11 +2385,11 @@ void wDockReattachIcon(WDock *dock, WAppIcon *icon, int x, int y) } assert(index < dock->max_icons); - icon->yindex = y; - icon->xindex = x; + wAppIconSetYIndex(icon, y); + wAppIconSetXIndex(icon, x); - icon->x_pos = dock->x_pos + x * ICON_SIZE; - icon->y_pos = dock->y_pos + y * ICON_SIZE; + wAppIconSetXPos(icon, dock->x_pos + x * ICON_SIZE); + wAppIconSetYPos(icon, dock->y_pos + y * ICON_SIZE); } Bool wDockMoveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y) @@ -2397,17 +2411,17 @@ Bool wDockMoveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, i * command, the dialog box will not be able to tell us to which of the * moved icons it applies. -Dan */ - if ((dest->type == WM_DOCK /*|| dest->keep_attracted */ ) && icon->command == NULL) { + if ((dest->type == WM_DOCK /*|| dest->keep_attracted */ ) && wAppIconGetCommand(icon) == NULL) { /* If icon->owner exists, it means the application is running */ - if (icon->icon->owner) { - wwin = icon->icon->owner; + if (wAppIconGetIcon(icon)->owner) { + wwin = wAppIconGetIcon(icon)->owner; command = GetCommandForWindow(wwin->client_win); } if (command) { - icon->command = command; + wAppIconSetCommand(icon, command); } else { - icon->editing = 1; + wAppIconSetEditing(icon, 1); /* icon->forced_dock = 1; */ if (wInputDialog(src->screen_ptr, _("Dock Icon"), _("Type the command used to launch the application"), &command)) { @@ -2415,14 +2429,14 @@ Bool wDockMoveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, i wfree(command); command = NULL; } - icon->command = command; + wAppIconSetCommand(icon, command); } else { - icon->editing = 0; + wAppIconSetEditing(icon, 0); if (command) wfree(command); return False; } - icon->editing = 0; + wAppIconSetEditing(icon, 0); } } @@ -2446,22 +2460,22 @@ Bool wDockMoveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, i assert(index < dest->max_icons); dest->icon_array[index] = icon; - icon->dock = dest; + wAppIconSetDock(icon, dest); /* deselect the icon */ - if (icon->icon->selected) - wIconSelect(icon->icon); + if (wAppIconGetIcon(icon)->selected) + wIconSelect(wAppIconGetIcon(icon)); - icon->icon->core->descriptor.handle_enternotify = clipEnterNotify; - icon->icon->core->descriptor.handle_leavenotify = clipLeaveNotify; + wAppIconGetIcon(icon)->core->descriptor.handle_enternotify = clipEnterNotify; + wAppIconGetIcon(icon)->core->descriptor.handle_leavenotify = clipLeaveNotify; /* set it to be kept when moving to dock. * Unless the icon does not have a command set */ - if (icon->command && (dest->type == WM_DOCK || dest->type == WM_DRAWER)) { - icon->attracted = 0; - if (icon->icon->shadowed) { - icon->icon->shadowed = 0; + if (wAppIconGetCommand(icon) && (dest->type == WM_DOCK || dest->type == WM_DRAWER)) { + wAppIconSetAttracted(icon, 0); + if (wAppIconGetIcon(icon)->shadowed) { + wAppIconGetIcon(icon)->shadowed = 0; update_icon = True; } } @@ -2469,22 +2483,22 @@ Bool wDockMoveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, i if (src->auto_collapse || src->auto_raise_lower) clipLeave(src); - icon->yindex = y; - icon->xindex = x; + wAppIconSetYIndex(icon, y); + wAppIconSetXIndex(icon, x); - icon->x_pos = dest->x_pos + x * ICON_SIZE; - icon->y_pos = dest->y_pos + y * ICON_SIZE; + wAppIconSetXPos(icon, dest->x_pos + x * ICON_SIZE); + wAppIconSetYPos(icon, dest->y_pos + y * ICON_SIZE); dest->icon_count++; - MoveInStackListUnder(dest->icon_array[index - 1]->icon->core, icon->icon->core); + MoveInStackListUnder(wAppIconGetIcon(dest->icon_array[index - 1])->core, wAppIconGetIcon(icon)->core); /* * Update icon pixmap, RImage doesn't change, * so call wIconUpdate is not needed */ if (update_icon) - update_icon_pixmap(icon->icon); + update_icon_pixmap(wAppIconGetIcon(icon)); /* Paint it */ wAppIconPaint(icon); @@ -2498,40 +2512,37 @@ void wDockDetach(WDock *dock, WAppIcon *icon) Bool update_icon = False; /* make the settings panel be closed */ - if (icon->panel) - DestroyDockAppSettingsPanel(icon->panel); + if (wAppIconGetPanel(icon)) + DestroyDockAppSettingsPanel(wAppIconGetPanel(icon)); /* This must be called before icon->dock is set to NULL. * Don't move it. -Dan */ wClipMakeIconOmnipresent(icon, False); - icon->docked = 0; - icon->dock = NULL; - icon->attracted = 0; - icon->auto_launch = 0; - if (icon->icon->shadowed) { - icon->icon->shadowed = 0; + wAppIconSetDocked(icon, 0); + wAppIconSetDock(icon, NULL); + wAppIconSetAttracted(icon, 0); + wAppIconSetAutoLaunch(icon, 0); + if (wAppIconGetIcon(icon)->shadowed) { + wAppIconGetIcon(icon)->shadowed = 0; update_icon = True; } /* deselect the icon */ - if (icon->icon->selected) - wIconSelect(icon->icon); + if (wAppIconGetIcon(icon)->selected) + wIconSelect(wAppIconGetIcon(icon)); - if (icon->command) { - wfree(icon->command); - icon->command = NULL; + if (wAppIconGetCommand(icon)) { + wAppIconSetCommand(icon, NULL); } #ifdef USE_DOCK_XDND - if (icon->dnd_command) { - wfree(icon->dnd_command); - icon->dnd_command = NULL; + if (wAppIconGetDnDCommand(icon)) { + wAppIconSetDnDCommand(icon, NULL); } #endif - if (icon->paste_command) { - wfree(icon->paste_command); - icon->paste_command = NULL; + if (wAppIconGetPasteCommand(icon)) { + wAppIconSetPasteCommand(icon, NULL); } for (index = 1; index < dock->max_icons; index++) @@ -2540,34 +2551,34 @@ void wDockDetach(WDock *dock, WAppIcon *icon) assert(index < dock->max_icons); dock->icon_array[index] = NULL; - icon->yindex = -1; - icon->xindex = -1; + wAppIconSetYIndex(icon, -1); + wAppIconSetXIndex(icon, -1); dock->icon_count--; /* Remove the Cached Icon */ - remove_cache_icon(icon->icon->file); + remove_cache_icon(wAppIconGetIcon(icon)->file); /* if the dock is not attached to an application or * the application did not set the appropriate hints yet, * destroy the icon */ - if (!icon->running || !wApplicationOf(icon->main_window)) { + if (!wAppIconIsRunning(icon) || !wApplicationOf(wAppIconGetMainWindow(icon))) { wAppIconDestroy(icon); } else { - icon->icon->core->descriptor.handle_mousedown = appIconMouseDown; - icon->icon->core->descriptor.handle_enternotify = NULL; - icon->icon->core->descriptor.handle_leavenotify = NULL; - icon->icon->core->descriptor.parent_type = WCLASS_APPICON; - icon->icon->core->descriptor.parent = icon; + wAppIconGetIcon(icon)->core->descriptor.handle_mousedown = appIconMouseDown; + wAppIconGetIcon(icon)->core->descriptor.handle_enternotify = NULL; + wAppIconGetIcon(icon)->core->descriptor.handle_leavenotify = NULL; + wAppIconGetIcon(icon)->core->descriptor.parent_type = WCLASS_APPICON; + wAppIconGetIcon(icon)->core->descriptor.parent = icon; - ChangeStackingLevel(icon->icon->core, NORMAL_ICON_LEVEL); + ChangeStackingLevel(wAppIconGetIcon(icon)->core, NORMAL_ICON_LEVEL); /* * Update icon pixmap, RImage doesn't change, * so call wIconUpdate is not needed */ if (update_icon) - update_icon_pixmap(icon->icon); + update_icon_pixmap(wAppIconGetIcon(icon)); /* Paint it */ wAppIconPaint(icon); @@ -2632,8 +2643,8 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x * - we are not right over it, and * - we are not the main tile of a drawer. * In the latter case, we are called from handleDockMove. */ - if (icon->dock != dock && ex_x != 0 && - !(icon->dock && icon->dock->type == WM_DRAWER && icon == icon->dock->icon_array[0])) + if (wAppIconGetDock(icon) != dock && ex_x != 0 && + !(wAppIconGetDock(icon) && wAppIconGetDock(icon)->type == WM_DRAWER && icon == wAppIconGetDock(icon)->icon_array[0])) return False; if (!redocking && ex_x != 0) @@ -2645,7 +2656,7 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x aicon = NULL; for (i = 0; i < dock->max_icons; i++) { nicon = dock->icon_array[i]; - if (nicon && nicon->yindex == ex_y) { + if (nicon && wAppIconGetYIndex(nicon) == ex_y) { aicon = nicon; break; } @@ -2688,7 +2699,7 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x if (onScreen(scr, dx, dy + closest * ICON_SIZE)) { for (j = 0; j < dock->max_icons; j++) { if (dock->icon_array[j] - && dock->icon_array[j]->yindex == closest) { + && wAppIconGetYIndex(dock->icon_array[j]) == closest) { /* slot is used by someone else */ if (dock->icon_array[j] != icon) done = 0; @@ -2724,8 +2735,8 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x int neighbours = 0; int start, stop, k; - start = icon->omnipresent ? 0 : scr->current_workspace; - stop = icon->omnipresent ? scr->workspace_count : start + 1; + start = wAppIconIsOmnipresent(icon) ? 0 : scr->current_workspace; + stop = wAppIconIsOmnipresent(icon) ? scr->workspace_count : start + 1; aicon = NULL; for (k = start; k < stop; k++) { @@ -2734,7 +2745,7 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x continue; for (i = 0; i < tmp->max_icons; i++) { nicon = tmp->icon_array[i]; - if (nicon && nicon->xindex == ex_x && nicon->yindex == ex_y) { + if (nicon && wAppIconGetXIndex(nicon) == ex_x && wAppIconGetYIndex(nicon) == ex_y) { aicon = nicon; break; } @@ -2749,8 +2760,8 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x for (i = 0; i < tmp->max_icons; i++) { nicon = tmp->icon_array[i]; if (nicon && nicon != icon && /* Icon can't be its own neighbour */ - (abs(nicon->xindex - ex_x) <= CLIP_ATTACH_VICINITY && - abs(nicon->yindex - ex_y) <= CLIP_ATTACH_VICINITY)) { + (abs(wAppIconGetXIndex(nicon) - ex_x) <= CLIP_ATTACH_VICINITY && + abs(wAppIconGetYIndex(nicon) - ex_y) <= CLIP_ATTACH_VICINITY)) { neighbours = 1; break; } @@ -2797,8 +2808,8 @@ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, int *ret_x for (i = 1; i < dock->max_icons; i++) { aicon = dock->icon_array[i]; if ((aicon != NULL) && (aicon != icon) && - ((ex_x <= aicon->xindex && aicon->xindex < index_of_hole) || - (index_of_hole < aicon->xindex && aicon->xindex <= ex_x))) + ((ex_x <= wAppIconGetXIndex(aicon) && wAppIconGetXIndex(aicon) < index_of_hole) || + (index_of_hole < wAppIconGetXIndex(aicon) && wAppIconGetXIndex(aicon) <= ex_x))) aicons_to_shift[ j++ ] = aicon; } assert(j == abs(ex_x - index_of_hole)); @@ -2909,17 +2920,17 @@ Bool wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) if (!btn) continue; - if (btn->xindex == 0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex > 0 && btn->xindex < hcount) - hmap[btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) > 0 && wAppIconGetYIndex(btn) < vcount) + vmap[wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) > 0 && wAppIconGetXIndex(btn) < hcount) + hmap[wAppIconGetXIndex(btn)] = 1; } for (chain = scr->global_icons; chain != NULL; chain = chain->next) { btn = chain->aicon; - if (btn->xindex == 0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex > 0 && btn->xindex < hcount) - hmap[btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) > 0 && wAppIconGetYIndex(btn) < vcount) + vmap[wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) > 0 && wAppIconGetXIndex(btn) < hcount) + hmap[wAppIconGetXIndex(btn)] = 1; } break; case C_NW: @@ -2928,17 +2939,17 @@ Bool wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) if (!btn) continue; - if (btn->xindex == 0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex < 0 && btn->xindex > -hcount) - hmap[-btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) > 0 && wAppIconGetYIndex(btn) < vcount) + vmap[wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) < 0 && wAppIconGetXIndex(btn) > -hcount) + hmap[-wAppIconGetXIndex(btn)] = 1; } for (chain = scr->global_icons; chain != NULL; chain = chain->next) { btn = chain->aicon; - if (btn->xindex == 0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex < 0 && btn->xindex > -hcount) - hmap[-btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) > 0 && wAppIconGetYIndex(btn) < vcount) + vmap[wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) < 0 && wAppIconGetXIndex(btn) > -hcount) + hmap[-wAppIconGetXIndex(btn)] = 1; } break; case C_SE: @@ -2947,17 +2958,17 @@ Bool wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) if (!btn) continue; - if (btn->xindex == 0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex > 0 && btn->xindex < hcount) - hmap[btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) < 0 && wAppIconGetYIndex(btn) > -vcount) + vmap[-wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) > 0 && wAppIconGetXIndex(btn) < hcount) + hmap[wAppIconGetXIndex(btn)] = 1; } for (chain = scr->global_icons; chain != NULL; chain = chain->next) { btn = chain->aicon; - if (btn->xindex == 0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex > 0 && btn->xindex < hcount) - hmap[btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) < 0 && wAppIconGetYIndex(btn) > -vcount) + vmap[-wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) > 0 && wAppIconGetXIndex(btn) < hcount) + hmap[wAppIconGetXIndex(btn)] = 1; } break; case C_SW: @@ -2967,17 +2978,17 @@ Bool wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) if (!btn) continue; - if (btn->xindex == 0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex < 0 && btn->xindex > -hcount) - hmap[-btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) < 0 && wAppIconGetYIndex(btn) > -vcount) + vmap[-wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) < 0 && wAppIconGetXIndex(btn) > -hcount) + hmap[-wAppIconGetXIndex(btn)] = 1; } for (chain = scr->global_icons; chain != NULL; chain = chain->next) { btn = chain->aicon; - if (btn->xindex == 0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex == 0 && btn->xindex < 0 && btn->xindex > -hcount) - hmap[-btn->xindex] = 1; + if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) < 0 && wAppIconGetYIndex(btn) > -vcount) + vmap[-wAppIconGetYIndex(btn)] = 1; + else if (wAppIconGetYIndex(btn) == 0 && wAppIconGetXIndex(btn) < 0 && wAppIconGetXIndex(btn) > -hcount) + hmap[-wAppIconGetXIndex(btn)] = 1; } } x = 0; @@ -3039,11 +3050,11 @@ Bool wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) for (i = 0; i < dock->max_icons; i++) { btn = dock->icon_array[i]; if (btn) - slot_map[XY2OFS(btn->xindex, btn->yindex)] = 1; + slot_map[XY2OFS(wAppIconGetXIndex(btn), wAppIconGetYIndex(btn))] = 1; } for (chain = scr->global_icons; chain != NULL; chain = chain->next) - slot_map[XY2OFS(chain->aicon->xindex, chain->aicon->yindex)] = 1; + slot_map[XY2OFS(wAppIconGetXIndex(chain->aicon), wAppIconGetYIndex(chain->aicon))] = 1; /* Find closest slot from the center that is free by scanning the * map from the center to outward in circular passes. @@ -3116,9 +3127,9 @@ static void moveDock(WDock *dock, int new_x, int new_y) for (i = 0; i < dock->max_icons; i++) { btn = dock->icon_array[i]; if (btn) { - btn->x_pos = new_x + btn->xindex * ICON_SIZE; - btn->y_pos = new_y + btn->yindex * ICON_SIZE; - XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); + wAppIconSetXPos(btn, new_x + wAppIconGetXIndex(btn) * ICON_SIZE); + wAppIconSetYPos(btn, new_y + wAppIconGetYIndex(btn) * ICON_SIZE); + XMoveWindow(dpy, wAppIconGetIcon(btn)->core->window, wAppIconGetXPos(btn), wAppIconGetYPos(btn)); } } } @@ -3136,8 +3147,8 @@ void wDockSwap(WDock *dock) for (i = 0; i < dock->max_icons; i++) { btn = dock->icon_array[i]; if (btn) { - btn->x_pos = x; - XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); + wAppIconSetXPos(btn, x); + XMoveWindow(dpy, wAppIconGetIcon(btn)->core->window, wAppIconGetXPos(btn), wAppIconGetYPos(btn)); } } @@ -3146,7 +3157,7 @@ void wDockSwap(WDock *dock) static pid_t execCommand(WAppIcon *btn, const char *command, WSavedState *state) { - WScreen *scr = btn->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(btn)->core->screen_ptr; pid_t pid; char **argv; int argc; @@ -3202,13 +3213,13 @@ static pid_t execCommand(WAppIcon *btn, const char *command, WSavedState *state) state->hidden = -1; state->miniaturized = -1; state->shaded = -1; - if (btn->dock == scr->dock || btn->dock->type == WM_DRAWER || btn->omnipresent) + if (wAppIconGetDock(btn) == scr->dock || wAppIconGetDock(btn)->type == WM_DRAWER || wAppIconIsOmnipresent(btn)) state->workspace = -1; else state->workspace = scr->current_workspace; } - wWindowAddSavedState(btn->wm_instance, btn->wm_class, cmdline, pid, state); - wAddDeathHandler(pid, trackDeadProcess, btn->dock); + wWindowAddSavedState(wAppIconGetWmInstance(btn), wAppIconGetWmClass(btn), cmdline, pid, state); + wAddDeathHandler(pid, trackDeadProcess, wAppIconGetDock(btn)); } else if (state) { wfree(state); } @@ -3225,7 +3236,7 @@ void wDockHideIcons(WDock *dock) for (i = 1; i < dock->max_icons; i++) { if (dock->icon_array[i]) - XUnmapWindow(dpy, dock->icon_array[i]->icon->core->window); + XUnmapWindow(dpy, wAppIconGetIcon(dock->icon_array[i])->core->window); } dock->mapped = 0; @@ -3241,7 +3252,7 @@ void wDockShowIcons(WDock *dock) return; btn = dock->icon_array[0]; - moveDock(dock, btn->x_pos, btn->y_pos); + moveDock(dock, wAppIconGetXPos(btn), wAppIconGetYPos(btn)); /* Deleting any change in stacking level, this function is now only about mapping icons */ @@ -3249,7 +3260,7 @@ void wDockShowIcons(WDock *dock) if (!dock->collapsed) { for (i = 1; i < dock->max_icons; i++) { if (dock->icon_array[i]) - XMapWindow(dpy, dock->icon_array[i]->icon->core->window); + XMapWindow(dpy, wAppIconGetIcon(dock->icon_array[i])->core->window); } } dock->mapped = 1; @@ -3268,7 +3279,7 @@ void wDockLower(WDock *dock) } for (i = 0; i < dock->max_icons; i++) { if (dock->icon_array[i]) - wLowerFrame(dock->icon_array[i]->icon->core); + wLowerFrame(wAppIconGetIcon(dock->icon_array[i])->core); } } @@ -3279,7 +3290,7 @@ void wDockRaise(WDock *dock) for (i = dock->max_icons - 1; i >= 0; i--) { if (dock->icon_array[i]) - wRaiseFrame(dock->icon_array[i]->icon->core); + wRaiseFrame(wAppIconGetIcon(dock->icon_array[i])->core); } if (dock->type == WM_DOCK) { for (dc = dock->screen_ptr->drawers; dc != NULL; dc = dc->next) @@ -3289,9 +3300,9 @@ void wDockRaise(WDock *dock) void wDockRaiseLower(WDock *dock) { - if (!dock->icon_array[0]->icon->core->stacking->above - || (dock->icon_array[0]->icon->core->stacking->window_level - != dock->icon_array[0]->icon->core->stacking->above->stacking->window_level)) + if (!wAppIconGetIcon(dock->icon_array[0])->core->stacking->above + || (wAppIconGetIcon(dock->icon_array[0])->core->stacking->window_level + != wAppIconGetIcon(dock->icon_array[0])->core->stacking->above->stacking->window_level)) wDockLower(dock); else wDockRaise(dock); @@ -3299,8 +3310,8 @@ void wDockRaiseLower(WDock *dock) void wDockFinishLaunch(WAppIcon *icon) { - icon->launching = 0; - icon->relaunching = 0; + wAppIconSetLaunching(icon, 0); + wAppIconSetRelaunching(icon, 0); dockIconPaint(icon); } @@ -3311,7 +3322,7 @@ WAppIcon *wDockFindIconForWindow(WDock *dock, Window window) for (i = 0; i < dock->max_icons; i++) { icon = dock->icon_array[i]; - if (icon && icon->main_window == window) + if (icon && wAppIconGetMainWindow(icon) == window) return icon; } return NULL; @@ -3340,24 +3351,24 @@ void wDockTrackWindowLaunch(WDock *dock, Window window) continue; /* app is already attached to icon */ - if (icon->main_window == window) { + if (wAppIconGetMainWindow(icon) == window) { found = True; break; } - if ((icon->wm_instance || icon->wm_class) - && (icon->launching || !icon->running)) { + if ((wAppIconGetWmInstance(icon) || wAppIconGetWmClass(icon)) + && (wAppIconIsLaunching(icon) || !wAppIconIsRunning(icon))) { - if (icon->wm_instance && wm_instance && strcmp(icon->wm_instance, wm_instance) != 0) + if (wAppIconGetWmInstance(icon) && wm_instance && strcmp(wAppIconGetWmInstance(icon), wm_instance) != 0) continue; - if (icon->wm_class && wm_class && strcmp(icon->wm_class, wm_class) != 0) + if (wAppIconGetWmClass(icon) && wm_class && strcmp(wAppIconGetWmClass(icon), wm_class) != 0) continue; - if (firstPass && command && strcmp(icon->command, command) != 0) + if (firstPass && command && strcmp(wAppIconGetCommand(icon), command) != 0) continue; - if (!icon->relaunching) { + if (!wAppIconIsRelaunching(icon)) { WApplication *wapp; /* Possibly an application that was docked with dockit, @@ -3365,34 +3376,34 @@ void wDockTrackWindowLaunch(WDock *dock, Window window) * it was docked by force */ wapp = wApplicationOf(window); if (!wapp) { - icon->forced_dock = 1; - icon->running = 0; + wAppIconSetForceDocked(icon, 1); + wAppIconSetRunning(icon, 0); } - if (!icon->forced_dock) - icon->main_window = window; + if (!wAppIconIsForceDocked(icon)) + wAppIconSetMainWindow(icon, window); } found = True; - if (!wPreferences.no_animations && !icon->launching && + if (!wPreferences.no_animations && !wAppIconIsLaunching(icon) && !dock->screen_ptr->flags.startup && !dock->collapsed) { WAppIcon *aicon; int x0, y0; - icon->launching = 1; + wAppIconSetLaunching(icon, 1); dockIconPaint(icon); aicon = wAppIconCreateForDock(dock->screen_ptr, NULL, wm_instance, wm_class, TILE_NORMAL); - /* XXX: can: aicon->icon == NULL ? */ - PlaceIcon(dock->screen_ptr, &x0, &y0, wGetHeadForWindow(aicon->icon->owner)); + /* XXX: can: wAppIconGetIcon(aicon) == NULL ? */ + PlaceIcon(dock->screen_ptr, &x0, &y0, wGetHeadForWindow(wAppIconGetIcon(aicon)->owner)); wAppIconMove(aicon, x0, y0); /* Should this always be lowered? -Dan */ if (dock->lowered) - wLowerFrame(aicon->icon->core); - XMapWindow(dpy, aicon->icon->core->window); - aicon->launching = 1; + wLowerFrame(wAppIconGetIcon(aicon)->core); + XMapWindow(dpy, wAppIconGetIcon(aicon)->core->window); + wAppIconSetLaunching(aicon, 1); wAppIconPaint(aicon); - slide_window(aicon->icon->core->window, x0, y0, icon->x_pos, icon->y_pos); - XUnmapWindow(dpy, aicon->icon->core->window); + slide_window(wAppIconGetIcon(aicon)->core->window, x0, y0, wAppIconGetXPos(icon), wAppIconGetYPos(icon)); + XUnmapWindow(dpy, wAppIconGetIcon(aicon)->core->window); wAppIconDestroy(aicon); } wDockFinishLaunch(icon); @@ -3417,17 +3428,17 @@ void wDockTrackWindowLaunch(WDock *dock, Window window) void wClipUpdateForWorkspaceChange(WScreen *scr, int workspace) { if (!wPreferences.flags.noclip) { - scr->clip_icon->dock = scr->workspaces[workspace]->clip; + wAppIconSetDock(scr->clip_icon, scr->workspaces[workspace]->clip); if (scr->current_workspace != workspace) { WDock *old_clip = scr->workspaces[scr->current_workspace]->clip; WAppIconChain *chain = scr->global_icons; while (chain) { - wDockMoveIconBetweenDocks(chain->aicon->dock, + wDockMoveIconBetweenDocks(wAppIconGetDock(chain->aicon), scr->workspaces[workspace]->clip, - chain->aicon, chain->aicon->xindex, chain->aicon->yindex); + chain->aicon, wAppIconGetXIndex(chain->aicon), wAppIconGetYIndex(chain->aicon)); if (scr->workspaces[workspace]->clip->collapsed) - XUnmapWindow(dpy, chain->aicon->icon->core->window); + XUnmapWindow(dpy, wAppIconGetIcon(chain->aicon)->core->window); chain = chain->next; } @@ -3462,26 +3473,26 @@ static void trackDeadProcess(pid_t pid, unsigned int status, void *cdata) if (!icon) continue; - if (icon->launching && icon->pid == pid) { - if (!icon->relaunching) { - icon->running = 0; - icon->main_window = None; + if (wAppIconIsLaunching(icon) && wAppIconGetPid(icon) == pid) { + if (!wAppIconIsRelaunching(icon)) { + wAppIconSetRunning(icon, 0); + wAppIconSetMainWindow(icon, None); } wDockFinishLaunch(icon); - icon->pid = 0; + wAppIconSetPid(icon, 0); if (status == 111) { char msg[PATH_MAX]; char *cmd; #ifdef USE_DOCK_XDND - if (icon->drop_launch) - cmd = icon->dnd_command; + if (wAppIconIsDropLaunch(icon)) + cmd = wAppIconGetDnDCommand(icon); else #endif - if (icon->paste_launch) - cmd = icon->paste_command; + if (wAppIconIsPasteLaunch(icon)) + cmd = wAppIconGetPasteCommand(icon); else - cmd = icon->command; + cmd = wAppIconGetCommand(icon); snprintf(msg, sizeof(msg), _("Could not execute command \"%s\""), cmd); @@ -3515,13 +3526,13 @@ static void toggleLowered(WDock *dock) if (!tmp) continue; - ChangeStackingLevel(tmp->icon->core, newlevel); + ChangeStackingLevel(wAppIconGetIcon(tmp)->core, newlevel); /* When the dock is no longer "on top", explicitly lower it as well. * It saves some CPU cycles (probably) to do it ourselves here * rather than calling wDockLower at the end of toggleLowered */ if (dock->lowered) - wLowerFrame(tmp->icon->core); + wLowerFrame(wAppIconGetIcon(tmp)->core); } if (dock->type == WM_DOCK) { @@ -3552,7 +3563,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) int index = 0; int x_pos; int n_selected; - int appIsRunning = aicon->running && aicon->icon && aicon->icon->owner; + int appIsRunning = wAppIconIsRunning(aicon) && wAppIconGetIcon(aicon) && wAppIconGetIcon(aicon)->owner; if (dock->type == WM_DOCK) { /* Dock position menu */ @@ -3587,7 +3598,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) entry->text = _("Toggle Omnipresent"); } else { entry->flags.indicator = 1; - entry->flags.indicator_on = aicon->omnipresent; + entry->flags.indicator_on = wAppIconIsOmnipresent(aicon); entry->flags.indicator_type = MI_CHECK; entry->text = _("Omnipresent"); } @@ -3597,7 +3608,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) /* select/unselect icon */ entry = dock->menu->entries[++index]; entry->clientdata = aicon; - entry->flags.indicator_on = aicon->icon->selected; + entry->flags.indicator_on = wAppIconGetIcon(aicon)->selected; wMenuSetEnabled(dock->menu, index, aicon != scr->clip_icon && !wIsADrawer(aicon)); /* select/unselect all icons */ @@ -3631,7 +3642,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) if (scr->clip_submenu) updateWorkspaceMenu(scr->clip_submenu, aicon); - wMenuSetEnabled(dock->menu, index, !aicon->omnipresent); + wMenuSetEnabled(dock->menu, index, !wAppIconIsOmnipresent(aicon)); } /* remove icon(s) */ @@ -3652,15 +3663,15 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) wMenuRealize(dock->menu); } - if (aicon->icon->owner) - wapp = wApplicationOf(aicon->icon->owner->main_window); + if (wAppIconGetIcon(aicon)->owner) + wapp = wApplicationOf(wAppIconGetIcon(aicon)->owner->main_window); else wapp = NULL; /* launch */ entry = dock->menu->entries[++index]; entry->clientdata = aicon; - wMenuSetEnabled(dock->menu, index, aicon->command != NULL); + wMenuSetEnabled(dock->menu, index, wAppIconGetCommand(aicon) != NULL); /* unhide here */ entry = dock->menu->entries[++index]; @@ -3685,7 +3696,7 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) /* settings */ entry = dock->menu->entries[++index]; entry->clientdata = aicon; - wMenuSetEnabled(dock->menu, index, !aicon->editing && !wPreferences.flags.noupdates); + wMenuSetEnabled(dock->menu, index, !wAppIconIsEditing(aicon) && !wPreferences.flags.noupdates); /* kill or remove drawer */ entry = dock->menu->entries[++index]; @@ -3730,12 +3741,12 @@ static void openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) static void iconDblClick(WObjDescriptor *desc, XEvent *event) { WAppIcon *btn = desc->parent; - WDock *dock = btn->dock; + WDock *dock = wAppIconGetDock(btn); WApplication *wapp = NULL; int unhideHere = 0; - if (btn->icon->owner && !(event->xbutton.state & ControlMask)) { - wapp = wApplicationOf(btn->icon->owner->main_window); + if (wAppIconGetIcon(btn)->owner && !(event->xbutton.state & ControlMask)) { + wapp = wApplicationOf(wAppIconGetIcon(btn)->owner->main_window); assert(wapp != NULL); @@ -3748,7 +3759,7 @@ static void iconDblClick(WObjDescriptor *desc, XEvent *event) wUnhideApplication(wapp, event->xbutton.button == Button2, unhideHere); if (event->xbutton.state & MOD_MASK) - wHideOtherApplications(btn->icon->owner); + wHideOtherApplications(wAppIconGetIcon(btn)->owner); } else { if (event->xbutton.button == Button1) { if (event->xbutton.state & MOD_MASK) { @@ -3759,9 +3770,9 @@ static void iconDblClick(WObjDescriptor *desc, XEvent *event) handleClipChangeWorkspace(dock->screen_ptr, event); else if (wPreferences.flags.clip_merged_in_dock) { // Is actually the dock - if (btn->command) + if (wAppIconGetCommand(btn)) { - if (!btn->launching && (!btn->running || (event->xbutton.state & ControlMask))) + if (!wAppIconIsLaunching(btn) && (!wAppIconIsRunning(btn) || (event->xbutton.state & ControlMask))) launchDockedApplication(btn, False); } else @@ -3773,10 +3784,10 @@ static void iconDblClick(WObjDescriptor *desc, XEvent *event) toggleCollapsed(dock); } else if (wIsADrawer(btn)) { toggleCollapsed(dock); - } else if (btn->command) { - if (!btn->launching && (!btn->running || (event->xbutton.state & ControlMask))) + } else if (wAppIconGetCommand(btn)) { + if (!wAppIconIsLaunching(btn) && (!wAppIconIsRunning(btn) || (event->xbutton.state & ControlMask))) launchDockedApplication(btn, False); - } else if (btn->xindex == 0 && btn->yindex == 0 && btn->dock->type == WM_DOCK) { + } else if (wAppIconGetXIndex(btn) == 0 && wAppIconGetYIndex(btn) == 0 && wAppIconGetDock(btn)->type == WM_DOCK) { wShowInfoPanel(dock->screen_ptr); } } @@ -3787,17 +3798,17 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) { WScreen *scr = dock->screen_ptr; int ofs_x = event->xbutton.x, ofs_y = event->xbutton.y; - WIcon *icon = aicon->icon; + WIcon *icon = wAppIconGetIcon(aicon); WAppIcon *tmpaicon; WDrawerChain *dc; - int x = aicon->x_pos, y = aicon->y_pos;; + int x = wAppIconGetXPos(aicon), y = wAppIconGetYPos(aicon); int shad_x = x, shad_y = y; XEvent ev; int grabbed = 0, done, previously_on_right, now_on_right, previous_x_pos, i; Pixmap ghost = None; int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */ - if (XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask + if (XGrabPointer(dpy, wAppIconGetIcon(aicon)->core->window, True, ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) wwarning("pointer grab failed for dock move"); @@ -3807,7 +3818,7 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) wins[0] = icon->core->window; wins[1] = scr->dock_shadow; XRestackWindows(dpy, wins, 2); - XMoveResizeWindow(dpy, scr->dock_shadow, aicon->x_pos, aicon->y_pos, + XMoveResizeWindow(dpy, scr->dock_shadow, wAppIconGetXPos(aicon), wAppIconGetYPos(aicon), ICON_SIZE, ICON_SIZE); if (superfluous) { if (icon->pixmap!=None) @@ -3885,17 +3896,17 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) tmpaicon = dock->icon_array[i]; if (tmpaicon == NULL) continue; - if (onScreen(scr, tmpaicon->x_pos, tmpaicon->y_pos)) + if (onScreen(scr, wAppIconGetXPos(tmpaicon), wAppIconGetYPos(tmpaicon))) continue; - new_y = (tmpaicon->y_pos + ICON_SIZE * dock->max_icons) % (ICON_SIZE * dock->max_icons); + new_y = (wAppIconGetYPos(tmpaicon) + ICON_SIZE * dock->max_icons) % (ICON_SIZE * dock->max_icons); new_index = (new_y - dock->y_pos) / ICON_SIZE; - if (!onScreen(scr, tmpaicon->x_pos, new_y)) + if (!onScreen(scr, wAppIconGetXPos(tmpaicon), new_y)) continue; ok = 1; for (j = 0; j < dock->max_icons; j++) { if (dock->icon_array[j] != NULL && - dock->icon_array[j]->yindex == new_index) + wAppIconGetYIndex(dock->icon_array[j]) == new_index) { ok = 0; break; @@ -3903,23 +3914,23 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) } if (!ok || getDrawer(scr, new_index) != NULL) continue; - wDockReattachIcon(dock, tmpaicon, tmpaicon->xindex, new_index); + wDockReattachIcon(dock, tmpaicon, wAppIconGetXIndex(tmpaicon), new_index); } for (dc = scr->drawers; dc != NULL; dc = dc->next) { int new_y, new_index, j, ok; tmpaicon = dc->adrawer->icon_array[0]; - if (onScreen(scr, tmpaicon->x_pos, tmpaicon->y_pos)) + if (onScreen(scr, wAppIconGetXPos(tmpaicon), wAppIconGetYPos(tmpaicon))) continue; - new_y = (tmpaicon->y_pos + ICON_SIZE * dock->max_icons) % (ICON_SIZE * dock->max_icons); + new_y = (wAppIconGetYPos(tmpaicon) + ICON_SIZE * dock->max_icons) % (ICON_SIZE * dock->max_icons); new_index = (new_y - dock->y_pos) / ICON_SIZE; - if (!onScreen(scr, tmpaicon->x_pos, new_y)) + if (!onScreen(scr, wAppIconGetXPos(tmpaicon), new_y)) continue; ok = 1; for (j = 0; j < dock->max_icons; j++) { if (dock->icon_array[j] != NULL && - dock->icon_array[j]->yindex == new_index) + wAppIconGetYIndex(dock->icon_array[j]) == new_index) { ok = 0; break; @@ -3927,7 +3938,7 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) } if (!ok || getDrawer(scr, new_index) != NULL) continue; - moveDock(dc->adrawer, tmpaicon->x_pos, new_y); + moveDock(dc->adrawer, wAppIconGetXPos(tmpaicon), new_y); } } break; @@ -3976,7 +3987,7 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) tmpaicon = dock->icon_array[i]; if (tmpaicon == NULL) continue; - wins[tmpaicon->xindex + offset_index] = tmpaicon->icon->core->window; + wins[wAppIconGetXIndex(tmpaicon) + offset_index] = wAppIconGetIcon(tmpaicon)->core->window; } slide_windows(wins, dock->icon_count, (dock->on_right_side ? x - (dock->icon_count - 1) * ICON_SIZE : x), @@ -4019,7 +4030,7 @@ 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 = wAppIconGetDock(scr->clip_icon); direction = getClipButton(event->xbutton.x, event->xbutton.y); @@ -4079,10 +4090,10 @@ static void handleClipChangeWorkspace(WScreen *scr, XEvent *event) static void iconMouseDown(WObjDescriptor *desc, XEvent *event) { WAppIcon *aicon = desc->parent; - WDock *dock = aicon->dock; - WScreen *scr = aicon->icon->core->screen_ptr; + WDock *dock = wAppIconGetDock(aicon); + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; - if (aicon->editing || WCHECK_STATE(WSTATE_MODAL)) + if (wAppIconIsEditing(aicon) || WCHECK_STATE(WSTATE_MODAL)) return; scr->last_dock = dock; @@ -4092,7 +4103,7 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent *event) if (IsDoubleClick(scr, event)) { /* double-click was not in the main clip icon */ - if (dock->type != WM_CLIP || aicon->xindex != 0 || aicon->yindex != 0 + if (dock->type != WM_CLIP || wAppIconGetXIndex(aicon) != 0 || wAppIconGetYIndex(aicon) != 0 || getClipButton(event->xbutton.x, event->xbutton.y) == CLIP_IDLE) { iconDblClick(desc, event); return; @@ -4106,11 +4117,11 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent *event) wDockRaise(dock); if ((event->xbutton.state & ShiftMask) && aicon != scr->clip_icon && dock->type != WM_DOCK) { - wIconSelect(aicon->icon); + wIconSelect(wAppIconGetIcon(aicon)); return; } - if (aicon->yindex == 0 && aicon->xindex == 0) { + if (wAppIconGetYIndex(aicon) == 0 && wAppIconGetXIndex(aicon) == 0) { 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); @@ -4145,10 +4156,10 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent *event) } } else if (event->xbutton.button == Button2 && dock->type == WM_CLIP && (event->xbutton.state & ShiftMask) && aicon != scr->clip_icon) { - wClipMakeIconOmnipresent(aicon, !aicon->omnipresent); + wClipMakeIconOmnipresent(aicon, !wAppIconIsOmnipresent(aicon)); } else if (event->xbutton.button == Button3) { if (event->xbutton.send_event && - XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask + XGrabPointer(dpy, wAppIconGetIcon(aicon)->core->window, True, ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) { wwarning("pointer grab failed for dockicon menu"); @@ -4159,7 +4170,7 @@ static void iconMouseDown(WObjDescriptor *desc, XEvent *event) } else if (event->xbutton.button == Button2) { WAppIcon *btn = desc->parent; - if (!btn->launching && (!btn->running || (event->xbutton.state & ControlMask))) + if (!wAppIconIsLaunching(btn) && (!wAppIconIsRunning(btn) || (event->xbutton.state & ControlMask))) launchDockedApplication(btn, True); } else if (event->xbutton.button == Button4 && dock->type == WM_CLIP) { wWorkspaceRelativeChange(scr, 1); @@ -4182,8 +4193,8 @@ static void clipEnterNotify(WObjDescriptor *desc, XEvent *event) if (desc->parent_type != WCLASS_DOCK_ICON) return; - scr = btn->icon->core->screen_ptr; - dock = btn->dock; + scr = wAppIconGetIcon(btn)->core->screen_ptr; + dock = wAppIconGetDock(btn); if (dock == NULL) return; @@ -4222,7 +4233,7 @@ static void clipLeave(WDock *dock) if (XFindContext(dpy, event.xcrossing.window, w_global.context.client_win, (XPointer *) & desc) != XCNOENT && desc && desc->parent_type == WCLASS_DOCK_ICON - && ((WAppIcon *) desc->parent)->dock == dock) { + && wAppIconGetDock((WAppIcon *) desc->parent) == dock) { /* We haven't left the dock/clip/drawer yet */ XPutBackEvent(dpy, &event); return; @@ -4265,7 +4276,7 @@ static void clipLeaveNotify(WObjDescriptor *desc, XEvent *event) if (desc->parent_type != WCLASS_DOCK_ICON) return; - clipLeave(btn->dock); + clipLeave(wAppIconGetDock(btn)); } static void clipAutoCollapse(void *cdata) @@ -4318,7 +4329,7 @@ static void clipAutoRaise(void *cdata) static Bool iconCanBeOmnipresent(WAppIcon *aicon) { - WScreen *scr = aicon->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; WDock *clip; WAppIcon *btn; int i, j; @@ -4326,7 +4337,7 @@ static Bool iconCanBeOmnipresent(WAppIcon *aicon) for (i = 0; i < scr->workspace_count; i++) { clip = scr->workspaces[i]->clip; - if (clip == aicon->dock) + if (clip == wAppIconGetDock(aicon)) continue; if (clip->icon_count + scr->global_icon_count >= clip->max_icons) @@ -4334,7 +4345,7 @@ static Bool iconCanBeOmnipresent(WAppIcon *aicon) for (j = 0; j < clip->max_icons; j++) { btn = clip->icon_array[j]; - if (btn && btn->xindex == aicon->xindex && btn->yindex == aicon->yindex) + if (btn && wAppIconGetXIndex(btn) == wAppIconGetXIndex(aicon) && wAppIconGetYIndex(btn) == wAppIconGetYIndex(aicon)) return False; } } @@ -4344,30 +4355,30 @@ static Bool iconCanBeOmnipresent(WAppIcon *aicon) int wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent) { - WScreen *scr = aicon->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; WAppIconChain *new_entry, *tmp, *tmp1; int status = WO_SUCCESS; - if ((scr->dock && aicon->dock == scr->dock) || aicon == scr->clip_icon) + if ((scr->dock && wAppIconGetDock(aicon) == scr->dock) || aicon == scr->clip_icon) return WO_NOT_APPLICABLE; - if (aicon->omnipresent == omnipresent) + if (wAppIconIsOmnipresent(aicon) == omnipresent) return WO_SUCCESS; if (omnipresent) { if (iconCanBeOmnipresent(aicon)) { - aicon->omnipresent = 1; + wAppIconSetOmnipresent(aicon, 1); new_entry = wmalloc(sizeof(WAppIconChain)); new_entry->aicon = aicon; new_entry->next = scr->global_icons; scr->global_icons = new_entry; scr->global_icon_count++; } else { - aicon->omnipresent = 0; + wAppIconSetOmnipresent(aicon, 0); status = WO_FAILED; } } else { - aicon->omnipresent = 0; + wAppIconSetOmnipresent(aicon, 0); if (aicon == scr->global_icons->aicon) { tmp = scr->global_icons->next; wfree(scr->global_icons); @@ -4446,7 +4457,7 @@ static char * findUniqueName(WScreen *scr, const char *instance_basename) already_in_use = False; for (dc = scr->drawers; dc != NULL; dc = dc->next) { - if (!strncmp(dc->adrawer->icon_array[0]->wm_instance, buffer, + if (!strncmp(wAppIconGetWmInstance(dc->adrawer->icon_array[0]), buffer, sizeof buffer)) { already_in_use = True; break; @@ -4486,7 +4497,7 @@ static int addADrawer(WScreen *scr) } for (i = 0; i < dock->max_icons; i++) { if (dock->icon_array[i] != NULL) - can_be_here[dock->icon_array[i]->yindex + dock->max_icons - 1] = False; + can_be_here[wAppIconGetYIndex(dock->icon_array[i]) + dock->max_icons - 1] = False; } for (dc = scr->drawers; dc != NULL; dc = dc->next) { y = (int) ((dc->adrawer->y_pos - dock->y_pos) / ICON_SIZE); @@ -4516,18 +4527,18 @@ static int addADrawer(WScreen *scr) drawer = wDockCreate(scr, WM_DRAWER, NULL); drawer->lowered = scr->dock->lowered; if (!drawer->lowered) - ChangeStackingLevel(drawer->icon_array[0]->icon->core, WMDockLevel); + ChangeStackingLevel(wAppIconGetIcon(drawer->icon_array[0])->core, WMDockLevel); else - ChangeStackingLevel(drawer->icon_array[0]->icon->core, WMNormalLevel); + ChangeStackingLevel(wAppIconGetIcon(drawer->icon_array[0])->core, WMNormalLevel); drawer->auto_raise_lower = scr->dock->auto_raise_lower; drawer->x_pos = dock->x_pos; drawer->y_pos = dock->y_pos + ICON_SIZE * y; - drawer->icon_array[0]->xindex = 0; - drawer->icon_array[0]->yindex = 0; - drawer->icon_array[0]->x_pos = drawer->x_pos; - drawer->icon_array[0]->y_pos = drawer->y_pos; - XMoveWindow(dpy, drawer->icon_array[0]->icon->core->window, - drawer->icon_array[0]->x_pos, drawer->icon_array[0]->y_pos); + wAppIconSetXIndex(drawer->icon_array[0], 0); + wAppIconSetYIndex(drawer->icon_array[0], 0); + wAppIconSetXPos(drawer->icon_array[0], drawer->x_pos); + wAppIconSetYPos(drawer->icon_array[0], drawer->y_pos); + XMoveWindow(dpy, wAppIconGetIcon(drawer->icon_array[0])->core->window, + wAppIconGetXPos(drawer->icon_array[0]), wAppIconGetYPos(drawer->icon_array[0])); return 0; } @@ -4539,7 +4550,7 @@ static void addADrawerCallback(WMenu *menu, WMenuEntry *entry) (void) menu; assert(entry->clientdata!=NULL); - addADrawer(((WAppIcon *) entry->clientdata)->dock->screen_ptr); + addADrawer(wAppIconGetDock((WAppIcon *) entry->clientdata)->screen_ptr); } @@ -4558,8 +4569,8 @@ static void drawerDestroy(WDock *drawer) /* Note regarding menus: we can't delete any dock/clip/drawer menu, because * that would (attempt to) wfree some memory in gettext library (see menu * entries that have several "versions", such like "Hide" and "Unhide"). */ - wDefaultPurgeInfo(drawer->icon_array[0]->wm_instance, - drawer->icon_array[0]->wm_class); + wDefaultPurgeInfo(wAppIconGetWmInstance(drawer->icon_array[0]), + wAppIconGetWmClass(drawer->icon_array[0])); if (drawer->icon_count == 2) { /* Drawer contains a single appicon: dock it where the drawer was */ @@ -4571,8 +4582,8 @@ static void drawerDestroy(WDock *drawer) wDockMoveIconBetweenDocks(drawer, scr->dock, aicon, 0, (drawer->y_pos - scr->dock->y_pos) / ICON_SIZE); - XMoveWindow(dpy, aicon->icon->core->window, drawer->x_pos, drawer->y_pos); - XMapWindow(dpy, aicon->icon->core->window); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, drawer->x_pos, drawer->y_pos); + XMapWindow(dpy, wAppIconGetIcon(aicon)->core->window); } else if (drawer->icon_count > 2) { icons = WMCreateArray(drawer->icon_count - 1); for (i = 1; i < drawer->max_icons; i++) { @@ -4609,7 +4620,7 @@ static void drawerDestroy(WDock *drawer) static void removeDrawerCallback(WMenu *menu, WMenuEntry *entry) { - WDock *dock = ((WAppIcon*)entry->clientdata)->dock; + WDock *dock = wAppIconGetDock((WAppIcon*)entry->clientdata); /* Parameter not used, but tell the compiler that it is ok */ (void) menu; @@ -4628,21 +4639,21 @@ static void removeDrawerCallback(WMenu *menu, WMenuEntry *entry) void wDrawerIconPaint(WAppIcon *dicon) { - Window win = dicon->icon->core->window; - WScreen *scr = dicon->icon->core->screen_ptr; + Window win = wAppIconGetIcon(dicon)->core->window; + WScreen *scr = wAppIconGetIcon(dicon)->core->screen_ptr; XPoint p[4]; GC gc = scr->draw_gc; WMColor *color; - wIconPaint(dicon->icon); + wIconPaint(wAppIconGetIcon(dicon)); - if (!dicon->dock->collapsed) + if (!wAppIconGetDock(dicon)->collapsed) color = scr->clip_title_color[CLIP_NORMAL]; else color = scr->clip_title_color[CLIP_COLLAPSED]; XSetForeground(dpy, gc, WMColorPixel(color)); - if (dicon->dock->on_right_side) { + if (wAppIconGetDock(dicon)->on_right_side) { p[0].x = p[3].x = 10; p[0].y = p[3].y = ICON_SIZE / 2 - 5; p[1].x = 10; @@ -4710,17 +4721,17 @@ static void swapDrawer(WDock *drawer, int new_x) if (ai == NULL) continue; if (drawer->on_right_side) - ai->xindex = -abs(ai->xindex); + wAppIconSetXIndex(ai, -abs(wAppIconGetXIndex(ai))); else - ai->xindex = abs(ai->xindex); - ai->x_pos = new_x + ai->xindex * ICON_SIZE; + wAppIconSetXIndex(ai, abs(wAppIconGetXIndex(ai))); + wAppIconSetXPos(ai, new_x + wAppIconGetXIndex(ai) * ICON_SIZE); /* Update drawer's tile */ if (i == 0) { - wIconUpdate(ai->icon); + wIconUpdate(wAppIconGetIcon(ai)); wDrawerIconPaint(ai); } - XMoveWindow(dpy, ai->icon->core->window, ai->x_pos, ai->y_pos); + XMoveWindow(dpy, wAppIconGetIcon(ai)->core->window, wAppIconGetXPos(ai), wAppIconGetYPos(ai)); } } @@ -4741,8 +4752,8 @@ static void swapDrawers(WScreen *scr, int new_x) int wIsADrawer(WAppIcon *aicon) { - return aicon && aicon->dock && - aicon->dock->type == WM_DRAWER && aicon->dock->icon_array[0] == aicon; + return aicon && wAppIconGetDock(aicon) && + wAppIconGetDock(aicon)->type == WM_DRAWER && wAppIconGetDock(aicon)->icon_array[0] == aicon; } @@ -4787,7 +4798,7 @@ static int indexOfHole(WDock *drawer, WAppIcon *moving_aicon, int redocking) for (i = 1; i < drawer->max_icons; i++) { if (drawer->icon_array[i] && drawer->icon_array[i] != moving_aicon) - index_of_hole -= drawer->icon_array[i]->xindex; + index_of_hole -= wAppIconGetXIndex(drawer->icon_array[i]); } /* wmessage(" Index of the moving appicon is %d (%sredocking)", index_of_hole, (redocking ? "" : "not ")); */ if (abs(index_of_hole) > abs(drawer->icon_count) - (redocking ? 1 : 0)) @@ -4812,21 +4823,21 @@ void wSlideAppicons(WAppIcon **appicons, int n, int to_the_left) for (i = 0; i < n; i++) { aicon = appicons[i]; - aicon->xindex += (to_the_left ? -1 : +1); - if (aicon->xindex < min_index) { - min_index = aicon->xindex; + wAppIconSetXIndex(aicon, wAppIconGetXIndex(aicon) + (to_the_left ? -1 : +1)); + if (wAppIconGetXIndex(aicon) < min_index) { + min_index = wAppIconGetXIndex(aicon); leftmost = i; - from_x = aicon->x_pos; + from_x = wAppIconGetXPos(aicon); } - aicon->x_pos += (to_the_left ? -ICON_SIZE : +ICON_SIZE); + wAppIconSetXPos(aicon, wAppIconGetXPos(aicon) + (to_the_left ? -ICON_SIZE : +ICON_SIZE)); } for (i = 0; i < n; i++) { aicon = appicons[i]; - wins[aicon->xindex - min_index] = aicon->icon->core->window; + wins[wAppIconGetXIndex(aicon) - min_index] = wAppIconGetIcon(aicon)->core->window; } aicon = appicons[leftmost]; - slide_windows(wins, n, from_x, aicon->y_pos, aicon->x_pos, aicon->y_pos); + slide_windows(wins, n, from_x, wAppIconGetYPos(aicon), wAppIconGetXPos(aicon), wAppIconGetYPos(aicon)); } @@ -4840,12 +4851,12 @@ void wDrawerFillTheGap(WDock *drawer, WAppIcon *aicon, Bool redocking) for (i = 0; i < drawer->max_icons; i++) { WAppIcon *ai = drawer->icon_array[i]; if (ai && ai != aicon && - abs(ai->xindex) > abs(index_of_hole)) + abs(wAppIconGetXIndex(ai)) > abs(index_of_hole)) aicons_to_shift[j++] = ai; } if (j != drawer->icon_count - abs(index_of_hole) - (redocking ? 1 : 0)) wwarning("Removing aicon at index %d from %s: j=%d but should be %d", - index_of_hole, drawer->icon_array[0]->wm_instance, + index_of_hole, wAppIconGetWmInstance(drawer->icon_array[0]), j, drawer->icon_count - abs(index_of_hole) - (redocking ? 1 : 0)); wSlideAppicons(aicons_to_shift, j, !drawer->on_right_side); } @@ -4861,9 +4872,9 @@ static void drawerConsolidateIcons(WDock *drawer) WAppIcon *ai = drawer->icon_array[i]; if (ai == NULL) continue; - sum += abs(ai->xindex); - if (abs(ai->xindex) > maxRemaining) - maxRemaining = abs(ai->xindex); + sum += abs(wAppIconGetXIndex(ai)); + if (abs(wAppIconGetXIndex(ai)) > maxRemaining) + maxRemaining = abs(wAppIconGetXIndex(ai)); } while (sum != maxRemaining * (maxRemaining + 1) / 2) { // while there is a hole WAppIcon *ai; @@ -4876,7 +4887,7 @@ static void drawerConsolidateIcons(WDock *drawer) WAppIcon *ai = drawer->icon_array[i]; if (ai == NULL) continue; - if (abs(ai->xindex) == maxDeleted) { + if (abs(wAppIconGetXIndex(ai)) == maxDeleted) { foundAppIconThere = True; break; } @@ -4888,7 +4899,7 @@ static void drawerConsolidateIcons(WDock *drawer) n = 0; for (i = 0; i < drawer->max_icons; i++) { ai = drawer->icon_array[i]; - if (ai != NULL && abs(ai->xindex) > maxDeleted) + if (ai != NULL && abs(wAppIconGetXIndex(ai)) > maxDeleted) aicons_to_shift[n++] = ai; } assert(n == maxRemaining - maxDeleted); // for the code review ;-) @@ -4924,12 +4935,12 @@ static WDock * drawerRestoreState(WScreen *scr, WMPropList *drawer_state) #ifdef USE_DOCK_XDND value = WMGetFromPLDictionary(drawer_state, dDropCommand); if (value && WMIsPLString(value)) - drawer->icon_array[0]->dnd_command = wstrdup(WMGetFromPLString(value)); + wAppIconSetDnDCommand(drawer->icon_array[0], wstrdup(WMGetFromPLString(value))); #endif /* USE_DOCK_XDND */ value = WMGetFromPLDictionary(drawer_state, dPasteCommand); if (value && WMIsPLString(value)) - drawer->icon_array[0]->paste_command = wstrdup(WMGetFromPLString(value)); + wAppIconSetPasteCommand(drawer->icon_array[0], wstrdup(WMGetFromPLString(value))); /* restore position */ value = WMGetFromPLDictionary(drawer_state, dPosition); @@ -4961,10 +4972,10 @@ static WDock * drawerRestoreState(WScreen *scr, WMPropList *drawer_state) /* restore lowered/raised state: same as scr->dock, no matter what */ drawer->lowered = scr->dock->lowered; if (!drawer->lowered) - ChangeStackingLevel(drawer->icon_array[0]->icon->core, WMDockLevel); + ChangeStackingLevel(wAppIconGetIcon(drawer->icon_array[0])->core, WMDockLevel); else - ChangeStackingLevel(drawer->icon_array[0]->icon->core, WMNormalLevel); - wRaiseFrame(drawer->icon_array[0]->icon->core); + ChangeStackingLevel(wAppIconGetIcon(drawer->icon_array[0])->core, WMNormalLevel); + wRaiseFrame(wAppIconGetIcon(drawer->icon_array[0])->core); /* restore collapsed state */ drawer->collapsed = 0; @@ -5020,23 +5031,23 @@ static WDock * drawerRestoreState(WScreen *scr, WMPropList *drawer_state) * dynamically positioned depending on the screen size */ if (drawer->screen_ptr->dock->on_right_side) - aicon->xindex = -abs(aicon->xindex); + wAppIconSetXIndex(aicon, -abs(wAppIconGetXIndex(aicon))); else - aicon->xindex = abs(aicon->xindex); - aicon->dock = drawer; - aicon->x_pos = drawer->x_pos + (aicon->xindex * ICON_SIZE); - aicon->y_pos = drawer->y_pos + (aicon->yindex * ICON_SIZE); + wAppIconSetXIndex(aicon, abs(wAppIconGetXIndex(aicon))); + wAppIconSetDock(aicon, drawer); + wAppIconSetXPos(aicon, drawer->x_pos + (wAppIconGetXIndex(aicon) * ICON_SIZE)); + wAppIconSetYPos(aicon, drawer->y_pos + (wAppIconGetYIndex(aicon) * ICON_SIZE)); if (!drawer->lowered) - ChangeStackingLevel(aicon->icon->core, WMDockLevel); + ChangeStackingLevel(wAppIconGetIcon(aicon)->core, WMDockLevel); else - ChangeStackingLevel(aicon->icon->core, WMNormalLevel); + ChangeStackingLevel(wAppIconGetIcon(aicon)->core, WMNormalLevel); - wCoreConfigure(aicon->icon->core, aicon->x_pos, aicon->y_pos, 0, 0); + wCoreConfigure(wAppIconGetIcon(aicon)->core, wAppIconGetXPos(aicon), wAppIconGetYPos(aicon), 0, 0); if (!drawer->collapsed) - XMapWindow(dpy, aicon->icon->core->window); - wRaiseFrame(aicon->icon->core); + XMapWindow(dpy, wAppIconGetIcon(aicon)->core->window); + wRaiseFrame(wAppIconGetIcon(aicon)->core); drawer->icon_count++; } @@ -5060,28 +5071,28 @@ static WMPropList *drawerSaveState(WDock *drawer) ai = drawer->icon_array[0]; /* Store its name */ - pstr = WMCreatePLString(ai->wm_instance); + pstr = WMCreatePLString(wAppIconGetWmInstance(ai)); drawer_state = WMCreatePLDictionary(dName, pstr, NULL); /* we need this final NULL */ WMReleasePropList(pstr); /* Store its position */ - snprintf(buffer, sizeof(buffer), "%i,%i", ai->x_pos, ai->y_pos); + snprintf(buffer, sizeof(buffer), "%i,%i", wAppIconGetXPos(ai), wAppIconGetYPos(ai)); pstr = WMCreatePLString(buffer); WMPutInPLDictionary(drawer_state, dPosition, pstr); WMReleasePropList(pstr); #ifdef USE_DOCK_XDND /* Store its DnD command */ - if (ai->dnd_command) { - pstr = WMCreatePLString(ai->dnd_command); + if (wAppIconGetDnDCommand(ai)) { + pstr = WMCreatePLString(wAppIconGetDnDCommand(ai)); WMPutInPLDictionary(drawer_state, dDropCommand, pstr); WMReleasePropList(pstr); } #endif /* USE_DOCK_XDND */ /* Store its paste command */ - if (ai->paste_command) { - pstr = WMCreatePLString(ai->paste_command); + if (wAppIconGetPasteCommand(ai)) { + pstr = WMCreatePLString(wAppIconGetPasteCommand(ai)); WMPutInPLDictionary(drawer_state, dPasteCommand, pstr); WMReleasePropList(pstr); } diff --git a/src/dockedapp.c b/src/dockedapp.c index 9d745359..26f0a610 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -42,43 +42,13 @@ static void updateCommand(WAppIcon * icon, char *command) { - if (icon->command) - wfree(icon->command); - if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { - wfree(command); - command = NULL; - } - icon->command = command; + wAppIconSetCommand(icon, command); - if (!icon->wm_class && !icon->wm_instance && icon->command && strlen(icon->command) > 0) { - icon->forced_dock = 1; + if (!wAppIconGetWmClass(icon) && !wAppIconGetWmInstance(icon) && wAppIconGetCommand(icon) && strlen(wAppIconGetCommand(icon)) > 0) { + wAppIconSetForceDocked(icon, 1); } } -static void updatePasteCommand(WAppIcon * icon, char *command) -{ - if (icon->paste_command) - wfree(icon->paste_command); - if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { - wfree(command); - command = NULL; - } - icon->paste_command = command; -} - -#ifdef USE_DOCK_XDND -static void updateDNDCommand(WAppIcon * icon, char *command) -{ - if (icon->dnd_command) - wfree(icon->dnd_command); - if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) { - wfree(command); - command = NULL; - } - icon->dnd_command = command; -} -#endif /* USE_DOCK_XDND */ - static void updateSettingsPanelIcon(AppSettingsPanel * panel) { char *file; @@ -132,7 +102,7 @@ static void chooseIconCallback(WMWidget * self, void *clientData) WMSetButtonEnabled(panel->browseBtn, False); result = wIconChooserDialog(panel->wwin->screen_ptr, &file, - panel->editedIcon->wm_instance, panel->editedIcon->wm_class); + wAppIconGetWmInstance(panel->editedIcon), wAppIconGetWmClass(panel->editedIcon)); panel->choosingIcon = 0; if (!panel->destroyed) { @@ -164,7 +134,7 @@ static void panelBtnCallback(WMWidget * self, void *data) text = NULL; } - if (!wIconChangeImageFile(panel->editedIcon->icon, text)) { + if (!wIconChangeImageFile(wAppIconGetIcon(panel->editedIcon), text)) { char *buf; int len = strlen(text) + 64; @@ -181,14 +151,14 @@ 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 == wAppIconGetIcon(aicon)->core->screen_ptr->clip_icon) wClipIconPaint(aicon); else if (wIsADrawer(aicon)) wDrawerIconPaint(aicon); else wAppIconPaint(aicon); - wDefaultChangeIcon(aicon->wm_instance, aicon->wm_class, text); + wDefaultChangeIcon(wAppIconGetWmInstance(aicon), wAppIconGetWmClass(aicon), text); } if (text) wfree(text); @@ -203,16 +173,16 @@ static void panelBtnCallback(WMWidget * self, void *data) updateCommand(panel->editedIcon, text); #ifdef USE_DOCK_XDND /* cannot free text from this, because it will be not be duplicated - * in updateDNDCommand */ + * in wAppIconSetDnDCommand */ text = WMGetTextFieldText(panel->dndCommandField); - updateDNDCommand(panel->editedIcon, text); + wAppIconSetDnDCommand(panel->editedIcon, text); #endif text = WMGetTextFieldText(panel->pasteCommandField); - updatePasteCommand(panel->editedIcon, text); + wAppIconSetPasteCommand(panel->editedIcon, text); - panel->editedIcon->auto_launch = WMGetButtonSelected(panel->autoLaunchBtn); + wAppIconSetAutoLaunch(panel->editedIcon, WMGetButtonSelected(panel->autoLaunchBtn)); - panel->editedIcon->lock = WMGetButtonSelected(panel->lockBtn); + wAppIconSetLocked(panel->editedIcon, WMGetButtonSelected(panel->lockBtn)); } DestroyDockAppSettingsPanel(panel); @@ -221,7 +191,7 @@ static void panelBtnCallback(WMWidget * self, void *data) void ShowDockAppSettingsPanel(WAppIcon * aicon) { AppSettingsPanel *panel; - WScreen *scr = aicon->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; Window parent; WMFont *font; int x, y; @@ -252,8 +222,8 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) panel->editedIcon = aicon; - aicon->panel = panel; - aicon->editing = 1; + wAppIconSetPanel(aicon, panel); + wAppIconSetEditing(aicon, 1); panel->win = WMCreateWindow(scr->wmscreen, "applicationSettings"); WMResizeWidget(panel->win, pwidth, pheight); @@ -270,10 +240,10 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) WMSetLabelTextAlignment(panel->nameLabel, WALeft); WMSetLabelFont(panel->nameLabel, font); WMReleaseFont(font); - if (aicon->wm_class && strcmp(aicon->wm_class, "DockApp") == 0) - WMSetLabelText(panel->nameLabel, aicon->wm_instance); + if (wAppIconGetWmClass(aicon) && strcmp(wAppIconGetWmClass(aicon), "DockApp") == 0) + WMSetLabelText(panel->nameLabel, wAppIconGetWmInstance(aicon)); else - WMSetLabelText(panel->nameLabel, aicon->wm_class); + WMSetLabelText(panel->nameLabel, wAppIconGetWmClass(aicon)); vbox = WMCreateBox(panel->win); WMResizeWidget(vbox, pwidth - 2 * WMScaleX(10), pheight - iconSize - 3 * WMScaleY(10)); @@ -282,12 +252,12 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) panel->autoLaunchBtn = WMCreateSwitchButton(vbox); WMAddBoxSubview(vbox, WMWidgetView(panel->autoLaunchBtn), False, True, WMScaleY(20), WMScaleY(20), WMScaleY(2)); WMSetButtonText(panel->autoLaunchBtn, _("Start when Window Maker is started")); - WMSetButtonSelected(panel->autoLaunchBtn, aicon->auto_launch); + WMSetButtonSelected(panel->autoLaunchBtn, wAppIconIsAutoLaunch(aicon)); panel->lockBtn = WMCreateSwitchButton(vbox); WMAddBoxSubview(vbox, WMWidgetView(panel->lockBtn), False, True, WMScaleY(20), WMScaleY(20), WMScaleY(5)); WMSetButtonText(panel->lockBtn, _("Lock (prevent accidental removal)")); - WMSetButtonSelected(panel->lockBtn, aicon->lock); + WMSetButtonSelected(panel->lockBtn, wAppIconIsLocked(aicon)); panel->commandFrame = WMCreateFrame(vbox); WMSetFrameTitle(panel->commandFrame, _("Application path and arguments")); @@ -296,7 +266,7 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) panel->commandField = WMCreateTextField(panel->commandFrame); WMResizeWidget(panel->commandField, WMScaleX(260), WMScaleY(20)); WMMoveWidget(panel->commandField, WMScaleX(10), WMScaleY(20)); - WMSetTextFieldText(panel->commandField, aicon->command); + WMSetTextFieldText(panel->commandField, wAppIconGetCommand(aicon)); WMMapSubwidgets(panel->commandFrame); @@ -312,7 +282,7 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) WMResizeWidget(panel->pasteCommandLabel, WMScaleX(260), WMScaleY(18)); WMMoveWidget(panel->pasteCommandLabel, WMScaleX(10), WMScaleY(45)); - WMSetTextFieldText(panel->pasteCommandField, aicon->paste_command); + WMSetTextFieldText(panel->pasteCommandField, wAppIconGetPasteCommand(aicon)); WMSetLabelText(panel->pasteCommandLabel, _("%s will be replaced with current selection")); WMMapSubwidgets(panel->pasteCommandFrame); @@ -328,7 +298,7 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) WMResizeWidget(panel->dndCommandLabel, WMScaleX(260), WMScaleY(18)); WMMoveWidget(panel->dndCommandLabel, WMScaleX(10), WMScaleY(45)); #ifdef USE_DOCK_XDND - WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command); + WMSetTextFieldText(panel->dndCommandField, wAppIconGetDnDCommand(aicon)); WMSetLabelText(panel->dndCommandLabel, _("%d will be replaced with the file name")); #else WMSetTextFieldEditable(panel->dndCommandField, False); @@ -346,7 +316,7 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) panel->iconField = WMCreateTextField(panel->iconFrame); WMResizeWidget(panel->iconField, WMScaleX(180), WMScaleY(20)); WMMoveWidget(panel->iconField, WMScaleX(10), WMScaleY(20)); - WMSetTextFieldText(panel->iconField, wDefaultGetIconFile(aicon->wm_instance, aicon->wm_class, False)); + WMSetTextFieldText(panel->iconField, wDefaultGetIconFile(wAppIconGetWmInstance(aicon), wAppIconGetWmClass(aicon), False)); panel->browseBtn = WMCreateCommandButton(panel->iconFrame); WMResizeWidget(panel->browseBtn, WMScaleX(70), WMScaleY(24)); @@ -392,14 +362,14 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) { WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); - y = aicon->y_pos; + y = wAppIconGetYPos(aicon); if (y < 0) y = 0; else if (y + pheight > rect.pos.y + rect.size.height) y = rect.pos.y + rect.size.height - pheight - 3 * WMScaleY(10); - if (aicon->dock && wDockGetType(aicon->dock) == WM_DOCK) { - if (wDockIsOnRightSide(aicon->dock)) + if (wAppIconGetDock(aicon) && wDockGetType(wAppIconGetDock(aicon)) == WM_DOCK) { + if (wDockIsOnRightSide(wAppIconGetDock(aicon))) x = rect.pos.x + rect.size.width / 2; else x = rect.pos.x + rect.size.width / 2 - pwidth - WMScaleX(2); @@ -443,9 +413,9 @@ void DestroyDockAppSettingsPanel(AppSettingsPanel * panel) XDestroyWindow(dpy, panel->parent); - panel->editedIcon->panel = NULL; + wAppIconSetPanel(panel->editedIcon, NULL); - panel->editedIcon->editing = 0; + wAppIconSetEditing(panel->editedIcon, 0); wfree(panel); } diff --git a/src/event.c b/src/event.c index f7b5570c..7356a1a2 100644 --- a/src/event.c +++ b/src/event.c @@ -1115,7 +1115,7 @@ static void handleClientMessage(XEvent * event) if (desc->parent_type == WCLASS_MINIWINDOW) { icon = (WIcon *) desc->parent; } else if (desc->parent_type == WCLASS_DOCK_ICON || desc->parent_type == WCLASS_APPICON) { - icon = ((WAppIcon *) desc->parent)->icon; + icon = wAppIconGetIcon((WAppIcon *) desc->parent); } if (icon && (wwin = icon->owner)) { if (wwin->client_win != event->xclient.window) { diff --git a/src/placement.c b/src/placement.c index 5e6a8d2d..98616652 100644 --- a/src/placement.c +++ b/src/placement.c @@ -57,9 +57,9 @@ iconPosition(WCoreWindow *wcore, int sx1, int sy1, int sx2, int sy2, parent = wcore->descriptor.parent; /* if it is an application icon */ - if (wcore->descriptor.parent_type == WCLASS_APPICON && !((WAppIcon *) parent)->docked) { - *retX = ((WAppIcon *) parent)->x_pos; - *retY = ((WAppIcon *) parent)->y_pos; + if (wcore->descriptor.parent_type == WCLASS_APPICON && !wAppIconIsDocked((WAppIcon *) parent)) { + *retX = wAppIconGetXPos((WAppIcon *) parent); + *retY = wAppIconGetYPos((WAppIcon *) parent); ok = 1; } else if (wcore->descriptor.parent_type == WCLASS_MINIWINDOW && diff --git a/src/session.c b/src/session.c index 069fa83f..c01eba2f 100644 --- a/src/session.c +++ b/src/session.c @@ -202,9 +202,9 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp) command = GetCommandForWindow(win); if (!command) { - if (wApplicationGetAppIcon(wapp) && wApplicationGetAppIcon(wapp)->command) { - command = wmalloc(strlen(wApplicationGetAppIcon(wapp)->command) + 1); - strcpy(command, wApplicationGetAppIcon(wapp)->command); + if (wApplicationGetAppIcon(wapp) && wAppIconGetCommand(wApplicationGetAppIcon(wapp))) { + command = wmalloc(strlen(wAppIconGetCommand(wApplicationGetAppIcon(wapp))) + 1); + strcpy(command, wAppIconGetCommand(wApplicationGetAppIcon(wapp))); } else return NULL; } @@ -256,16 +256,16 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp) WMReleasePropList(maximized); WMReleasePropList(geometry); WMReleasePropList(shortcut); - if (wapp && wApplicationGetAppIcon(wapp) && wApplicationGetAppIcon(wapp)->dock) { + if (wapp && wApplicationGetAppIcon(wapp) && wAppIconGetDock(wApplicationGetAppIcon(wapp))) { int i; char *name = NULL; - if (wApplicationGetAppIcon(wapp)->dock == scr->dock) + if (wAppIconGetDock(wApplicationGetAppIcon(wapp)) == scr->dock) name = "Dock"; /* Try the clips */ if (name == NULL) { for (i = 0; i < scr->workspace_count; i++) - if (scr->workspaces[i]->clip == wApplicationGetAppIcon(wapp)->dock) + if (scr->workspaces[i]->clip == wAppIconGetDock(wApplicationGetAppIcon(wapp))) break; if (i < scr->workspace_count) name = scr->workspaces[i]->name; @@ -274,11 +274,11 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp) if (name == NULL) { WDrawerChain *dc; for (dc = scr->drawers; dc != NULL; dc = dc->next) { - if (dc->adrawer == wApplicationGetAppIcon(wapp)->dock) + if (dc->adrawer == wAppIconGetDock(wApplicationGetAppIcon(wapp))) break; } assert(dc != NULL); - name = wDockGetIcon(dc->adrawer, 0)->wm_instance; + name = wAppIconGetWmInstance(wDockGetIcon(dc->adrawer, 0)); } dock = WMCreatePLString(name); WMPutInPLDictionary(win_state, sDock, dock); @@ -536,7 +536,7 @@ void wSessionRestoreState(WScreen *scr) WDrawerChain *dc; for (dc = scr->drawers; dc != NULL; dc = dc->next) { - if (strcmp(wDockGetIcon(dc->adrawer, 0)->wm_instance, tmp) == 0) + if (strcmp(wAppIconGetWmInstance(wDockGetIcon(dc->adrawer, 0)), tmp) == 0) { dock = dc->adrawer; break; @@ -556,10 +556,10 @@ void wSessionRestoreState(WScreen *scr) if (dock != NULL) { for (j = 0; j < wDockGetMaxIcons(dock); j++) { btn = wDockGetIcon(dock, j); - if (btn && is_same(instance, btn->wm_instance) && - is_same(class, btn->wm_class) && - is_same(command, btn->command) && - !btn->launching) { + if (btn && is_same(instance, wAppIconGetWmInstance(btn)) && + is_same(class, wAppIconGetWmClass(btn)) && + is_same(command, wAppIconGetCommand(btn)) && + !wAppIconIsLaunching(btn)) { found = 1; break; } diff --git a/src/superfluous.c b/src/superfluous.c index a8b9a0be..c0e40be9 100644 --- a/src/superfluous.c +++ b/src/superfluous.c @@ -201,7 +201,7 @@ static void doAppBounce(void *arg) reinit: if (wApplicationHasLiveRefcount(data->wapp)) { if (wPreferences.raise_appicons_when_bouncing) - XRaiseWindow(dpy, aicon->icon->core->window); + XRaiseWindow(dpy, wAppIconGetIcon(aicon)->core->window); const double ticks = BOUNCE_HZ * BOUNCE_LENGTH; const double s = sqrt(BOUNCE_HEIGHT)/(ticks/2); @@ -218,29 +218,29 @@ reinit: switch (data->dir) { case 0: /* left, bounce to right */ - XMoveWindow(dpy, aicon->icon->core->window, - aicon->x_pos + (int)offset, aicon->y_pos); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, + wAppIconGetXPos(aicon) + (int)offset, wAppIconGetYPos(aicon)); break; case 1: /* right, bounce to left */ - XMoveWindow(dpy, aicon->icon->core->window, - aicon->x_pos - (int)offset, aicon->y_pos); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, + wAppIconGetXPos(aicon) - (int)offset, wAppIconGetYPos(aicon)); break; case 2: /* top, bounce down */ - XMoveWindow(dpy, aicon->icon->core->window, - aicon->x_pos, aicon->y_pos + (int)offset); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, + wAppIconGetXPos(aicon), wAppIconGetYPos(aicon) + (int)offset); break; case 3: /* bottom, bounce up */ - XMoveWindow(dpy, aicon->icon->core->window, - aicon->x_pos, aicon->y_pos - (int)offset); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, + wAppIconGetXPos(aicon), wAppIconGetYPos(aicon) - (int)offset); break; } return; } } - XMoveWindow(dpy, aicon->icon->core->window, - aicon->x_pos, aicon->y_pos); - CommitStackingForWindow(aicon->icon->core); + XMoveWindow(dpy, wAppIconGetIcon(aicon)->core->window, + wAppIconGetXPos(aicon), wAppIconGetYPos(aicon)); + CommitStackingForWindow(wAppIconGetIcon(aicon)->core); wApplicationSetBouncing(data->wapp, 0); WMDeleteTimerHandler(data->timer); wApplicationDestroy(data->wapp); @@ -251,13 +251,13 @@ static int bounceDirection(WAppIcon *aicon) { enum { left_e = 1, right_e = 2, top_e = 4, bottom_e = 8 }; - WScreen *scr = aicon->icon->core->screen_ptr; + WScreen *scr = wAppIconGetIcon(aicon)->core->screen_ptr; WMRect rr, sr; int l, r, t, b, h, v; int dir = 0; - rr.pos.x = aicon->x_pos; - rr.pos.y = aicon->y_pos; + rr.pos.x = wAppIconGetXPos(aicon); + rr.pos.y = wAppIconGetYPos(aicon); rr.size.width = rr.size.height = 64; sr = wGetRectForHead(scr, wGetHeadForRect(scr, rr)); @@ -283,8 +283,8 @@ static int bounceDirection(WAppIcon *aicon) v = b; } - if (aicon->dock && abs(aicon->xindex) != abs(aicon->yindex)) { - if (abs(aicon->xindex) < abs(aicon->yindex)) dir &= ~(top_e | bottom_e); + if (wAppIconGetDock(aicon) && abs(wAppIconGetXIndex(aicon)) != abs(wAppIconGetYIndex(aicon))) { + if (abs(wAppIconGetXIndex(aicon)) < abs(wAppIconGetYIndex(aicon))) dir &= ~(top_e | bottom_e); else dir &= ~(left_e | right_e); } else { if (h < v) dir &= ~(top_e | bottom_e); diff --git a/src/winspector.c b/src/winspector.c index 31b9fb59..eacfdf95 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -837,12 +837,12 @@ static void applySettings(WMWidget *button, void *client_data) if (!WFLAGP(wwin, always_user_icon)) { /* Change App Icon image, using the icon provided by the client */ if (wApplicationGetAppIcon(wapp)) { - RImage *image = get_rimage_icon_from_wm_hints(wApplicationGetAppIcon(wapp)->icon); + RImage *image = get_rimage_icon_from_wm_hints(wAppIconGetIcon(wApplicationGetAppIcon(wapp))); if (image) { - set_icon_image_from_image(wApplicationGetAppIcon(wapp)->icon, image); - update_icon_pixmap(wApplicationGetAppIcon(wapp)->icon); + set_icon_image_from_image(wAppIconGetIcon(wApplicationGetAppIcon(wapp)), image); + update_icon_pixmap(wAppIconGetIcon(wApplicationGetAppIcon(wapp))); } else { - wIconUpdate(wApplicationGetAppIcon(wapp)->icon); + wIconUpdate(wAppIconGetIcon(wApplicationGetAppIcon(wapp))); } } @@ -860,7 +860,7 @@ static void applySettings(WMWidget *button, void *client_data) } else { /* Change App Icon image */ if (wApplicationGetAppIcon(wapp)) - wIconChangeImageFile(wApplicationGetAppIcon(wapp)->icon, file); + wIconChangeImageFile(wAppIconGetIcon(wApplicationGetAppIcon(wapp)), file); /* Change icon image if the app is minimized */ if (wwin->icon) diff --git a/src/wmspec.c b/src/wmspec.c index ba5de29f..f50a4b19 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -566,7 +566,7 @@ static void updateIconImage(WWindow *wwin) /* Refresh the application icon */ WApplication *app = wApplicationOf(wwin->main_window); if (app && wApplicationGetAppIcon(app)) { - wIconUpdate(wApplicationGetAppIcon(app)->icon); + wIconUpdate(wAppIconGetIcon(wApplicationGetAppIcon(app))); wAppIconPaint(wApplicationGetAppIcon(app)); } } diff --git a/src/workspace.c b/src/workspace.c index 6bc678a5..dad14eb5 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -655,8 +655,8 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (!wPreferences.flags.noclip && (wDockIsAutoCollapse(scr->workspaces[workspace]->clip) || wDockIsAutoRaiseLower(scr->workspaces[workspace]->clip))) { /* 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, wAppIconGetIcon(scr->clip_icon)->core->window); + XMapWindow(dpy, wAppIconGetIcon(scr->clip_icon)->core->window); } else if (scr->clip_icon != NULL) { wClipIconPaint(scr->clip_icon); @@ -929,9 +929,9 @@ void wWorkspaceRestoreState(WScreen *scr) WAppIcon *aicon = wDockGetIcon(scr->workspaces[i]->clip, j); int k; - if (!aicon || !aicon->omnipresent) + if (!aicon || !wAppIconIsOmnipresent(aicon)) continue; - aicon->omnipresent = 0; + wAppIconSetOmnipresent(aicon, 0); if (wClipMakeIconOmnipresent(aicon, True) != WO_SUCCESS) continue; if (i == 0) @@ -949,7 +949,7 @@ void wWorkspaceRestoreState(WScreen *scr) if (wDockGetIcon(scr->workspaces[0]->clip, k) == NULL) break; wDockSetIcon(scr->workspaces[0]->clip, k, aicon); - aicon->dock = scr->workspaces[0]->clip; + wAppIconSetDock(aicon, scr->workspaces[0]->clip); } wDockAddIconCount(scr->workspaces[0]->clip, added_omnipresent_icons); } diff --git a/src/xdnd.c b/src/xdnd.c index c20bafa9..54c0df55 100644 --- a/src/xdnd.c +++ b/src/xdnd.c @@ -207,7 +207,7 @@ static Bool acceptXDND(Window window) if (dock) { for (i = 0; i < wDockGetMaxIcons(dock); i++) { if (wDockGetIcon(dock, i) - && wDockGetIcon(dock, i)->icon->core->window == window) { + && wAppIconGetIcon(wDockGetIcon(dock, i))->core->window == window) { icon_pos = i; break; } @@ -218,7 +218,7 @@ static Bool acceptXDND(Window window) if (dock) { for (i = 0; i < wDockGetMaxIcons(dock); i++) { if (wDockGetIcon(dock, i) - && wDockGetIcon(dock, i)->icon->core->window == window) { + && wAppIconGetIcon(wDockGetIcon(dock, i))->core->window == window) { icon_pos = i; break; } @@ -228,10 +228,10 @@ static Bool acceptXDND(Window window) if (icon_pos < 0) return False; - if (isAwareXDND(wDockGetIcon(dock, icon_pos)->icon->icon_win)) + if (isAwareXDND(wAppIconGetIcon(wDockGetIcon(dock, icon_pos))->icon_win)) return False; - if (wDockGetIcon(dock, icon_pos)->dnd_command != NULL) + if (wAppIconGetDnDCommand(wDockGetIcon(dock, icon_pos)) != NULL) return True; return False; diff --git a/src/xinerama.c b/src/xinerama.c index 1ae13e05..722e530c 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -210,14 +210,14 @@ Bool wAppIconTouchesHead(WAppIcon * aicon, int head) WMRect rect; int a; - if (!aicon || !aicon->icon) + if (!aicon || !wAppIconGetIcon(aicon)) return False; - scr = aicon->icon->core->screen_ptr; + scr = wAppIconGetIcon(aicon)->core->screen_ptr; rect = wGetRectForHead(scr, head); - a = calcIntersectionArea(aicon->x_pos, aicon->y_pos, - aicon->icon->core->width, - aicon->icon->core->height, + a = calcIntersectionArea(wAppIconGetXPos(aicon), wAppIconGetYPos(aicon), + wAppIconGetIcon(aicon)->core->width, + wAppIconGetIcon(aicon)->core->height, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height); return (a != 0);