CTWM
Loading...
Searching...
No Matches
/usr/src/RPM/BUILD/ctwm-4.1.0/otp.c File Reference
#include "ctwm.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <X11/Xatom.h>
#include "otp.h"
#include "ctwm_atoms.h"
#include "screen.h"
#include "util.h"
#include "icons.h"
#include "list.h"
#include "events.h"
#include "event_handlers.h"
#include "vscreen.h"
#include "win_utils.h"
Include dependency graph for otp.c:

Go to the source code of this file.

Data Structures

struct  OtpWinList
struct  OtpPreferences
struct  Box

Macros

#define DEBUG_OTP   0
#define DPRINTF(x)
#define CHECK_OTP   1
#define OTP_ZERO   8
#define OTP_MAX   (OTP_ZERO * 2)
#define PRI(owl)
#define PRI_CP(from, to)

Typedefs

typedef struct Box Box

Functions

static bool OtpCheckConsistencyVS (VirtualScreen *currentvs, Window vroot)
static void OwlPrettyPrint (const OtpWinList *start)
 Pretty-print a whole OWL stack.
static void OwlSetAflagMask (OtpWinList *owl, unsigned mask, unsigned setto)
static void OwlSetAflag (OtpWinList *owl, unsigned flag)
static void OwlClearAflag (OtpWinList *owl, unsigned flag)
static void OwlStashAflags (OtpWinList *owl)
static unsigned OwlGetStashedAflags (OtpWinList *owl, bool *gotit)
static int OwlEffectivePriority (OtpWinList *owl)
static Box BoxOfOwl (OtpWinList *owl)
static bool BoxesIntersect (Box *b1, Box *b2)
static bool isIntersectingWith (OtpWinList *owl1, OtpWinList *owl2)
static bool isOnScreen (OtpWinList *owl)
bool isTransientOf (TwmWindow *trans, TwmWindow *main)
bool isGroupLeader (TwmWindow *twm_win)
bool isGroupLeaderOf (TwmWindow *leader, TwmWindow *twm_win)
bool isSmallTransientOf (TwmWindow *trans, TwmWindow *main)
static Window WindowOfOwl (OtpWinList *owl)
bool OtpCheckConsistency (void)
static void RemoveOwl (OtpWinList *owl)
static OtpWinListGetOwlAtOrBelowInVS (OtpWinList *owl, VirtualScreen *vs)
 For the purpose of putting a window above another, they need to have the same parent, i.e.
