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 Box::height, Box::width, Box::x, and Box::y.

Referenced by isIntersectingWith().

◆ BoxOfOwl()

◆ free_OtpPreferences()

void free_OtpPreferences ( OtpPreferences * pref)
static

Definition at line 1354 of file otp.c.

References FreeList(), OTP_MAX, OtpPreferences::priorityL, and OtpPreferences::switchingL.

Referenced by OtpScrInitData().

◆ free_OtpWinList()

void free_OtpWinList ( OtpWinList * owl)
static

Definition at line 1086 of file otp.c.

References OtpWinList::above, and OtpWinList::below.

Referenced by 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, TwmWindow::parent_vs, and OtpWinList::twm_win.

Referenced by InsertOwlAbove().

◆ InsertOwl()

◆ InsertOwlAbove()

◆ isGroupLeader()

bool isGroupLeader ( TwmWindow * twm_win)

Definition at line 153 of file otp.c.

References TwmWindow::group, and TwmWindow::w.

Referenced by isGroupLeaderOf(), and OtpAdd().

◆ isGroupLeaderOf()

bool isGroupLeaderOf ( TwmWindow * leader,
TwmWindow * twm_win )

Definition at line 159 of file otp.c.

References TwmWindow::group, and isGroupLeader().

Referenced by OtpAdd().

◆ isHiddenBy()

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

Definition at line 693 of file otp.c.

References isIntersectingWith(), and isOnScreen().

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

◆ isIntersectingWith()

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

Definition at line 130 of file otp.c.

References BoxesIntersect(), and BoxOfOwl().

Referenced by isHiddenBy().

◆ isOnScreen()

bool isOnScreen ( OtpWinList * owl)
static

Definition at line 139 of file otp.c.

References TwmWindow::iconified, IconWin, TwmWindow::mapped, OCCUPY, Scr, OtpWinList::twm_win, and OtpWinList::type.

Referenced by isHiddenBy().

◆ isSmallTransientOf()

bool isSmallTransientOf ( TwmWindow * trans,
TwmWindow * main )

Definition at line 166 of file otp.c.

References TwmWindow::frame, TwmWindow::frame_height, TwmWindow::frame_width, isTransientOf(), main(), and Scr.

Referenced by shouldStayAbove().

◆ isTransientOf()

bool isTransientOf ( TwmWindow * trans,
TwmWindow * main )

◆ LowerOwl()

void LowerOwl ( OtpWinList * owl)
static

Definition at line 686 of file otp.c.

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

Referenced by OtpLower(), and RaiseLowerOwl().

◆ new_OtpPreferences()

OtpPreferences * new_OtpPreferences ( void )
static

◆ new_OtpWinList()

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

◆ OtpAdd()

◆ OtpBottomWin()

TwmWindow * OtpBottomWin ( void )

◆ OtpChangePriority()

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

◆ OtpCheckConsistency()

◆ OtpCheckConsistencyVS()

◆ OtpCirculateSubwindows()

void OtpCirculateSubwindows ( VirtualScreen * vs,
int direction )

Definition at line 849 of file otp.c.

References DPRINTF, dpy, Event, HandleCirculateNotify(), and VirtualScreen::window.

Referenced by f_circledown_impl(), and f_circleup_impl().

◆ OtpClearAflag()

void OtpClearAflag ( TwmWindow * twm_win,
unsigned flag )

Definition at line 1559 of file otp.c.

References TwmWindow::otp, and OwlClearAflag().

Referenced by unzoom().

◆ OtpEffectiveDisplayPriority()

int OtpEffectiveDisplayPriority ( TwmWindow * twm_win)

Definition at line 1794 of file otp.c.

References TwmWindow::otp, OTP_ZERO, and OwlEffectivePriority().

Referenced by EwmhSet_NET_WM_STATE(), Identify(), and OwlPrettyPrint().

◆ OtpEffectivePriority()

int OtpEffectivePriority ( TwmWindow * twm_win)

Definition at line 1803 of file otp.c.

References TwmWindow::otp, and OwlEffectivePriority().

Referenced by EwmhClientMessage_NET_WM_STATEchange(), and OwlPrettyPrint().

◆ 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, OtpFocusWindowBE(), PRI, and Scr.

Referenced by HandleFocusIn(), 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(), RemoveOwl(), Scr, OtpWinList::twm_win, OtpWinList::type, and WinWin.

Referenced by OtpFocusWindow(), 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, and OtpRemove().

Referenced by RedoIcon().

◆ OtpHandleCirculateNotify()

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

Definition at line 877 of file otp.c.

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

Referenced by HandleCirculateNotify().

◆ OtpIsFocusDependent()

bool OtpIsFocusDependent ( TwmWindow * twm_win)

Definition at line 1883 of file otp.c.

References TwmWindow::otp, and OtpWinList::pri_aflags.

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

◆ OtpLower()

◆ OtpNextWinDown()

TwmWindow * OtpNextWinDown ( TwmWindow * twm_win)

Definition at line 1467 of file otp.c.

References OtpWinList::below, TwmWindow::otp, OtpWinList::twm_win, OtpWinList::type, and WinWin.

Referenced by GotoWorkSpace().

◆ OtpNextWinUp()

◆ OtpRaise()

◆ OtpRaiseLower()

void OtpRaiseLower ( TwmWindow * twm_win,
WinType wintype )

◆ OtpReassignIcon()

void OtpReassignIcon ( TwmWindow * twm_win,
Icon * old_icon )

Definition at line 1262 of file otp.c.

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

Referenced by RedoIcon().

◆ OtpRecomputePrefs()

void OtpRecomputePrefs ( TwmWindow * twm_win)

