1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-24 07:02:30 +01:00

new appicon grouping stuff

This commit is contained in:
kojima
2001-02-11 02:18:26 +00:00
parent 0fae7d3e77
commit 7a491db6c1
12 changed files with 332 additions and 471 deletions

View File

@@ -1269,19 +1269,11 @@ wHideOtherApplications(WWindow *awin)
{
WWindow *wwin;
WApplication *tapp;
#ifdef REDUCE_APPICONS
char *tinstance, *tclass;
unsigned int brokenwin = 0, match = 0;
#endif
if (!awin)
return;
wwin = awin->screen_ptr->focused_window;
#ifdef REDUCE_APPICONS
if (awin->wm_instance == NULL || awin->wm_class == NULL)
brokenwin++;
#endif
while (wwin) {
if (wwin!=awin
@@ -1291,30 +1283,13 @@ wHideOtherApplications(WWindow *awin)
&& wGetWindowOfInspectorForWindow(wwin) != awin
&& !WFLAGP(wwin, no_hide_others)) {
#ifdef REDUCE_APPICONS
match = 0;
if (!brokenwin) {
if ((tinstance = wwin->wm_instance) == NULL)
tinstance = "";
if ((tclass = wwin->wm_class) == NULL)
tclass = "";
if ((strcmp(awin->wm_instance, tinstance) == 0) &&
(strcmp(awin->wm_class, tclass) == 0) )
match++;
}
#endif
if (wwin->main_window==None || WFLAGP(wwin, no_appicon)) {
if (!WFLAGP(wwin, no_miniaturizable)) {
wwin->flags.skip_next_animation = 1;
wIconifyWindow(wwin);
}
} else if (wwin->main_window!=None
#ifndef REDUCE_APPICONS
&& awin->main_window != wwin->main_window) {
#else
&& (awin->main_window != wwin->main_window && !match)) {
#endif
tapp = wApplicationOf(wwin->main_window);
if (tapp) {
tapp->flags.skip_next_animation = 1;
@@ -1339,11 +1314,6 @@ wHideOtherApplications(WWindow *awin)
void
wHideApplication(WApplication *wapp)
{
#ifdef REDUCE_APPICONS
WApplication *tapp;
char *tinstance, *tclass;
unsigned int nowmhints = 0, matchwmhints = 0, matchworkspace = 0;
#endif
WScreen *scr;
WWindow *wlist;
int hadfocus;
@@ -1356,11 +1326,6 @@ wHideApplication(WApplication *wapp)
wwarning("group leader not found for window group");
return;
}
#ifdef REDUCE_APPICONS
if ((wapp->main_window_desc->wm_instance == NULL) ||
(wapp->main_window_desc->wm_class == NULL))
nowmhints++;
#endif
scr = wapp->main_window_desc->screen_ptr;
hadfocus = 0;
wlist = scr->focused_window;
@@ -1372,38 +1337,7 @@ wHideApplication(WApplication *wapp)
else
wapp->last_focused = NULL;
while (wlist) {
#ifdef REDUCE_APPICONS
matchwmhints = matchworkspace = 0;
if (!nowmhints) {
tapp = wApplicationOf(wlist->main_window);
tinstance = tclass = NULL;
if (tapp) {
if (tapp->main_window_desc) {
tinstance = tapp->main_window_desc->wm_instance;
tclass = tapp->main_window_desc->wm_class;
}
}
if (tapp == NULL || tinstance == NULL || tclass == NULL) {
/* Should never reach here */
tinstance = "";
tclass = "";
}
if ((strcmp(tinstance, wapp->main_window_desc->wm_instance) == 0) &&
(strcmp(tclass, wapp->main_window_desc->wm_class) == 0) )
matchwmhints++;
}
if (wlist->frame) {
if (wlist->frame->workspace == wapp->main_window_desc->screen_ptr->current_workspace)
matchworkspace++;
}
if ((wlist->main_window == wapp->main_window || matchwmhints) &&
matchworkspace) {
#ifdef I_HATE_THIS
}
#endif
#else
if (wlist->main_window == wapp->main_window) {
#endif
if (wlist->flags.focused) {
hadfocus = 1;
}
@@ -1493,21 +1427,10 @@ wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS)
WScreen *scr;
WWindow *wlist, *next;
WWindow *focused=NULL;
#ifdef REDUCE_APPICONS
char *tinstance, *tclass;
unsigned int nowmhints = 0, matchwmhints = 0, matchworkspace = 0;
#endif
if (!wapp) {
return;
}
#ifdef REDUCE_APPICONS
if ((wapp->main_window_desc->wm_class == NULL) ||
(wapp->main_window_desc->wm_instance == NULL))
nowmhints++;
#endif
scr = wapp->main_window_desc->screen_ptr;
wlist = scr->focused_window;
if (!wlist) return;
@@ -1518,27 +1441,7 @@ wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS)
while (wlist) {
next = wlist->next;
#ifndef REDUCE_APPICONS
if (wlist->main_window == wapp->main_window) {
#else
matchwmhints = matchworkspace = 0;
if (!nowmhints) {
if ((tinstance = wlist->wm_instance) == NULL)
tinstance = "";
if ((tclass = wlist->wm_class) == NULL)
tclass = "";
if ((strcmp(tinstance, wapp->main_window_desc->wm_instance) == 0)
&& (strcmp(tclass, wapp->main_window_desc->wm_class) == 0) )
matchwmhints++;
}
if (wlist->frame) {
if (wlist->frame->workspace == wapp->main_window_desc->screen_ptr->current_workspace)
matchworkspace++;
}
if ((wlist->main_window == wapp->main_window || matchwmhints) &&
matchworkspace) {
#endif
if (wlist->flags.focused)
focused = wlist;
else if (!focused || !focused->flags.focused)
@@ -1718,7 +1621,7 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
pi = 0;
si = 0;
while (aicon) {
if (!aicon->docked) {
if (!aicon->docked && wAppIconIndexOfInstance(aicon) == 0) {
if (aicon->x_pos != X || aicon->y_pos != Y) {
#ifdef ANIMATIONS
if (!wPreferences.no_animations) {

View File

@@ -112,9 +112,7 @@ wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
#ifdef XDND
wXDNDMakeAwareness(dicon->icon->core->window);
#endif
#ifdef REDUCE_APPICONS
dicon->num_apps = 0;
#endif
#ifdef DEMATERIALIZE_ICON
{
XSetWindowAttributes attribs;
@@ -140,30 +138,11 @@ WAppIcon*
wAppIconCreate(WWindow *leader_win)
{
WAppIcon *aicon;
#ifdef REDUCE_APPICONS
WAppIcon *atmp;
WAppIconAppList *applist;
char *tinstance, *tclass;
#endif
WScreen *scr = leader_win->screen_ptr;
aicon = wmalloc(sizeof(WAppIcon));
wretain(aicon);
memset(aicon, 0, sizeof(WAppIcon));
#ifdef REDUCE_APPICONS
applist = wmalloc(sizeof(WAppIconAppList));
memset(applist, 0, sizeof(WAppIconAppList));
applist->wapp = wApplicationOf(leader_win->main_window);
aicon->applist = applist;
if (applist->wapp == NULL) {
/* Something's wrong. wApplicationOf() should always return a
* valid structure. Rather than violate assumptions, bail. -cls
*/
wfree(applist);
wrelease(aicon);
return NULL;
}
#endif
aicon->yindex = -1;
aicon->xindex = -1;
@@ -171,43 +150,7 @@ wAppIconCreate(WWindow *leader_win)
aicon->prev = NULL;
aicon->next = scr->app_icon_list;
if (scr->app_icon_list) {
#ifndef REDUCE_APPICONS
scr->app_icon_list->prev = aicon;
#else
/* If we aren't going to have a match, jump straight to new appicon */
if (leader_win->wm_class == NULL || leader_win->wm_class == NULL)
atmp = NULL;
else
atmp = scr->app_icon_list;
while (atmp != NULL) {
if ((tinstance = atmp->wm_instance) == NULL)
tinstance = "";
if ((tclass = atmp->wm_class) == NULL)
tclass = "";
if ((strcmp(leader_win->wm_class, tclass) == 0) &&
(strcmp(leader_win->wm_instance, tinstance) == 0))
{
/* We have a winner */
wrelease(aicon);
atmp->num_apps++;
applist->next = atmp->applist;
if (atmp->applist)
atmp->applist->prev = applist;
atmp->applist = applist;
if (atmp->docked) {
wDockSimulateLaunch(atmp->dock, atmp);
}
return atmp;
}
atmp = atmp->next;
}
if (atmp == NULL) {
scr->app_icon_list->prev = aicon;
}
#endif /* REDUCE_APPICONS */
}
scr->app_icon_list = aicon;
@@ -215,9 +158,6 @@ wAppIconCreate(WWindow *leader_win)
aicon->wm_class = wstrdup(leader_win->wm_class);
if (leader_win->wm_instance)
aicon->wm_instance = wstrdup(leader_win->wm_instance);
#ifdef REDUCE_APPICONS
aicon->num_apps = 1;
#endif
aicon->icon = wIconCreate(leader_win);
#ifdef DEMATERIALIZE_ICON
@@ -249,9 +189,6 @@ void
wAppIconDestroy(WAppIcon *aicon)
{
WScreen *scr = aicon->icon->core->screen_ptr;
#ifdef REDUCE_APPICONS
WAppIconAppList *aptmp;
#endif
RemoveFromStackList(aicon->icon->core);
wIconDestroy(aicon->icon);
@@ -265,17 +202,6 @@ wAppIconDestroy(WAppIcon *aicon)
wfree(aicon->wm_instance);
if (aicon->wm_class)
wfree(aicon->wm_class);
#ifdef REDUCE_APPICONS
/* There should never be a list but just in case */
if (aicon->applist != NULL) {
aptmp = aicon->applist;
while (aptmp->next) {
aptmp = aptmp->next;
wfree(aptmp->prev);
}
wfree(aptmp);
}
#endif
if (aicon == scr->app_icon_list) {
if (aicon->next)
@@ -351,9 +277,21 @@ drawCorner(WIcon *icon)
void
wAppIconMove(WAppIcon *aicon, int x, int y)
{
XMoveWindow(dpy, aicon->icon->core->window, x, y);
aicon->x_pos = x;
aicon->y_pos = y;
WAppIcon *tmp;
tmp = aicon->icon->core->screen_ptr->app_icon_list;
/* move all icons of the same class/name to the same pos */
while (tmp) {
if (strcmp(tmp->wm_class, aicon->wm_class) == 0 &&
strcmp(tmp->wm_instance, aicon->wm_instance) == 0 &&
!tmp->docked) {
XMoveWindow(dpy, tmp->icon->core->window, x, y);
tmp->x_pos = x;
tmp->y_pos = y;
}
tmp = tmp->next;
}
}
@@ -394,10 +332,65 @@ updateDockNumbers(WScreen *scr)
#endif /* WS_INDICATOR */
WAppIcon*
wAppIconNextSibling(WAppIcon *icon)
{
WAppIcon *tmp;
tmp = icon->icon->core->screen_ptr->app_icon_list;
while (tmp) {
if (icon != tmp && strcmp(tmp->wm_class, icon->wm_class) == 0
&& strcmp(tmp->wm_instance, icon->wm_instance) == 0
&& !tmp->docked) {
return tmp;
}
tmp = tmp->next;
}
return NULL;
}
int
wAppIconIndexOfInstance(WAppIcon *icon)
{
WAppIcon *list = icon->icon->core->screen_ptr->app_icon_list;
int index = 0;
while (list) {
if (icon == list)
return index;
if (strcmp(icon->wm_instance,
list->wm_instance) == 0
&&
strcmp(icon->wm_class,
list->wm_class) == 0
&& !icon->docked)
index++;
list = list->next;
}
puts("OH SHIT!?!?!? HOW THE FUCK DID WE GET HERE!?!?!?!?!");
return 0;
}
void
wAppIconPaint(WAppIcon *aicon)
{
WApplication *wapp;
WScreen *scr = aicon->icon->core->screen_ptr;
int index;
if (aicon->icon->owner)
wapp = wApplicationOf(aicon->icon->owner->main_window);
else
wapp = NULL;
wIconPaint(aicon->icon);
@@ -417,9 +410,6 @@ wAppIconPaint(WAppIcon *aicon)
}
#ifdef HIDDENDOT
{
WApplication *wapp;
wapp = wApplicationOf(aicon->main_window);
if (wapp && wapp->flags.hidden) {
XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
@@ -428,9 +418,24 @@ wAppIconPaint(WAppIcon *aicon)
scr->copy_gc, 0, 0, 7,
scr->dock_dots->height, 0, 0);
}
}
#endif /* HIDDENDOT */
if (wapp)
index = wApplicationIndexOfInstance(wapp);
else
index = 0;
if (index > 0) {
char buf[16];
sprintf(buf, "%i", index);
WMDrawString(scr->wmscreen, aicon->icon->core->window,
scr->clip_title_gc, scr->title_font,
1, 1, buf, strlen(buf));
}
if (aicon->omnipresent)
drawCorner(aicon->icon);
@@ -445,58 +450,6 @@ wAppIconPaint(WAppIcon *aicon)
#define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
#ifdef REDUCE_APPICONS
unsigned int
wAppIconReduceAppCount(WApplication *wapp)
{
WAppIconAppList *applist;
if (wapp == NULL)
return 0;
if (wapp->app_icon == NULL)
return 0;
/* If given a main window, check the applist
* and remove the if it exists
*/
applist = wapp->app_icon->applist;
while (applist != NULL) {
if (applist->wapp == wapp) {
/* If this app owns the appicon, change the appicon's
* owner to the next app in the list or NULL
*/
if (wapp->app_icon->icon->owner
== applist->wapp->main_window_desc) {
if (applist->next) {
wapp->app_icon->icon->owner = applist->next->wapp->main_window_desc;
} else if (applist->prev) {
wapp->app_icon->icon->owner = applist->prev->wapp->main_window_desc;
} else {
wapp->app_icon->icon->owner = NULL;
}
}
if (applist->prev)
applist->prev->next = applist->next;
if (applist->next)
applist->next->prev = applist->prev;
if (applist == wapp->app_icon->applist)
wapp->app_icon->applist = applist->next;
wfree(applist);
if (wapp->app_icon->applist != NULL)
wapp->app_icon->main_window = wapp->app_icon->applist->wapp->main_window;
return (--wapp->app_icon->num_apps);
}
applist = applist->next;
}
return (--wapp->app_icon->num_apps);
}
#endif
static void
@@ -664,14 +617,7 @@ iconDblClick(WObjDescriptor *desc, XEvent *event)
WScreen *scr = aicon->icon->core->screen_ptr;
int unhideHere;
#ifndef REDUCE_APPICONS
assert(aicon->icon->owner!=NULL);
#else
if (aicon->icon->owner == NULL) {
fprintf(stderr, "Double-click disabled: missing main window.\n");
return;
}
#endif
wapp = wApplicationOf(aicon->icon->owner->main_window);
#ifdef DEBUG0
@@ -680,12 +626,6 @@ iconDblClick(WObjDescriptor *desc, XEvent *event)
return;
}
#endif
#ifdef REDUCE_APPICONS
if (!wapp) {
fprintf(stderr, "Double-click disabled: missing wapp.\n");
return;
}
#endif /* REDUCE_APPICONS */
unhideHere = (event->xbutton.state & ShiftMask);
@@ -701,6 +641,7 @@ iconDblClick(WObjDescriptor *desc, XEvent *event)
}
void
appIconMouseDown(WObjDescriptor *desc, XEvent *event)
{
@@ -719,6 +660,9 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event)
int clickButton = event->xbutton.button;
Pixmap ghost = None;
Window wins[2];
Bool movingSingle = False;
int oldX = x;
int oldY = y;
if (aicon->editing || WCHECK_STATE(WSTATE_MODAL))
return;
@@ -808,7 +752,12 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event)
}
x = ev.xmotion.x_root - dx;
y = ev.xmotion.y_root - dy;
if (movingSingle) {
XMoveWindow(dpy, icon->core->window, x, y);
} else {
wAppIconMove(aicon, x, y);
}
if (dockable) {
if (scr->dock && wDockSnapIcon(scr->dock, aicon, x, y,
@@ -896,17 +845,31 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event)
if (!docked) {
/* If icon could not be docked, slide it back to the old
* position */
SlideWindow(icon->core->window, x, y, aicon->x_pos,
aicon->y_pos);
SlideWindow(icon->core->window, x, y, oldX, oldY);
} else {
WAppIcon *nextIcon = wAppIconNextSibling(aicon);
if (nextIcon) {
/* move the next instance back to the old position */
SlideWindow(nextIcon->icon->core->window, x, y,
oldX, oldY);
wAppIconMove(nextIcon, oldX, oldY);
}
}
#ifdef WSOUND
wSoundPlay(WSOUND_DOCK);
#endif
} else {
if (movingSingle) {
/* move back to its place */
SlideWindow(icon->core->window, x, y, oldX, oldY);
wAppIconMove(aicon, oldX, oldY);
} else {
XMoveWindow(dpy, icon->core->window, x, y);
aicon->x_pos = x;
aicon->y_pos = y;
}
if (workspace->clip && workspace->clip->auto_raise_lower)
wDockLower(workspace->clip);
}

View File

@@ -31,13 +31,6 @@
#include "icon.h"
#include "application.h"
#ifdef REDUCE_APPICONS
typedef struct WAppIconAppList {
struct WAppIconAppList *prev;
struct WAppIconAppList *next;
WApplication *wapp;
} WAppIconAppList;
#endif
typedef struct WAppIcon {
short xindex;
@@ -61,15 +54,7 @@ typedef struct WAppIcon {
char *wm_instance;
pid_t pid; /* for apps launched from the dock */
Window main_window;
#ifdef REDUCE_APPICONS
/* There are a number of assumptions about structures in the code,
* but nowhere do I see them explicitly stated. I'll rip this out later.
* If applist is not NULL, applist->wapp will always point to a valid
* structure. Knowing this removes the need for useless checks....
* AS LONG AS NO ONE VIOLATES THIS ASSUMPTION. -cls
*/
WAppIconAppList *applist; /* list of apps bound to appicon */
#endif
struct WDock *dock; /* In which dock is docked. */
struct _AppSettingsPanel *panel; /* Settings Panel */
@@ -94,9 +79,6 @@ typedef struct WAppIcon {
unsigned int lock:1; /* do not allow to be destroyed */
#ifdef REDUCE_APPICONS
unsigned int num_apps; /* length of applist */
#endif
} WAppIcon;
@@ -112,7 +94,7 @@ Bool wAppIconChangeImage(WAppIcon *icon, char *file);
void wAppIconMove(WAppIcon *aicon, int x, int y);
#ifdef REDUCE_APPICONS
unsigned int wAppIconReduceAppCount(WApplication *wapp);
#endif
WAppIcon *wAppIconNextSibling(WAppIcon *icon);
int wAppIconIndexOfInstance(WAppIcon *icon);
#endif

View File

@@ -300,6 +300,25 @@ wApplicationCreate(WScreen *scr, Window main_window)
#endif /* USER_MENU */
{
WApplication *tmp = scr->wapp_list;
wapp->next = NULL;
wapp->prev = NULL;
/* append to app list */
if (!tmp) {
scr->wapp_list = wapp;
} else {
while (tmp->next) {
tmp = tmp->next;
}
tmp->next = wapp;
wapp->prev = tmp;
}
}
/*
* Set application wide attributes from the leader.
*/
@@ -341,18 +360,6 @@ wApplicationCreate(WScreen *scr, Window main_window)
wAppIconPaint(wapp->app_icon);
} else {
wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
#ifdef REDUCE_APPICONS
/* This is so we get the appearance of invoking the app sitting
* on the dock. -cls */
if (wapp->app_icon) {
if (wapp->app_icon->docked && wapp->app_icon->num_apps == 1) {
wapp->app_icon->launching = 0;
wapp->app_icon->running = 1;
wapp->app_icon->icon->force_paint = 1;
wAppIconPaint(wapp->app_icon);
}
}
#endif
}
} else {
wapp->app_icon = NULL;
@@ -362,14 +369,7 @@ wApplicationCreate(WScreen *scr, Window main_window)
wapp->app_icon->main_window = main_window;
}
#ifndef REDUCE_APPICONS
if (wapp->app_icon && !wapp->app_icon->docked) {
#else
if (wapp->app_icon && !wapp->app_icon->docked && wapp->app_icon->num_apps == 1) {
#ifdef THIS_SUCKS
}
#endif
#endif
WIcon *icon = wapp->app_icon->icon;
WDock *clip = scr->workspaces[scr->current_workspace]->clip;
int x=0, y=0;
@@ -407,12 +407,6 @@ wApplicationCreate(WScreen *scr, Window main_window)
extractClientIcon(wapp->app_icon);
}
wapp->prev = NULL;
wapp->next = scr->wapp_list;
if (scr->wapp_list)
scr->wapp_list->prev = wapp;
scr->wapp_list = wapp;
#ifdef WSOUND
wSoundPlay(WSOUND_APPSTART);
@@ -431,9 +425,6 @@ wApplicationDestroy(WApplication *wapp)
Window main_window;
WWindow *wwin;
WScreen *scr;
#ifdef REDUCE_APPICONS
unsigned int napps;
#endif
if (!wapp)
return;
@@ -445,9 +436,6 @@ wApplicationDestroy(WApplication *wapp)
scr = wapp->main_window_desc->screen_ptr;
main_window = wapp->main_window;
#ifdef REDUCE_APPICONS
napps = wAppIconReduceAppCount(wapp);
#endif
if (wapp == scr->wapp_list) {
if (wapp->next)
@@ -464,9 +452,6 @@ wApplicationDestroy(WApplication *wapp)
wAppMenuDestroy(wapp->menu);
if (wapp->app_icon) {
if (wapp->app_icon->docked && !wapp->app_icon->attracted) {
#ifdef REDUCE_APPICONS
if (napps == 0) {
#endif
wapp->app_icon->running = 0;
/* since we keep it, we don't care if it was attracted or not */
wapp->app_icon->attracted = 0;
@@ -477,26 +462,11 @@ wApplicationDestroy(WApplication *wapp)
wapp->app_icon->icon->icon_win = None;
wapp->app_icon->icon->force_paint = 1;
wAppIconPaint(wapp->app_icon);
#ifdef REDUCE_APPICONS
}
#endif
} else if (wapp->app_icon->docked) {
#ifdef REDUCE_APPICONS
if (napps == 0) {
#endif
wapp->app_icon->running = 0;
wDockDetach(wapp->app_icon->dock, wapp->app_icon);
#ifdef REDUCE_APPICONS
}
#endif
} else {
#ifdef REDUCE_APPICONS
if (napps == 0) {
#endif
wAppIconDestroy(wapp->app_icon);
#ifdef REDUCE_APPICONS
}
#endif
}
}
wwin = wWindowFor(wapp->main_window_desc->client_win);
@@ -523,3 +493,58 @@ wApplicationDestroy(WApplication *wapp)
}
/*
* Returns index number of the app in case there are more than
* one instance of the same class/name.
*/
int
wApplicationIndexOfInstance(WApplication *app)
{
WApplication *list = app->main_window_desc->screen_ptr->wapp_list;
int index = 0;
WWindow *wwin = app->main_window_desc;
while (list) {
if (app == list)
return index;
if (strcmp(wwin->wm_instance,
list->main_window_desc->wm_instance) == 0
&&
strcmp(wwin->wm_class,
list->main_window_desc->wm_class) == 0)
index++;
list = list->next;
}
puts("OH SHIT!?!?!? HOW THE FUCK DID WE GET HERE!?!?!?!?!");
return 0;
}
Bool
wApplicationHasMultiInstances(WApplication *app)
{
WApplication *list = app->main_window_desc->screen_ptr->wapp_list;
int index = 0;
WWindow *wwin = app->main_window_desc;
while (list) {
if (strcmp(wwin->wm_instance,
list->main_window_desc->wm_instance) == 0
&&
strcmp(wwin->wm_class,
list->main_window_desc->wm_class) == 0)
index++;
if (index == 2)
return True;
list = list->next;
}
return False;
}

View File

@@ -55,9 +55,13 @@ void wApplicationDestroy(WApplication *wapp);
WApplication *wApplicationOf(Window window);
Bool wApplicationHasMultiInstances(WApplication *app);
void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance,
char *wm_class);
int wApplicationIndexOfInstance(WApplication *app);
#ifdef NEWAPPICON

View File

@@ -297,6 +297,8 @@ wClientKill(WWindow *wwin)
XFlush(dpy);
}
/*
*----------------------------------------------------------------------
* wClientCheckProperty--
@@ -316,30 +318,18 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event)
XWindowAttributes attribs;
XWMHints *new_hints;
int i, g1, g2;
char *tmp;
char *tmp = NULL;
switch (event->atom) {
case XA_WM_NAME:
/* window title was changed */
wwin->flags.wm_name_changed = 1;
if (wwin->frame) {
if (!wFetchName(dpy, wwin->client_win, &tmp)) {
/* the hint was removed */
tmp = wstrdup(DEF_WINDOW_TITLE);
#ifdef KWM_HINTS
wKWMSendEventMessage(wwin, WKWMChangedClient);
#endif
}
if (wFrameWindowChangeTitle(wwin->frame, tmp)) {
/* only update the menu if the title has actually changed */
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE);
#ifdef KWM_HINTS
wKWMSendEventMessage(wwin, WKWMChangedClient);
#endif
wWindowUpdateName(wwin, NULL);
} else {
wWindowUpdateName(wwin, tmp);
}
if (tmp)
wfree(tmp);
}
XFree(tmp);
break;
case XA_WM_ICON_NAME:

View File

@@ -237,13 +237,7 @@ static void
killCallback(WMenu *menu, WMenuEntry *entry)
{
WAppIcon *icon;
#ifdef REDUCE_APPICONS
WAppIconAppList *tapplist;
extern Atom _XA_WM_DELETE_WINDOW;
#else
char *buffer;
#endif
if (!WCHECK_STATE(WSTATE_NORMAL))
return;
@@ -256,23 +250,6 @@ killCallback(WMenu *menu, WMenuEntry *entry)
WCHANGE_STATE(WSTATE_MODAL);
#ifdef REDUCE_APPICONS
/* Send a delete message to the main window of each application
* bound to this docked appicon. - cls
*/
tapplist = icon->applist;
while (tapplist != NULL) {
if (tapplist->wapp->main_window_desc != NULL) {
if (tapplist->wapp->main_window_desc->protocols.DELETE_WINDOW) {
wClientSendProtocol(tapplist->wapp->main_window_desc,
_XA_WM_DELETE_WINDOW, CurrentTime);
} else {
wClientKill(tapplist->wapp->main_window_desc);
}
}
tapplist = tapplist->next;
}
#else
buffer = wstrconcat(icon->wm_class,
_(" will be forcibly closed.\n"
"Any unsaved changes will be lost.\n"
@@ -287,7 +264,6 @@ killCallback(WMenu *menu, WMenuEntry *entry)
}
wfree(buffer);
#endif /* !REDUCE_APPICONS */
icon->editing = 0;
@@ -1988,23 +1964,6 @@ wDockDoAutoLaunch(WDock *dock, int workspace)
}
}
#ifdef REDUCE_APPICONS
void
wDockSimulateLaunch(WDock *dock, WAppIcon *btn)
{
if ((btn == NULL) || (dock == NULL))
return;
if (!btn->running) {
if ((btn->icon->owner == NULL) && (btn->applist))
btn->icon->owner = btn->applist->wapp->main_window_desc;
if (!btn->forced_dock)
btn->launching = 1;
dockIconPaint(btn);
wusleep(5000);
}
}
#endif
#ifdef OFFIX_DND
static WDock*
@@ -2389,11 +2348,7 @@ wDockDetach(WDock *dock, WAppIcon *icon)
/* if the dock is not attached to an application or
* the the application did not set the approriate hints yet,
* destroy the icon */
#ifdef REDUCE_APPICONS
if ((icon->num_apps == 0) && (!icon->running || !wApplicationOf(icon->main_window)) )
#else
if (!icon->running || !wApplicationOf(icon->main_window))
#endif
wAppIconDestroy(icon);
else {
icon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
@@ -2407,6 +2362,14 @@ wDockDetach(WDock *dock, WAppIcon *icon)
wAppIconPaint(icon);
if (wPreferences.auto_arrange_icons) {
wArrangeIcons(dock->screen_ptr, True);
} else {
WAppIcon *bla = wAppIconNextSibling(icon);
if (bla) {
SlideWindow(icon->icon->core->window, icon->x_pos, icon->y_pos,
bla->x_pos, bla->y_pos);
wAppIconMove(icon, bla->x_pos, bla->y_pos);
}
}
}
if (dock->auto_collapse || dock->auto_raise_lower)
@@ -3118,9 +3081,6 @@ void
wDockTrackWindowLaunch(WDock *dock, Window window)
{
WAppIcon *icon;
#ifdef REDUCE_APPICONS
WAppIconAppList *tapplist;
#endif
char *wm_class, *wm_instance;
int i;
Bool firstPass = True;
@@ -3186,16 +3146,6 @@ retry:
if (!icon->forced_dock)
icon->main_window = window;
#ifdef REDUCE_APPICONS
tapplist = wmalloc(sizeof(WAppIconAppList));
memset(tapplist, 0, sizeof(WAppIconAppList));
tapplist->next = icon->applist;
if (icon->applist)
icon->applist->prev = tapplist;
icon->applist = tapplist;
tapplist->wapp = wApplicationOf(window);
icon->num_apps++;
#endif
}
found = True;
wDockFinishLaunch(dock, icon);
@@ -3528,14 +3478,7 @@ iconDblClick(WObjDescriptor *desc, XEvent *event)
WApplication *wapp = NULL;
int unhideHere = 0;
#ifdef REDUCE_APPICONS
if ((btn->icon->owner && !(event->xbutton.state & ControlMask)) ||
((btn->icon->owner == NULL) && (btn->applist != NULL))) {
if (btn->icon->owner == NULL)
btn->icon->owner = btn->applist->wapp->main_window_desc;
#else
if (btn->icon->owner && !(event->xbutton.state & ControlMask)) {
#endif
wapp = wApplicationOf(btn->icon->owner->main_window);
assert(wapp!=NULL);

View File

@@ -480,14 +480,9 @@ handleMapRequest(XEvent *ev)
} else if (wwin->flags.hidden) {
WApplication *wapp = wApplicationOf(wwin->main_window);
/* go to the last workspace that the user worked on the app */
#ifndef REDUCE_APPICONS
/* This severely breaks REDUCE_APPICONS. last_workspace is a neat
* concept but it needs to be reworked to handle REDUCE_APPICONS -cls
*/
if (wapp) {
wWorkspaceChange(wwin->screen_ptr, wapp->last_workspace);
}
#endif
wUnhideApplication(wapp, False, False);
}
return;

View File

@@ -1014,11 +1014,10 @@ wFrameWindowPaint(WFrameWindow *fwin)
}
if (fwin->title && fwin->titlebar && !fwin->flags.repaint_only_resizebar) {
if (fwin->titlebar && !fwin->flags.repaint_only_resizebar) {
int x, w;
int lofs = 6, rofs = 6;
int titlelen;
char *title;
int allButtons = 1;
@@ -1049,6 +1048,9 @@ wFrameWindowPaint(WFrameWindow *fwin)
scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode];
#endif
if (fwin->title) {
char *title;
title = ShrinkString(*fwin->font, fwin->title,
fwin->titlebar->width - lofs - rofs);
titlelen = strlen(title);
@@ -1079,6 +1081,7 @@ wFrameWindowPaint(WFrameWindow *fwin)
title, titlelen);
wfree(title);
}
if (fwin->left_button)
handleButtonExpose(&fwin->left_button->descriptor, NULL);

View File

@@ -518,6 +518,7 @@ wWindowObscuresWindow(WWindow *wwin, WWindow *obscured)
}
/*
*----------------------------------------------------------------
* wManageWindow--
@@ -1020,9 +1021,6 @@ wManageWindow(WScreen *scr, Window window)
wFrameWindowUpdatePushButton(wwin->frame, True);
#endif /* OLWM_HINTS */
wFrameWindowChangeTitle(wwin->frame, title ? title : DEF_WINDOW_TITLE);
if (title)
XFree(title);
wwin->frame->workspace = workspace;
@@ -1211,6 +1209,12 @@ wManageWindow(WScreen *scr, Window window)
wwin->prev = NULL;
}
/* Update name must come after WApplication stuff is done */
wWindowUpdateName(wwin, title);
if (title)
XFree(title);
#ifdef GNOME_STUFF
wGNOMEUpdateClientStateHint(wwin, True);
#endif
@@ -1755,6 +1759,53 @@ wWindowUnfocus(WWindow *wwin)
}
void
wWindowUpdateName(WWindow *wwin, char *newTitle)
{
WApplication *app = wApplicationOf(wwin->main_window);
int instIndex = 0;
Bool res;
char prefix[32] = "";
char *tmp, *title;
if (!wwin->frame)
return;
if (app)
instIndex = wApplicationIndexOfInstance(app);
wwin->flags.wm_name_changed = 1;
if (!newTitle) {
/* the hint was removed */
title = DEF_WINDOW_TITLE;
#ifdef KWM_HINTS
wKWMSendEventMessage(wwin, WKWMChangedClient);
#endif
} else {
title = newTitle;
}
if (instIndex > 0) {
sprintf(prefix, " [%i]", instIndex);
title = wstrconcat(title, prefix);
}
if (wFrameWindowChangeTitle(wwin->frame, title)) {
/* only update the menu if the title has actually changed */
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE);
#ifdef KWM_HINTS
wKWMSendEventMessage(wwin, WKWMChangedClient);
#endif
}
if (instIndex > 0)
wfree(title);
}
/*
*----------------------------------------------------------------------

View File

@@ -347,6 +347,8 @@ void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed);
void wWindowFocus(WWindow *wwin, WWindow *owin);
void wWindowUnfocus(WWindow *wwin);
void wWindowUpdateName(WWindow *wwin, char *newTitle);
void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight);
void wWindowConfigure(WWindow *wwin, int req_x, int req_y,
int req_width, int req_height);