static void InsertOwlAbove (OtpWinList *owl, OtpWinList *other_owl)
static bool shouldStayAbove (OtpWinList *owl, OtpWinList *other_owl)
static void RaiseSmallTransientsOfAbove (OtpWinList *owl, OtpWinList *other_owl)
static OtpWinListOwlRightBelow (int priority)
static void InsertOwl (OtpWinList *owl, int where)
static void SetOwlPriority (OtpWinList *owl, int new_pri, int where)
static void TryToMoveTransientsOfTo (OtpWinList *owl, int priority, int where)
static void TryToSwitch (OtpWinList *owl, int where)
static void RaiseOwl (OtpWinList *owl)
static void LowerOwl (OtpWinList *owl)
static bool isHiddenBy (OtpWinList *owl, OtpWinList *other_owl)
static void TinyRaiseOwl (OtpWinList *owl)
static void TinyLowerOwl (OtpWinList *owl)
static void RaiseLowerOwl (OtpWinList *owl)
void OtpRaise (TwmWindow *twm_win, WinType wintype)
void OtpLower (TwmWindow *twm_win, WinType wintype)
void OtpRaiseLower (TwmWindow *twm_win, WinType wintype)
void OtpTinyRaise (TwmWindow *twm_win, WinType wintype)
void OtpTinyLower (TwmWindow *twm_win, WinType wintype)
void OtpCirculateSubwindows (VirtualScreen *vs, int direction)
void OtpHandleCirculateNotify (VirtualScreen *vs, TwmWindow *twm_win, WinType wintype, int place)
void OtpSetPriority (TwmWindow *twm_win, WinType wintype, int new_pri, int where)
void OtpChangePriority (TwmWindow *twm_win, WinType wintype, int relpriority)
void OtpSwitchPriority (TwmWindow *twm_win, WinType wintype)
void OtpToggleSwitching (TwmWindow *twm_win, WinType wintype)
void OtpForcePlacement (TwmWindow *twm_win, int where, TwmWindow *other_win)
static void ApplyPreferences (OtpPreferences *prefs, OtpWinList *owl)
static void RecomputeOwlPrefs (OtpPreferences *prefs, OtpWinList *owl)
void OtpRecomputePrefs (TwmWindow *twm_win)
static void free_OtpWinList (OtpWinList *owl)
void OtpRemove (TwmWindow *twm_win, WinType wintype)
static OtpWinListnew_OtpWinList (TwmWindow *twm_win, WinType wintype, bool switching, int priority)
static OtpWinListAddNewOwl (TwmWindow *twm_win, WinType wintype, OtpWinList *parent)
void OtpAdd (TwmWindow *twm_win, WinType wintype)
void OtpReassignIcon (TwmWindow *twm_win, Icon *old_icon)
void OtpFreeIcon (TwmWindow *twm_win)
name_list ** OtpScrSwitchingL (ScreenInfo *scr, WinType wintype)
void OtpScrSetSwitching (ScreenInfo *scr, WinType wintype, bool switching)
void OtpScrSetZero (ScreenInfo *scr, WinType wintype, int priority)
name_list ** OtpScrPriorityL (ScreenInfo *scr, WinType wintype, int priority)
static OtpPreferencesnew_OtpPreferences (void)
static void free_OtpPreferences (OtpPreferences *pref)
void OtpScrInitData (ScreenInfo *scr)
int ReparentWindow (Display *display, TwmWindow *twm_win, WinType wintype, Window parent, int x, int y)
void ReparentWindowAndIcon (Display *display, TwmWindow *twm_win, Window parent, int win_x, int win_y, int icon_x, int icon_y)
TwmWindowOtpBottomWin (void)
TwmWindowOtpTopWin (void)
TwmWindowOtpNextWinUp (TwmWindow *twm_win)
TwmWindowOtpNextWinDown (TwmWindow *twm_win)
void OtpSetAflagMask (TwmWindow *twm_win, unsigned mask, unsigned setto)
void OtpSetAflag (TwmWindow *twm_win, unsigned flag)
void OtpClearAflag (TwmWindow *twm_win, unsigned flag)
void OtpStashAflagsFirstTime (TwmWindow *twm_win)
void OtpRestackWindow (TwmWindow *twm_win)
static void OtpFocusWindowBE (TwmWindow *twm_win, int oldprio)
 Focus/unfocus backend.
void OtpUnfocusWindow (TwmWindow *twm_win)
 Unfocus a window.
void OtpFocusWindow (TwmWindow *twm_win)
 Focus a window.
int OtpEffectiveDisplayPriority (TwmWindow *twm_win)
int OtpEffectivePriority (TwmWindow *twm_win)
bool OtpIsFocusDependent (TwmWindow *twm_win)

Macro Definition Documentation

◆ CHECK_OTP

#define CHECK_OTP   1

Definition at line 42 of file otp.c.

◆ DEBUG_OTP

#define DEBUG_OTP   0

Definition at line 32 of file otp.c.

◆ DPRINTF

◆ OTP_MAX

◆ OTP_ZERO

◆ PRI

#define PRI ( owl)

◆ PRI_CP

#define PRI_CP ( from,
to )
Value:
do { \
to->pri_base = from->pri_base; \
to->pri_aflags = from->pri_aflags; \
} while(0)

Definition at line 51 of file otp.c.

Referenced by AddNewOwl(), InsertOwl(), and RaiseSmallTransientsOfAbove().

Typedef Documentation

◆ Box

typedef struct Box Box

Function Documentation

◆ AddNewOwl()

◆ ApplyPreferences()

◆ BoxesIntersect()

bool BoxesIntersect ( Box * b1,
Box * b2 )
static

Definition at line 121 of file otp.c.

References BoxesIntersect(), Box::height, Box::width, Box::x, and Box::y.

Referenced by BoxesIntersect(), and isIntersectingWith().

◆ BoxOfOwl()

◆ free_OtpPreferences()

void free_OtpPreferences ( OtpPreferences * pref)
static

◆ free_OtpWinList()

void free_OtpWinList ( OtpWinList * owl)
static

Definition at line 1086 of file otp.c.

References OtpWinList::above, OtpWinList::below, and free_OtpWinList().

Referenced by free_OtpWinList(), and OtpRemove().

◆ GetOwlAtOrBelowInVS()

OtpWinList * GetOwlAtOrBelowInVS ( OtpWinList * owl,
VirtualScreen * vs )
static

For the purpose of putting a window above another, they need to have the same parent, i.e.

be in the same VirtualScreen.

Definition at line 378 of file otp.c.

