22#include "ctwm_atoms.h"
34#define DPRINTF(x) fprintf x
47#define OTP_MAX (OTP_ZERO * 2)
50#define PRI(owl) OwlEffectivePriority(owl)
51#define PRI_CP(from, to) do { \
52 to->pri_base = from->pri_base; \
53 to->pri_aflags = from->pri_aflags; \
97 Icon *icon =
owl->twm_win->icon;
144 &&
OCCUPY(twm_win,
Scr->currentvs->wsw->currentwspc));
155 return ((twm_win->
group == 0)
156 || (twm_win->
group == twm_win->
w));
185 ?
owl->twm_win->icon->w :
owl->twm_win->frame;
231 twm_win =
owl->twm_win;
253 "(%d:'%s' -> %d:'%s')\n",
255 priority,
owl->below->twm_win->name,
271 if(
owl->twm_win->vs) {
279 if(
owl->twm_win->parent_vs) {
297 if(twm_win->winbox) {
302 DPRINTF((
stderr,
"Can't check this window, it is in a WinBox\n"));
321 assert(i >
stack &&
"Window not in good place in stack");
347 for(twm_win =
Scr->FirstWindow; twm_win !=
NULL; twm_win = twm_win->
next) {
360 owl->above->below =
owl->below;
363 owl->below->above =
owl->above;
366 Scr->bottomOwl =
owl->above;
380 while(
owl !=
NULL &&
owl->twm_win->parent_vs != vs) {
418 fprintf(
stderr,
"InsertOwlAbove owl->pri=%d w=0x%x parent_vs:(x,y)=(%d,%d)",
421 owl->twm_win->parent_vs->x,
422 owl->twm_win->parent_vs->y);
424 fprintf(
stderr,
"\n other_owl->pri=%d w=0x%x parent_vs:(x,y)=(%d,%d)",
427 owl->twm_win->parent_vs->x,
428 owl->twm_win->parent_vs->y);
446 owl->above =
Scr->bottomOwl;
475 DPRINTF((
stderr,
"Bottom-most window in VirtualScreen or window box\n"));
543 if(priority <=
PRI(
Scr->bottomOwl)) {
658 if(!
owl->switching) {
674 owl->pri_base = priority;
890 "OtpHandleCirculateNotify: place equals PlaceOnTop nor PlaceOnBottom");
903 if(twm_win->winbox !=
NULL || twm_win->iswinbox) {
927 if(twm_win->winbox !=
NULL || twm_win->iswinbox) {
950 if(twm_win->winbox !=
NULL || twm_win->iswinbox) {
969 if(twm_win->winbox !=
NULL || twm_win->iswinbox) {
974 owl->switching = !
owl->switching;
1031 owl->switching = !
prefs->switching;
1035 for(i = 0; i <=
OTP_MAX; i++) {
1062 if(!
owl->stashed_aflags) {
1118 owl->twm_win = twm_win;
1120 owl->switching = switching;
1121 owl->pri_base = priority;
1122 owl->pri_aflags = 0;
1157 if(
owl->pri_base == 0) {
1211 && !
owl->stashed_aflags) {
1235 else if(twm_win->winbox) {
1293 return &(
prefs->switchingL);
1316 fprintf(
stderr,
"invalid OnTopPriority value: %d\n", priority);
1331 fprintf(
stderr,
"invalid OnTopPriority value: %d\n", priority);
1344 for(i = 0; i <=
OTP_MAX; i++) {
1349 pref->switching =
false;
1359 for(i = 0; i <=
OTP_MAX; i++) {
1401 int icon_x,
int icon_y)
1494 owl->twm_win->w,
owl->twm_win->name);
1505 if(
owl->twm_win->istransient) {
1605 owl->stashed_aflags =
true;
1738 for(
int i = 0 ; i <
tlused ; i++) {
1780 Scr->Focus = twm_win;
1850 if(
Scr->Focus ==
owl->twm_win) {
1854 else if(
owl->twm_win->istransient) {
int main(int argc, char *argv[])
void HandleCirculateNotify(void)
int EwmhGetInitPriority(TwmWindow *twm_win)
void EwmhSet_NET_WM_STATE(TwmWindow *twm_win, int changes)
void EwmhSet_NET_CLIENT_LIST_STACKING(void)
#define EWMH_PRI_FULLSCREEN
#define EWMH_STATE_FULLSCREEN
int frame_x
X position on screen of frame.
int frame_y
Y position on screen of frame.
Window frame
The X window for the overall frame.
unsigned int frame_width
Width of frame.
unsigned int frame_height
Height of frame.
void FreeList(name_list **list)
void * LookInList(name_list *list_head, const char *name, XClassHint *class)
void OtpSetAflag(TwmWindow *twm_win, unsigned flag)
static void TryToSwitch(OtpWinList *owl, int where)
static bool BoxesIntersect(Box *b1, Box *b2)
static bool shouldStayAbove(OtpWinList *owl, OtpWinList *other_owl)
void OtpChangePriority(TwmWindow *twm_win, WinType wintype, int relpriority)
void OtpScrInitData(ScreenInfo *scr)
static void OwlPrettyPrint(const OtpWinList *start)
Pretty-print a whole OWL stack.
TwmWindow * OtpNextWinDown(TwmWindow *twm_win)
static OtpWinList * new_OtpWinList(TwmWindow *twm_win, WinType wintype, bool switching, int priority)
void OtpAdd(TwmWindow *twm_win, WinType wintype)
static int OwlEffectivePriority(OtpWinList *owl)
static void SetOwlPriority(OtpWinList *owl, int new_pri, int where)
static void InsertOwl(OtpWinList *owl, int where)
bool isTransientOf(TwmWindow *trans, TwmWindow *main)
static void free_OtpPreferences(OtpPreferences *pref)
void OtpSetAflagMask(TwmWindow *twm_win, unsigned mask, unsigned setto)
int OtpEffectivePriority(TwmWindow *twm_win)
static void TinyLowerOwl(OtpWinList *owl)
static Box BoxOfOwl(OtpWinList *owl)
static bool isOnScreen(OtpWinList *owl)
void OtpRestackWindow(TwmWindow *twm_win)
void OtpUnfocusWindow(TwmWindow *twm_win)
Unfocus a window.
static void ApplyPreferences(OtpPreferences *prefs, OtpWinList *owl)
static void OwlStashAflags(OtpWinList *owl)
void OtpTinyLower(TwmWindow *twm_win, WinType wintype)
void OtpTinyRaise(TwmWindow *twm_win, WinType wintype)
static void OwlSetAflagMask(OtpWinList *owl, unsigned mask, unsigned setto)
void OtpHandleCirculateNotify(VirtualScreen *vs, TwmWindow *twm_win, WinType wintype, int place)
void OtpStashAflagsFirstTime(TwmWindow *twm_win)
TwmWindow * OtpNextWinUp(TwmWindow *twm_win)
static void RecomputeOwlPrefs(OtpPreferences *prefs, OtpWinList *owl)
void OtpLower(TwmWindow *twm_win, WinType wintype)
bool isSmallTransientOf(TwmWindow *trans, TwmWindow *main)
static OtpWinList * AddNewOwl(TwmWindow *twm_win, WinType wintype, OtpWinList *parent)
name_list ** OtpScrSwitchingL(ScreenInfo *scr, WinType wintype)
void OtpRecomputePrefs(TwmWindow *twm_win)
void OtpClearAflag(TwmWindow *twm_win, unsigned flag)
static void free_OtpWinList(OtpWinList *owl)
static unsigned OwlGetStashedAflags(OtpWinList *owl, bool *gotit)
static bool isIntersectingWith(OtpWinList *owl1, OtpWinList *owl2)
static OtpWinList * OwlRightBelow(int priority)
int OtpEffectiveDisplayPriority(TwmWindow *twm_win)
static void OwlClearAflag(OtpWinList *owl, unsigned flag)
void OtpFocusWindow(TwmWindow *twm_win)
Focus a window.
static void RaiseSmallTransientsOfAbove(OtpWinList *owl, OtpWinList *other_owl)
void OtpScrSetSwitching(ScreenInfo *scr, WinType wintype, bool switching)
static bool OtpCheckConsistencyVS(VirtualScreen *currentvs, Window vroot)
void OtpRemove(TwmWindow *twm_win, WinType wintype)
bool isGroupLeader(TwmWindow *twm_win)
static void OwlSetAflag(OtpWinList *owl, unsigned flag)
static void InsertOwlAbove(OtpWinList *owl, OtpWinList *other_owl)
static Window WindowOfOwl(OtpWinList *owl)
static void TinyRaiseOwl(OtpWinList *owl)
void OtpForcePlacement(TwmWindow *twm_win, int where, TwmWindow *other_win)
static void RemoveOwl(OtpWinList *owl)
bool OtpCheckConsistency(void)
static OtpWinList * GetOwlAtOrBelowInVS(OtpWinList *owl, VirtualScreen *vs)
For the purpose of putting a window above another, they need to have the same parent,...
static void TryToMoveTransientsOfTo(OtpWinList *owl, int priority, int where)
void OtpFreeIcon(TwmWindow *twm_win)
void OtpToggleSwitching(TwmWindow *twm_win, WinType wintype)
static void RaiseOwl(OtpWinList *owl)
static void OtpFocusWindowBE(TwmWindow *twm_win, int oldprio)
Focus/unfocus backend.
static void RaiseLowerOwl(OtpWinList *owl)
void OtpSetPriority(TwmWindow *twm_win, WinType wintype, int new_pri, int where)
void OtpCirculateSubwindows(VirtualScreen *vs, int direction)
void OtpSwitchPriority(TwmWindow *twm_win, WinType wintype)
bool OtpIsFocusDependent(TwmWindow *twm_win)
void OtpScrSetZero(ScreenInfo *scr, WinType wintype, int priority)
static void LowerOwl(OtpWinList *owl)
void OtpReassignIcon(TwmWindow *twm_win, Icon *old_icon)
bool isGroupLeaderOf(TwmWindow *leader, TwmWindow *twm_win)
void ReparentWindowAndIcon(Display *display, TwmWindow *twm_win, Window parent, int win_x, int win_y, int icon_x, int icon_y)
void OtpRaise(TwmWindow *twm_win, WinType wintype)
TwmWindow * OtpBottomWin(void)
static OtpPreferences * new_OtpPreferences(void)
name_list ** OtpScrPriorityL(ScreenInfo *scr, WinType wintype, int priority)
void OtpRaiseLower(TwmWindow *twm_win, WinType wintype)
TwmWindow * OtpTopWin(void)
int ReparentWindow(Display *display, TwmWindow *twm_win, WinType wintype, Window parent, int x, int y)
static bool isHiddenBy(OtpWinList *owl, OtpWinList *other_owl)
name_list * priorityL[(8 *2)+1]
Info and control for each X Screen we control.
struct OtpPreferences * OTP
Stash of various OTP info about the windows on the screen.
struct OtpPreferences * IconOTP
Stash of OTP info about icons on the screen.
Info and control for every X Window we take over.
struct TwmWindow * next
Next TwmWindow on the Screen.
bool iconified
Has the window ever been iconified?
Window w
The actual X Window handle.
bool istransient
This is a transient window.
char * name
Current window name. Points into TwmWindow::names.
struct Icon * icon
The current icon.
int occupation
Workspaces the window is in (bitmap)
struct VirtualScreen * vs
Where the window is currently mapped (may be NULL)
bool mapped
Is the window mapped ?
XClassHint class
Window class info. From XGetClassHint().
struct VirtualScreen * parent_vs
Where the window is parented. Always set.
OtpWinList * otp
OTP control info for stacking. Created in OtpAdd().
Window group
Window group, from WM hints.
struct WindowBox WindowBox
TwmWindow * GetTwmWindow(Window w)