1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-11 00:44:12 +01:00

fixed bug with bag sorting

fixed bug with stacking code
This commit is contained in:
kojima
2000-03-30 02:52:07 +00:00
parent 15734b9147
commit f65c549814
36 changed files with 5665 additions and 520 deletions

View File

@@ -460,40 +460,40 @@ wAppIconReduceAppCount(WApplication *wapp)
/* 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;
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->next)
applist->next->prev = applist->prev;
if (applist == wapp->app_icon->applist)
wapp->app_icon->applist = applist->next;
wapp->app_icon->applist = applist->next;
free(applist);
free(applist);
if (wapp->app_icon->applist != NULL)
wapp->app_icon->main_window = wapp->app_icon->applist->wapp->main_window;
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);
}
applist = applist->next;
}
return (--wapp->app_icon->num_apps);
}
#endif

View File

@@ -533,7 +533,7 @@ removeIconsCallback(WMenu *menu, WMenuEntry *entry)
WAppIcon *aicon;
WMBag *selectedIcons;
int keepit;
int i;
WMBagIterator it;
assert(clickedIcon!=NULL);
@@ -556,8 +556,7 @@ removeIconsCallback(WMenu *menu, WMenuEntry *entry)
WMPutInBag(selectedIcons, clickedIcon);
}
for (i = 0; i < WMGetBagItemCount(selectedIcons); i++) {
aicon = WMGetFromBag(selectedIcons, i);
WM_ITERATE_BAG(selectedIcons, aicon, it) {
keepit = aicon->running && wApplicationOf(aicon->main_window);
wDockDetach(dock, aicon);
if (keepit) {
@@ -582,7 +581,7 @@ keepIconsCallback(WMenu *menu, WMenuEntry *entry)
WDock *dock;
WAppIcon *aicon;
WMBag *selectedIcons;
int i;
WMBagIterator it;
assert(clickedIcon!=NULL);
dock = clickedIcon->dock;
@@ -617,8 +616,7 @@ keepIconsCallback(WMenu *menu, WMenuEntry *entry)
WMPutInBag(selectedIcons, clickedIcon);
}
for (i = 0; i < WMGetBagItemCount(selectedIcons); i++) {
aicon = WMGetFromBag(selectedIcons, i);
WM_ITERATE_BAG(selectedIcons, aicon, it) {
if (aicon->icon->selected)
wIconSelect(aicon->icon);
if (aicon && aicon->attracted && aicon->command) {

View File

@@ -1711,7 +1711,6 @@ wMouseMoveWindow(WWindow *wwin, XEvent *ev)
/* discard all enter/leave events that happened until
* the time the button was released */
/*
while (XCheckTypedEvent(dpy, EnterNotify, &e)) {
if (e.xcrossing.time > event.xbutton.time) {
XPutBackEvent(dpy, &e);
@@ -1723,7 +1722,7 @@ wMouseMoveWindow(WWindow *wwin, XEvent *ev)
XPutBackEvent(dpy, &e);
break;
}
}*/
}
if (!scr->selected_windows) {
/* get rid of the geometry window */

View File

@@ -644,7 +644,7 @@ constructMenu(WMenu *menu, WMenuEntry *entry)
time_t last=0;
separateCommand((char*)entry->clientdata, &path, &cmd);
if (!path || *path==NULL || **path==0) {
if (path == NULL || *path==NULL || **path==0) {
wwarning(_("invalid OPEN_MENU specification: %s"),
(char*)entry->clientdata);
return;

View File

@@ -174,7 +174,7 @@ RestoreDesktop(WScreen *scr)
/* reparent windows back to the root window, keeping the stacking order */
for (core = WMBagFirst(scr->stacking_list, &iter);
core != NULL;
iter != NULL;
core = WMBagNext(scr->stacking_list, &iter)) {
WCoreWindow *next;
WWindow *wwin;

View File

@@ -45,10 +45,6 @@ extern XContext wStackContext;
extern WPreferences wPreferences;
/*
*----------------------------------------------------------------------
* RemakeStackList--
@@ -103,13 +99,13 @@ RemakeStackList(WScreen *scr)
}
#endif
scr->window_count = c;
}
}
CommitStacking(scr);
}
/*
*----------------------------------------------------------------------
* CommitStacking--
@@ -185,113 +181,74 @@ moveFrameToUnder(WCoreWindow *under, WCoreWindow *frame)
/*
*----------------------------------------------------------------------
* wRaiseFrame--
* Raises a frame taking the window level and the on_top flag
* into account.
* Raises a frame taking the window level into account.
*
* Returns:
* None
*
* Side effects:
* Window stacking order and window list is changed.
* Window stacking order and stacking list are changed.
*
*----------------------------------------------------------------------
*/
void
wRaiseFrame(WCoreWindow *frame)
{
WCoreWindow *wlist = frame, *wlist_above;
WCoreWindow *wlist = frame;
int level = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
/* already on top */
if (frame->stacking->above == NULL) {
return;
}
/* insert on top of other windows */
while (wlist) {
if (wlist == (wlist_above = wlist->stacking->above)) {
wwarning("You just found a bug in wmaker. Please try to figure what type of raising/lowering operations you did with which applications and report. Please give complete information about how to reproduce it.");
break;
} else {
wlist=wlist_above;
}
}
/* window is inserted before the point found */
if (wlist==NULL) {
/* top most window (last on the list) */
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
/* insert it on top of other windows on the same level */
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
frame->stacking->above = NULL;
frame->stacking->under = WMGetFromBag(scr->stacking_list, level);
frame->stacking->under->stacking->above = frame;
WMSetInBag(scr->stacking_list, level, frame);
frame->stacking->above = NULL;
frame->stacking->under = WMGetFromBag(scr->stacking_list, level);
frame->stacking->under->stacking->above = frame;
WMSetInBag(scr->stacking_list, level, frame);
} else if (frame!=wlist) {
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
frame->stacking->above = wlist;
frame->stacking->under = wlist->stacking->under;
if (wlist->stacking->under)
wlist->stacking->under->stacking->above = frame;
wlist->stacking->under = frame;
}
#ifdef removed
if (wPreferences.on_top_transients)
#endif
{
/* raise transients under us from bottom to top
* so that the order is kept */
again:
wlist = frame->stacking->under;
while (wlist && wlist->stacking->under)
wlist = wlist->stacking->under;
while (wlist && wlist!=frame) {
if (wlist->stacking->child_of == frame) {
wRaiseFrame(wlist);
goto again;
}
wlist = wlist->stacking->above;
/* raise transients under us from bottom to top
* so that the order is kept */
again:
wlist = frame->stacking->under;
while (wlist && wlist->stacking->under)
wlist = wlist->stacking->under;
while (wlist && wlist!=frame) {
if (wlist->stacking->child_of == frame) {
wRaiseFrame(wlist);
goto again;
}
# if 0
again:
wlist = frame->stacking->under;
while (wlist) {
if (wlist->stacking->child_of == frame) {
/* transient for us */
wRaiseFrame(wlist);
goto again; /* need this or we'll get in a loop */
}
wlist = wlist->stacking->under;
}
#endif
wlist = wlist->stacking->above;
}
/* try to optimize things a little */
if (frame->stacking->above == NULL) {
WCoreWindow *above;
WMBagIterator iter;
WCoreWindow *above = WMBagLast(scr->stacking_list, &iter);
int i, last = above->stacking->window_level;
for (above = WMBagIteratorAtIndex(scr->stacking_list, level+1, &iter);
iter != NULL;
above = WMBagNext(scr->stacking_list, &iter)) {
/* find the 1st level above us which has windows in it */
for (i = level+1, above = NULL; i <= last; i++) {
above = WMGetFromBag(scr->stacking_list, i);
if (above != NULL)
break;
}
/* can't optimize */
if (above != frame && above != NULL) {
while (above->stacking->under)
above = above->stacking->under;
break;
}
if (above == NULL) {
XRaiseWindow(dpy, frame->window);
} else {
moveFrameToUnder(above, frame);
} else {
/* no window above us */
above = NULL;
XRaiseWindow(dpy, frame->window);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
@@ -349,24 +306,17 @@ void
wLowerFrame(WCoreWindow *frame)
{
WScreen *scr = frame->screen_ptr;
WCoreWindow *prev, *wlist=frame;
WCoreWindow *wlist=frame;
int level = frame->stacking->window_level;
/* already in bottom */
if (wlist->stacking->under == NULL) {
return;
}
#ifdef removed
if (wPreferences.on_top_transients &&
wlist->stacking->under==wlist->stacking->child_of) {
/* cant lower transient below below its owner */
if (wlist->stacking->under == wlist->stacking->child_of) {
return;
}
#else
if (wlist->stacking->under==wlist->stacking->child_of) {
return;
}
#endif
prev = wlist;
/* remove from the list */
if (WMGetFromBag(scr->stacking_list, level) == frame) {
/* it was the top window */
@@ -381,9 +331,6 @@ wLowerFrame(WCoreWindow *frame)
wlist = WMGetFromBag(scr->stacking_list, level);
/* look for place to put this window */
#ifdef removed
if (wPreferences.on_top_transients)
#endif
{
WCoreWindow *owner = frame->stacking->child_of;
@@ -392,18 +339,11 @@ wLowerFrame(WCoreWindow *frame)
/* if this is a transient, it should not be placed under
* it's owner */
if (owner == wlist->stacking->under)
break;
break;
wlist = wlist->stacking->under;
}
}
}
#ifdef removed
else {
while (wlist->stacking->under) {
wlist = wlist->stacking->under;
}
}
#endif
/* insert under the place found */
frame->stacking->above = wlist;
frame->stacking->under = wlist->stacking->under;
@@ -411,24 +351,25 @@ wLowerFrame(WCoreWindow *frame)
wlist->stacking->under->stacking->above = frame;
wlist->stacking->under = frame;
/* try to optimize things a little */
if (frame->stacking->above == NULL) {
WCoreWindow *above = NULL;
WMBagIterator iter;
for (above = WMBagIteratorAtIndex(scr->stacking_list, level-1, &iter);
iter != NULL;
above = WMBagPrevious(scr->stacking_list, &iter)) {
/* can't optimize */
WCoreWindow *above = WMBagLast(scr->stacking_list, &iter);
int i, last = above->stacking->window_level;
/* find the 1st level above us which has windows in it */
for (i = level+1, above = NULL; i <= last; i++) {
above = WMGetFromBag(scr->stacking_list, i);
if (above != NULL)
break;
}
if (above != frame && above != NULL) {
while (above->stacking->under)
above = above->stacking->under;
break;
}
if (!above) {
XLowerWindow(dpy, frame->window);
} else {
moveFrameToUnder(above, frame);
} else {
/* no window below us */
XLowerWindow(dpy, frame->window);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
@@ -461,58 +402,50 @@ wLowerFrame(WCoreWindow *frame)
void
AddToStackList(WCoreWindow *frame)
{
WCoreWindow *prev, *tmpw, *wlist;
WCoreWindow *curtop, *wlist;
int index = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
WCoreWindow *trans = NULL;
frame->screen_ptr->window_count++;
XSaveContext(dpy, frame->window, wStackContext, (XPointer)frame);
tmpw = WMGetFromBag(scr->stacking_list, index);
curtop = WMGetFromBag(scr->stacking_list, index);
if (!tmpw) {
/* first window in this level */
if (curtop == NULL) {
WMSetInBag(scr->stacking_list, index, frame);
frame->stacking->above = NULL;
frame->stacking->under = NULL;
CommitStacking(scr);
return;
}
prev = tmpw;
/* check if this is a transient owner */
#ifdef removed
if (wPreferences.on_top_transients)
#endif
{
WCoreWindow *trans = NULL;
wlist = WMGetFromBag(scr->stacking_list, index);
while (wlist) {
if (wlist->stacking->child_of == frame)
trans = wlist;
wlist = wlist->stacking->under;
}
frame->stacking->above = trans;
if (trans) {
frame->stacking->under = trans->stacking->under;
if (trans->stacking->under) {
trans->stacking->under->stacking->above = frame;
}
trans->stacking->under = frame;
} else {
frame->stacking->under = tmpw;
tmpw->stacking->above = frame;
WMSetInBag(scr->stacking_list, index, frame);
}
wlist = curtop;
while (wlist) {
if (wlist->stacking->child_of == frame)
trans = wlist;
wlist = wlist->stacking->under;
}
#ifdef removed
else {
/* put on top of the stacking list */
frame->stacking->above = NULL;
frame->stacking->under = tmpw;
tmpw->stacking->above = frame;
/* trans will hold the transient in the lowest position
* in stacking list */
frame->stacking->above = trans;
if (trans != NULL) {
/* window is owner of a transient.. put it below
* the lowest transient */
frame->stacking->under = trans->stacking->under;
if (trans->stacking->under) {
trans->stacking->under->stacking->above = frame;
}
trans->stacking->under = frame;
} else {
/* window is not owner of transients.. just put it in the
* top of other windows */
frame->stacking->under = curtop;
curtop->stacking->above = frame;
WMSetInBag(scr->stacking_list, index, frame);
}
#endif
CommitStacking(scr);
}
@@ -657,6 +590,7 @@ void
ChangeStackingLevel(WCoreWindow *frame, int new_level)
{
int old_level;
if (frame->stacking->window_level == new_level)
return;
old_level = frame->stacking->window_level;