References OtpWinList::below, GetOwlAtOrBelowInVS(), TwmWindow::parent_vs, and OtpWinList::twm_win.

Referenced by GetOwlAtOrBelowInVS(), and InsertOwlAbove().

◆ InsertOwl()

◆ InsertOwlAbove()

◆ isGroupLeader()

bool isGroupLeader ( TwmWindow * twm_win)

Definition at line 153 of file otp.c.

References TwmWindow::group, isGroupLeader(), and TwmWindow::w.

Referenced by isGroupLeader(), isGroupLeaderOf(), and OtpAdd().

◆ isGroupLeaderOf()

bool isGroupLeaderOf ( TwmWindow * leader,
TwmWindow * twm_win )

Definition at line 159 of file otp.c.

References TwmWindow::group, isGroupLeader(), and isGroupLeaderOf().

Referenced by isGroupLeaderOf(), and OtpAdd().

◆ isHiddenBy()

bool isHiddenBy ( OtpWinList * owl,
OtpWinList * other_owl )
static

Definition at line 693 of file otp.c.

References isHiddenBy(), isIntersectingWith(), and isOnScreen().

Referenced by isHiddenBy(), RaiseLowerOwl(), TinyLowerOwl(), and TinyRaiseOwl().

◆ isIntersectingWith()

bool isIntersectingWith ( OtpWinList * owl1,
OtpWinList * owl2 )
static

Definition at line 130 of file otp.c.

References BoxesIntersect(), BoxOfOwl(), and isIntersectingWith().

Referenced by isHiddenBy(), and isIntersectingWith().

◆ isOnScreen()

bool isOnScreen ( OtpWinList * owl)
static

◆ isSmallTransientOf()

bool isSmallTransientOf ( TwmWindow * trans,
TwmWindow * main )

◆ isTransientOf()

bool isTransientOf ( TwmWindow * trans,
TwmWindow * main )

◆ LowerOwl()

void LowerOwl ( OtpWinList * owl)
static

Definition at line 686 of file otp.c.

References InsertOwl(), LowerOwl(), RemoveOwl(), and TryToSwitch().

Referenced by LowerOwl(), OtpLower(), and RaiseLowerOwl().

◆ new_OtpPreferences()

◆ new_OtpWinList()

OtpWinList * new_OtpWinList ( TwmWindow * twm_win,
WinType wintype,
bool switching,
int priority )
static

◆ OtpAdd()

◆ OtpBottomWin()

◆ OtpChangePriority()

void OtpChangePriority ( TwmWindow * twm_win,
WinType wintype,
int relpriority )

◆ OtpCheckConsistency()

◆ OtpCheckConsistencyVS()

◆ OtpCirculateSubwindows()

void OtpCirculateSubwindows ( VirtualScreen * vs,
int direction )

◆ OtpClearAflag()

void OtpClearAflag ( TwmWindow * twm_win,
unsigned flag )

Definition at line 1559 of file otp.c.

References TwmWindow::otp, OtpClearAflag(), and OwlClearAflag().

Referenced by OtpClearAflag(), and unzoom().

◆ OtpEffectiveDisplayPriority()

int OtpEffectiveDisplayPriority ( TwmWindow * twm_win)

◆ OtpEffectivePriority()

int OtpEffectivePriority ( TwmWindow * twm_win)

◆ OtpFocusWindow()

void OtpFocusWindow ( TwmWindow * twm_win)

Focus a window.

This needs to know internals of OTP because of focus-dependent stacking of it and its transients.

Definition at line 1774 of file otp.c.

References TwmWindow::otp, OtpFocusWindow(), OtpFocusWindowBE(), PRI, and Scr.

Referenced by HandleFocusIn(), OtpFocusWindow(), and SetFocus().

◆ OtpFocusWindowBE()

void OtpFocusWindowBE ( TwmWindow * twm_win,
int oldprio )
static

Focus/unfocus backend.

This is used on windows whose stacking is focus-dependent (e.g., EWMH fullscreen), to move them and their transients around. For these windows, getting/losing focus is practically the same as a f.setpriority, except it's on the calculated rather than the base parts. And it's hard to re-use our existing functions to do it because we have to move Scr->Focus before the main window changes, but then it's too late to see where all the transients were.

There are a number of unpleasant assumptions in here relating to where the transients are, and IWBNI we could be smarter and quicker about dealing with them. But this gets us past the simple to cause assertion failures, anyway...

Definition at line 1675 of file otp.c.

