Lines Matching defs:owl
50 #define PRI(owl) OwlEffectivePriority(owl)
84 static void OwlSetAflagMask(OtpWinList *owl, unsigned mask, unsigned setto);
85 static void OwlSetAflag(OtpWinList *owl, unsigned flag);
86 static void OwlClearAflag(OtpWinList *owl, unsigned flag);
87 static void OwlStashAflags(OtpWinList *owl);
88 static unsigned OwlGetStashedAflags(OtpWinList *owl, bool *gotit);
89 static int OwlEffectivePriority(OtpWinList *owl);
91 static Box BoxOfOwl(OtpWinList *owl)
95 switch(owl->type) {
97 Icon *icon = owl->twm_win->icon;
106 TwmWindow *twm_win = owl->twm_win;
139 static bool isOnScreen(OtpWinList *owl)
141 TwmWindow *twm_win = owl->twm_win;
143 return (((owl->type == IconWin) ? twm_win->iconified : twm_win->mapped)
182 static Window WindowOfOwl(OtpWinList *owl)
184 return (owl->type == IconWin)
185 ? owl->twm_win->icon->w : owl->twm_win->frame;
208 OtpWinList *owl;
230 for(owl = Scr->bottomOwl; owl != NULL; owl = owl->above) {
231 twm_win = owl->twm_win;
234 assert(((owl->type == IconWin) && (owl == twm_win->icon->otp))
235 || ((owl->type == WinWin) && (owl == twm_win->otp)));
238 if(owl->below == NULL) {
239 assert(owl == Scr->bottomOwl);
242 assert(owl->below->above == owl);
246 assert(owl->pri_base <= OTP_MAX);
250 const int nextpri = PRI(owl);
255 priority, owl->below->twm_win->name,
256 nextpri, owl->twm_win->name);
265 fprintf(stderr, "checking owl: pri %d w=%x stack=%d",
266 priority, (unsigned int)WindowOfOwl(owl), stack);
271 if(owl->twm_win->vs) {
279 if(owl->twm_win->parent_vs) {
288 fprintf(stderr, " %s\n", (owl->type == WinWin ? "Window" : "Icon"));
292 if(owl->type == WinWin) {
313 Window windowOfOwl = WindowOfOwl(owl);
320 fprintf(stderr, "search for owl in stack -> i=%d\n", i);
357 static void RemoveOwl(OtpWinList *owl)
359 if(owl->above != NULL) {
360 owl->above->below = owl->below;
362 if(owl->below != NULL) {
363 owl->below->above = owl->above;
366 Scr->bottomOwl = owl->above;
368 owl->below = NULL;
369 owl->above = NULL;
378 static OtpWinList *GetOwlAtOrBelowInVS(OtpWinList *owl, VirtualScreen *vs)
380 while(owl != NULL && owl->twm_win->parent_vs != vs) {
381 owl = owl->below;
384 return owl;
393 * Therefore we may need to update the owl we're going to be above.
397 OtpWinList *owl = *owlp;
399 while(owl != NULL && owl->twm_win->winbox != wb) {
400 owl = owl->below;
403 if(owl == NULL) {
408 *owlp = owl;
410 return owl;
415 static void InsertOwlAbove(OtpWinList *owl, OtpWinList *other_owl)
418 fprintf(stderr, "InsertOwlAbove owl->pri=%d w=0x%x parent_vs:(x,y)=(%d,%d)",
419 PRI(owl),
420 (unsigned int)WindowOfOwl(owl),
421 owl->twm_win->parent_vs->x,
422 owl->twm_win->parent_vs->y);
427 owl->twm_win->parent_vs->x,
428 owl->twm_win->parent_vs->y);
433 assert(owl->above == NULL);
434 assert(owl->below == NULL);
440 assert(PRI(owl) <= PRI(Scr->bottomOwl));
443 XLowerWindow(dpy, WindowOfOwl(owl));
446 owl->above = Scr->bottomOwl;
447 owl->above->below = owl;
448 Scr->bottomOwl = owl;
452 WindowBox *winbox = owl->twm_win->winbox;
466 vs_owl = GetOwlAtOrBelowInVS(other_owl, owl->twm_win->parent_vs);
469 assert(PRI(owl) >= PRI(other_owl));
471 assert(PRI(owl) <= PRI(other_owl->above));
479 XLowerWindow(dpy, WindowOfOwl(owl));
488 assert(owl->twm_win->parent_vs == vs_owl->twm_win->parent_vs);
494 XConfigureWindow(dpy, WindowOfOwl(owl), xwcm, &xwc);
498 owl->below = other_owl;
499 owl->above = other_owl->above;
500 owl->below->above = owl;
501 if(owl->above != NULL) {
502 owl->above->below = owl;
508 /* should owl stay above other_owl if other_owl was raised ? */
509 static bool shouldStayAbove(OtpWinList *owl, OtpWinList *other_owl)
511 return ((owl->type == WinWin)
513 && isSmallTransientOf(owl->twm_win, other_owl->twm_win));
517 static void RaiseSmallTransientsOfAbove(OtpWinList *owl, OtpWinList *other_owl)
522 if((owl->type != WinWin) || other_owl == NULL) {
529 if(shouldStayAbove(trans_owl, owl)) {
531 PRI_CP(owl, trans_owl);
561 static void InsertOwl(OtpWinList *owl, int where)
570 assert(owl->above == NULL);
571 assert(owl->below == NULL);
574 priority = PRI(owl) - (where == Above ? 0 : 1);
578 Scr->bottomOwl = owl;
585 && shouldStayAbove(other_owl, owl)) {
586 PRI_CP(owl, other_owl);
592 RaiseSmallTransientsOfAbove(owl, other_owl);
595 InsertOwlAbove(owl, other_owl);
600 static void SetOwlPriority(OtpWinList *owl, int new_pri, int where)
612 RemoveOwl(owl);
613 owl->pri_base = new_pri;
614 InsertOwl(owl, where);
616 assert(owl->pri_base == new_pri);
624 static void TryToMoveTransientsOfTo(OtpWinList *owl, int priority, int where)
629 if(owl->type != WinWin) {
634 * We start looking for transients of owl at the bottom of its OTP
637 other_owl = OwlRightBelow(PRI(owl));
639 assert(PRI(other_owl) >= PRI(owl));
642 while((other_owl != NULL) && (PRI(other_owl) == PRI(owl))) {
645 && isTransientOf(other_owl->twm_win, owl->twm_win)) {
647 other_owl->pri_aflags = owl->pri_aflags;
654 static void TryToSwitch(OtpWinList *owl, int where)
658 if(!owl->switching) {
666 priority = OTP_MAX - owl->pri_base;
667 if(((where == Above) && (priority > owl->pri_base)) ||
668 ((where == Below) && (priority < owl->pri_base))) {
673 TryToMoveTransientsOfTo(owl, priority, where);
674 owl->pri_base = priority;
678 static void RaiseOwl(OtpWinList *owl)
680 TryToSwitch(owl, Above);
681 RemoveOwl(owl);
682 InsertOwl(owl, Above);
686 static void LowerOwl(OtpWinList *owl)
688 TryToSwitch(owl, Below);
689 RemoveOwl(owl);
690 InsertOwl(owl, Below);
693 static bool isHiddenBy(OtpWinList *owl, OtpWinList *other_owl)
695 /* doesn't check that owl is on screen */
697 && isIntersectingWith(owl, other_owl));
700 static void TinyRaiseOwl(OtpWinList *owl)
702 OtpWinList *other_owl = owl->above;
704 while((other_owl != NULL) && (PRI(other_owl) == PRI(owl))) {
705 if(isHiddenBy(owl, other_owl)
706 && !shouldStayAbove(other_owl, owl)) {
707 RemoveOwl(owl);
708 RaiseSmallTransientsOfAbove(owl, other_owl);
709 InsertOwlAbove(owl, other_owl);
718 static void TinyLowerOwl(OtpWinList *owl)
720 OtpWinList *other_owl = owl->below;
722 while((other_owl != NULL) && (PRI(other_owl) == PRI(owl))) {
723 if(isHiddenBy(owl, other_owl)) {
724 RemoveOwl(owl);
725 InsertOwlAbove(owl, other_owl->below);
734 static void RaiseLowerOwl(OtpWinList *owl)
748 priority = MAX(PRI(owl), OTP_MAX - PRI(owl));
750 for(other_owl = owl->above;
753 if(isHiddenBy(owl, other_owl)
754 && !shouldStayAbove(other_owl, owl)) {
755 RaiseOwl(owl);
759 LowerOwl(owl);
765 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
766 assert(owl != NULL);
768 RaiseOwl(owl);
779 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
780 assert(owl != NULL);
782 LowerOwl(owl);
793 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
794 assert(owl != NULL);
796 RaiseLowerOwl(owl);
807 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
808 assert(owl != NULL);
810 TinyRaiseOwl(owl);
821 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
822 assert(owl != NULL);
824 TinyLowerOwl(owl);
896 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
900 assert(owl != NULL);
912 TryToMoveTransientsOfTo(owl, priority, where);
913 SetOwlPriority(owl, priority, where);
922 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
923 int priority = owl->pri_base + relpriority;
934 TryToMoveTransientsOfTo(owl, priority, where);
935 SetOwlPriority(owl, priority, where);
943 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
944 int priority = OTP_MAX - owl->pri_base;
947 assert(owl != NULL);
956 TryToMoveTransientsOfTo(owl, priority, where);
957 SetOwlPriority(owl, priority, where);
965 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
966 assert(owl != NULL);
974 owl->switching = !owl->switching;
992 OtpWinList *owl = twm_win->otp;
1005 /* remove the owl to change it */
1006 RemoveOwl(owl);
1012 owl->pri_base = other_owl->pri_base;
1014 /* put the owl back into the list */
1018 InsertOwlAbove(owl, other_owl);
1024 static void ApplyPreferences(OtpPreferences *prefs, OtpWinList *owl)
1027 TwmWindow *twm_win = owl->twm_win;
1031 owl->switching = !prefs->switching;
1038 owl->pri_base = i;
1048 static void RecomputeOwlPrefs(OtpPreferences *prefs, OtpWinList *owl)
1052 old_pri = owl->pri_base;
1053 ApplyPreferences(prefs, owl);
1054 if(old_pri != owl->pri_base) {
1055 RemoveOwl(owl);
1056 InsertOwl(owl, Above);
1062 if(!owl->stashed_aflags) {
1063 OwlStashAflags(owl);
1068 EwmhSet_NET_WM_STATE(owl->twm_win, EWMH_STATE_ABOVE);
1086 static void free_OtpWinList(OtpWinList *owl)
1088 assert(owl->above == NULL);
1089 assert(owl->below == NULL);
1090 free(owl);
1114 OtpWinList *owl = malloc(sizeof(OtpWinList));
1116 owl->above = NULL;
1117 owl->below = NULL;
1118 owl->twm_win = twm_win;
1119 owl->type = wintype;
1120 owl->switching = switching;
1121 owl->pri_base = priority;
1122 owl->pri_aflags = 0;
1129 owl->stashed_aflags = (wintype == WinWin ? false : true);
1131 return owl;
1137 OtpWinList *owl;
1140 /* make the new owl */
1141 owl = new_OtpWinList(twm_win, wintype,
1146 PRI_CP(parent, owl);
1147 owl->switching = parent->switching;
1152 ApplyPreferences(prefs, owl);
1157 if(owl->pri_base == 0) {
1158 owl->pri_base = EwmhGetInitPriority(twm_win) + OTP_ZERO;
1172 aflags = OwlGetStashedAflags(owl, &gotflags);
1206 owl->pri_aflags |= aflags;
1207 owl->stashed_aflags = gotflags;
1210 if((PRI(owl) != OTP_ZERO || owl->pri_aflags != 0)
1211 && !owl->stashed_aflags) {
1212 OwlStashAflags(owl);
1217 InsertOwl(owl, Above);
1219 return owl;
1255 /* make the new owl */
1382 OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp;
1383 OtpWinList *other = owl->below;
1384 assert(owl != NULL);
1387 (unsigned int)WindowOfOwl(owl), wintype));
1388 result = XReparentWindow(display, WindowOfOwl(owl), parent, x, y);
1392 RemoveOwl(owl);
1393 InsertOwlAbove(owl, other);
1439 OtpWinList *owl = Scr->bottomOwl;
1440 while(owl && owl->type != WinWin) {
1441 owl = owl->above;
1443 return owl ? owl->twm_win : NULL;
1448 OtpWinList *owl = Scr->bottomOwl, *top = NULL;
1449 while(owl) {
1450 if(owl->type == WinWin) {
1451 top = owl;
1453 owl = owl->above;
1460 OtpWinList *owl = twm_win->otp->above;
1461 while(owl && owl->type != WinWin) {
1462 owl = owl->above;
1464 return owl ? owl->twm_win : NULL;
1469 OtpWinList *owl = twm_win->otp->below;
1470 while(owl && owl->type != WinWin) {
1471 owl = owl->below;
1473 return owl ? owl->twm_win : NULL;
1489 for(const OtpWinList *owl = start ; owl != NULL ; owl = owl->above) {
1491 OtpEffectivePriority(owl->twm_win),
1492 OtpEffectiveDisplayPriority(owl->twm_win),
1493 (owl->type == WinWin ? "win" : "ico"),
1494 owl->twm_win->w, owl->twm_win->name);
1496 owl->pri_base,
1498 (owl->pri_aflags & OTP_AFLAG_ABOVE ? " _ABOVE" : ""),
1499 (owl->pri_aflags & OTP_AFLAG_BELOW ? " _BELOW" : ""),
1500 (owl->pri_aflags & OTP_AFLAG_FULLSCREEN ? " _FULLSCREEN" : "")
1505 if(owl->twm_win->istransient) {
1506 const TwmWindow *parent = GetTwmWindow(owl->twm_win->transientfor);
1530 OwlSetAflagMask(OtpWinList *owl, unsigned mask, unsigned setto)
1532 assert(owl != NULL);
1534 owl->pri_aflags &= ~mask;
1535 owl->pri_aflags |= (setto & mask);
1536 OwlStashAflags(owl);
1550 OwlSetAflag(OtpWinList *owl, unsigned flag)
1552 assert(owl != NULL);
1554 owl->pri_aflags |= flag;
1555 OwlStashAflags(owl);
1568 OwlClearAflag(OtpWinList *owl, unsigned flag)
1570 assert(owl != NULL);
1572 owl->pri_aflags &= ~flag;
1573 OwlStashAflags(owl);
1593 OwlStashAflags(OtpWinList *owl)
1595 unsigned long of_prop = owl->pri_aflags;
1598 if(owl->type != WinWin) {
1602 XChangeProperty(dpy, owl->twm_win->w, XA_CTWM_OTP_AFLAGS, XA_INTEGER,
1605 owl->stashed_aflags = true;
1609 OwlGetStashedAflags(OtpWinList *owl, bool *gotit)
1619 if(owl->type != WinWin) {
1624 ret = XGetWindowProperty(dpy, owl->twm_win->w, XA_CTWM_OTP_AFLAGS, 0, 1,
1650 OtpWinList *owl = twm_win->otp;
1652 RemoveOwl(owl);
1653 InsertOwl(owl, Above);
1677 OtpWinList *owl = twm_win->otp;
1680 RemoveOwl(owl);
1681 InsertOwl(owl, Above);
1812 OwlEffectivePriority(OtpWinList *owl)
1816 assert(owl != NULL);
1818 pri = owl->pri_base;
1822 if(owl->pri_aflags & OTP_AFLAG_ABOVE) {
1825 if(owl->pri_aflags & OTP_AFLAG_BELOW) {
1835 EwmhWindowType ewt = owl->twm_win->ewmhWindowType;
1836 if((owl->pri_aflags & OTP_AFLAG_BELOW) && (ewt == wt_Dock) &&
1837 (owl->pri_base == EWMH_PRI_DOCK + OTP_ZERO)) {
1849 if(owl->pri_aflags & OTP_AFLAG_FULLSCREEN) {
1850 if(Scr->Focus == owl->twm_win) {
1854 else if(owl->twm_win->istransient) {
1861 TwmWindow *parent = GetTwmWindow(owl->twm_win->transientfor);