Definition at line 1073 of file otp.c.

References TwmWindow::icon, Icon::otp, TwmWindow::otp, OtpCheckConsistency(), RecomputeOwlPrefs(), and Scr.

Referenced by apply_window_name().

◆ OtpRemove()

void OtpRemove ( TwmWindow * twm_win,
WinType wintype )

◆ OtpRestackWindow()

void OtpRestackWindow ( TwmWindow * twm_win)

◆ OtpScrInitData()

void OtpScrInitData ( ScreenInfo * scr)

Definition at line 1366 of file otp.c.

References free_OtpPreferences(), ScreenInfo::IconOTP, new_OtpPreferences(), and ScreenInfo::OTP.

Referenced by InitScreenInfo().

◆ OtpScrPriorityL()

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

Definition at line 1324 of file otp.c.

References ABS, ScreenInfo::IconOTP, IconWin, ScreenInfo::OTP, OTP_ZERO, and OtpPreferences::priorityL.

◆ OtpScrSetSwitching()

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

Definition at line 1297 of file otp.c.

References ScreenInfo::IconOTP, IconWin, ScreenInfo::OTP, and OtpPreferences::switching.

◆ OtpScrSetZero()

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

Definition at line 1309 of file otp.c.

References ABS, ScreenInfo::IconOTP, IconWin, ScreenInfo::OTP, OTP_ZERO, and OtpPreferences::priority.

◆ OtpScrSwitchingL()

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

Definition at line 1287 of file otp.c.

References ScreenInfo::IconOTP, IconWin, ScreenInfo::OTP, and OtpPreferences::switchingL.

◆ OtpSetAflag()

void OtpSetAflag ( TwmWindow * twm_win,
unsigned flag )

Definition at line 1541 of file otp.c.

References TwmWindow::otp, and OwlSetAflag().

Referenced by fullzoom().

◆ OtpSetAflagMask()

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

Definition at line 1522 of file otp.c.

References TwmWindow::otp, and OwlSetAflagMask().

Referenced by EwmhClientMessage_NET_WM_STATEchange().

◆ OtpSetPriority()

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

◆ OtpStashAflagsFirstTime()

void OtpStashAflagsFirstTime ( TwmWindow * twm_win)

Definition at line 1585 of file otp.c.

References TwmWindow::otp, OwlStashAflags(), and OtpWinList::stashed_aflags.

Referenced by otp_priority_handler().

◆ OtpSwitchPriority()

void OtpSwitchPriority ( TwmWindow * twm_win,
WinType wintype )

◆ 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, Scr, OtpWinList::type, and WinWin.

Referenced by GotoWorkSpace().

◆ 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(), PRI, and Scr.

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

◆ OwlClearAflag()

void OwlClearAflag ( OtpWinList * owl,
unsigned flag )
static

Definition at line 1568 of file otp.c.

References OwlStashAflags(), and OtpWinList::pri_aflags.

Referenced by OtpClearAflag().

◆ OwlEffectivePriority()

◆ OwlGetStashedAflags()

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

Definition at line 1609 of file otp.c.

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

Referenced by AddNewOwl().

◆ 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(), OtpWinList::pri_aflags, OtpWinList::pri_base, TwmWindow::transientfor, OtpWinList::twm_win, OtpWinList::type, TwmWindow::w, and WinWin.

Referenced by OtpCheckConsistencyVS().

◆ OwlRightBelow()

OtpWinList * OwlRightBelow ( int priority)
static

Definition at line 538 of file otp.c.

References OtpWinList::above, PRI, and Scr.

Referenced by InsertOwl(), and TryToMoveTransientsOfTo().

◆ OwlSetAflag()

void OwlSetAflag ( OtpWinList * owl,
unsigned flag )
static

Definition at line 1550 of file otp.c.

References OwlStashAflags(), and OtpWinList::pri_aflags.

Referenced by OtpSetAflag().

◆ OwlSetAflagMask()

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

Definition at line 1530 of file otp.c.

References OwlStashAflags(), and OtpWinList::pri_aflags.

Referenced by OtpSetAflagMask().

◆ OwlStashAflags()

◆ RaiseLowerOwl()

void RaiseLowerOwl ( OtpWinList * owl)
static

Definition at line 734 of file otp.c.

References OtpWinList::above, isHiddenBy(), LowerOwl(), MAX, OTP_MAX, PRI, RaiseOwl(), and shouldStayAbove().

Referenced by OtpRaiseLower().

◆ RaiseOwl()

void RaiseOwl ( OtpWinList * owl)
static

Definition at line 678 of file otp.c.

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

Referenced by OtpRaise(), and RaiseLowerOwl().

◆ RaiseSmallTransientsOfAbove()

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

Definition at line 517 of file otp.c.

References OtpWinList::below, InsertOwlAbove(), PRI_CP, RemoveOwl(), shouldStayAbove(), OtpWinList::type, and WinWin.

Referenced by InsertOwl(), and TinyRaiseOwl().

◆ 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, and RemoveOwl().

Referenced by OtpTinyLower().

◆ TinyRaiseOwl()

void TinyRaiseOwl ( OtpWinList * owl)
static

◆ TryToMoveTransientsOfTo()

void TryToMoveTransientsOfTo ( OtpWinList * owl,
int priority,
int where )
static

◆ TryToSwitch()

void TryToSwitch ( OtpWinList * owl,
int where )
static

Definition at line 654 of file otp.c.

References OTP_MAX, OtpWinList::pri_base, OtpWinList::switching, and TryToMoveTransientsOfTo().

Referenced by LowerOwl(), and RaiseOwl().

◆ WindowOfOwl()

Window WindowOfOwl ( OtpWinList * owl)
static