References OtpWinList::above, InsertOwl(), isTransientOf(), TwmWindow::otp, OtpCheckConsistency(), OtpFocusWindowBE(), RemoveOwl(), Scr, OtpWinList::twm_win, OtpWinList::type, and WinWin.

Referenced by OtpFocusWindow(), OtpFocusWindowBE(), and OtpUnfocusWindow().

◆ OtpForcePlacement()

void OtpForcePlacement ( TwmWindow * twm_win,
int where,
TwmWindow * other_win )

◆ OtpFreeIcon()

void OtpFreeIcon ( TwmWindow * twm_win)

Definition at line 1278 of file otp.c.

References TwmWindow::icon, IconWin, OtpFreeIcon(), and OtpRemove().

Referenced by OtpFreeIcon(), and RedoIcon().

◆ OtpHandleCirculateNotify()

void OtpHandleCirculateNotify ( VirtualScreen * vs,
TwmWindow * twm_win,
WinType wintype,
int place )

Definition at line 877 of file otp.c.

References DPRINTF, OtpHandleCirculateNotify(), OtpLower(), and OtpRaise().

Referenced by HandleCirculateNotify(), and OtpHandleCirculateNotify().

◆ OtpIsFocusDependent()

bool OtpIsFocusDependent ( TwmWindow * twm_win)

◆ OtpLower()

◆ OtpNextWinDown()

TwmWindow * OtpNextWinDown ( TwmWindow * twm_win)

◆ OtpNextWinUp()

◆ OtpRaise()

◆ OtpRaiseLower()

◆ OtpReassignIcon()

void OtpReassignIcon ( TwmWindow * twm_win,
Icon * old_icon )

Definition at line 1262 of file otp.c.

References TwmWindow::icon, IconWin, Icon::otp, OtpAdd(), and OtpReassignIcon().

Referenced by OtpReassignIcon(), and RedoIcon().

◆ OtpRecomputePrefs()

void OtpRecomputePrefs ( TwmWindow * twm_win)

◆ OtpRemove()

void OtpRemove ( TwmWindow * twm_win,
WinType wintype )

◆ OtpRestackWindow()

void OtpRestackWindow ( TwmWindow * twm_win)

◆ OtpScrInitData()

void OtpScrInitData ( ScreenInfo * scr)

◆ OtpScrPriorityL()

name_list ** OtpScrPriorityL ( ScreenInfo * scr,
WinType wintype,
int priority )

◆ OtpScrSetSwitching()

void OtpScrSetSwitching ( ScreenInfo * scr,
WinType wintype,
bool switching )

◆ OtpScrSetZero()

void OtpScrSetZero ( ScreenInfo * scr,
WinType wintype,
int priority )

◆ OtpScrSwitchingL()

name_list ** OtpScrSwitchingL ( ScreenInfo * scr,
WinType wintype )

◆ OtpSetAflag()

void OtpSetAflag ( TwmWindow * twm_win,
unsigned flag )

Definition at line 1541 of file otp.c.

References TwmWindow::otp, OtpSetAflag(), and OwlSetAflag().

Referenced by fullzoom(), and OtpSetAflag().

◆ OtpSetAflagMask()

void OtpSetAflagMask ( TwmWindow * twm_win,
unsigned mask,
unsigned setto )

◆ OtpSetPriority()

void OtpSetPriority ( TwmWindow * twm_win,
WinType wintype,
int new_pri,
int where )

◆ OtpStashAflagsFirstTime()

void OtpStashAflagsFirstTime ( TwmWindow * twm_win)

◆ OtpSwitchPriority()

◆ OtpTinyLower()

void OtpTinyLower ( TwmWindow * twm_win,
WinType wintype )

◆ OtpTinyRaise()

void OtpTinyRaise ( TwmWindow * twm_win,
WinType wintype )

◆ OtpToggleSwitching()

void OtpToggleSwitching ( TwmWindow * twm_win,
WinType wintype )

◆ OtpTopWin()

TwmWindow * OtpTopWin ( void )

Definition at line 1446 of file otp.c.

References OtpWinList::above, OtpTopWin(), Scr, OtpWinList::type, and WinWin.

Referenced by GotoWorkSpace(), and OtpTopWin().

◆ OtpUnfocusWindow()

void OtpUnfocusWindow ( TwmWindow * twm_win)

Unfocus a window.

This needs to know internals of OTP because of focus-dependent stacking of it and its transients.

Definition at line 1753 of file otp.c.

References TwmWindow::otp, OtpFocusWindowBE(), OtpUnfocusWindow(), PRI, and Scr.

Referenced by HandleFocusIn(), HandleFocusOut(), OtpUnfocusWindow(), and SetFocus().

◆ OwlClearAflag()

void OwlClearAflag ( OtpWinList * owl,
unsigned flag )
static

Definition at line 1568 of file otp.c.

References OwlClearAflag(), OwlStashAflags(), and OtpWinList::pri_aflags.

Referenced by OtpClearAflag(), and OwlClearAflag().

◆ OwlEffectivePriority()

◆ OwlGetStashedAflags()

unsigned OwlGetStashedAflags ( OtpWinList * owl,
bool * gotit )
static

Definition at line 1609 of file otp.c.

References dpy, OwlGetStashedAflags(), OtpWinList::twm_win, OtpWinList::type, TwmWindow::w, and WinWin.

Referenced by AddNewOwl(), and OwlGetStashedAflags().

◆ OwlPrettyPrint()

void OwlPrettyPrint ( const OtpWinList * start)
static

Pretty-print a whole OWL stack.

Works upward from the arg; generally, you'd call this with Scr->bottomOwl.

Definition at line 1485 of file otp.c.

References OtpWinList::above, GetTwmWindow(), TwmWindow::istransient, TwmWindow::name, OtpEffectiveDisplayPriority(), OtpEffectivePriority(), OwlPrettyPrint(), OtpWinList::pri_aflags, OtpWinList::pri_base, TwmWindow::transientfor, OtpWinList::twm_win, OtpWinList::type, TwmWindow::w, and WinWin.

Referenced by OtpCheckConsistencyVS(), and OwlPrettyPrint().

◆ OwlRightBelow()

OtpWinList * OwlRightBelow ( int priority)
static

Definition at line 538 of file otp.c.

References OtpWinList::above, OwlRightBelow(), PRI, and Scr.

Referenced by InsertOwl(), OwlRightBelow(), and TryToMoveTransientsOfTo().

◆ OwlSetAflag()

void OwlSetAflag ( OtpWinList * owl,
unsigned flag )
static

Definition at line 1550 of file otp.c.

References OwlSetAflag(), OwlStashAflags(), and OtpWinList::pri_aflags.

Referenced by OtpSetAflag(), and OwlSetAflag().

◆ OwlSetAflagMask()

void OwlSetAflagMask ( OtpWinList * owl,
unsigned mask,
unsigned setto )
static

Definition at line 1530 of file otp.c.

References OwlSetAflagMask(), OwlStashAflags(), and OtpWinList::pri_aflags.

Referenced by OtpSetAflagMask(), and OwlSetAflagMask().

◆ OwlStashAflags()

◆ RaiseLowerOwl()

void RaiseLowerOwl ( OtpWinList * owl)
static

◆ RaiseOwl()

void RaiseOwl ( OtpWinList * owl)
static

Definition at line 678 of file otp.c.

References InsertOwl(), RaiseOwl(), RemoveOwl(), and TryToSwitch().

Referenced by OtpRaise(), RaiseLowerOwl(), and RaiseOwl().

◆ RaiseSmallTransientsOfAbove()

void RaiseSmallTransientsOfAbove ( OtpWinList * owl,
OtpWinList * other_owl )
static

◆ RecomputeOwlPrefs()

◆ RemoveOwl()

◆ ReparentWindow()

int ReparentWindow ( Display * display,
TwmWindow * twm_win,
WinType wintype,
Window parent,
int x,
int y )

◆ ReparentWindowAndIcon()

void ReparentWindowAndIcon ( Display * display,
TwmWindow * twm_win,
Window parent,
int win_x,
int win_y,
int icon_x,
int icon_y )

◆ SetOwlPriority()

void SetOwlPriority ( OtpWinList * owl,
int new_pri,
int where )
static

◆ shouldStayAbove()

bool shouldStayAbove ( OtpWinList * owl,
OtpWinList * other_owl )
static

◆ TinyLowerOwl()

void TinyLowerOwl ( OtpWinList * owl)
static

Definition at line 718 of file otp.c.

References OtpWinList::below, InsertOwlAbove(), isHiddenBy(), PRI, RemoveOwl(), and TinyLowerOwl().

Referenced by OtpTinyLower(), and TinyLowerOwl().

◆ TinyRaiseOwl()

void TinyRaiseOwl ( OtpWinList * owl)
static

◆ TryToMoveTransientsOfTo()

◆ TryToSwitch()

void TryToSwitch ( OtpWinList * owl,
int where )
static

◆ WindowOfOwl()

Window WindowOfOwl ( OtpWinList * owl)
static