31#include <X11/extensions/shape.h>
34#include "ctwm_atoms.h"
99 unsigned int width,
unsigned int height);
204 if(
CLarg.is_captive) {
268 "%s: unable to mark display connection as close-on-exec\n",
275 fprintf(
stderr,
"%s: Can't connect to X server, proceeding anyway...\n",
342 fprintf(
stderr,
"%s: Unable to allocate memory for screen list, exiting.\n",
380 else if(
CLarg.is_captive) {
429 "%s: unable to allocate memory for ScreenInfo structure"
485 Scr->d_visual->bits_per_rgb = 8;
491 Scr->XORvalue = (((
unsigned long) 1) <<
Scr->d_depth) - 1;
496 if(
CLarg.is_captive) {
499 if(
Scr->captivename) {
501 Scr->captivename,
Scr->captivename,
513 Scr->RootColormaps.number_cwins = 1;
525 Scr->cmapInfo.root_pushes = 0;
529 Scr->StdCmapInfo.head =
Scr->StdCmapInfo.tail
531 Scr->StdCmapInfo.mruindex = 0;
552 Scr->MenuShadowColor =
Scr->Black;
553 Scr->IconBorderColor =
Scr->Black;
554 Scr->IconManagerHighlight =
Scr->Black;
556#define SETFB(fld) Scr->fld.fore = Scr->Black; Scr->fld.back = Scr->White;
565 SETFB(workSpaceMgr.windowcp)
566 SETFB(workSpaceMgr.curColors)
567 SETFB(workSpaceMgr.defColors)
667 if(
Scr->ClickToFocus) {
668 Scr->FocusRoot =
false;
669 Scr->TitleFocus =
false;
672 if(
Scr->use3Dborders) {
673 Scr->ClientBorderWidth =
false;
680 Scr->BorderLeft,
Scr->BorderRight,
681 Scr->BorderTop,
Scr->BorderBottom);
682 if(
Scr->BorderedLayout ==
NULL) {
683 Scr->BorderedLayout =
Scr->Layout;
685 else if(
Scr->BorderedLayout->monitors->len == 0) {
687 "Borders too large! correct BorderLeft, BorderRight, BorderTop and/or BorderBottom parameters\n");
721#define SETDEF(fld, num) if(Scr->fld == -100) { Scr->fld = num; }
722 if(
Scr->use3Dtitles) {
738 if(!
Scr->use3Dtitles) {
739 Scr->TitleShadowDepth = 0;
740 Scr->TitleButtonShadowDepth = 0;
742 if(!
Scr->use3Dborders) {
743 Scr->BorderShadowDepth = 0;
745 if(!
Scr->use3Dmenus) {
746 Scr->MenuShadowDepth = 0;
748 if(!
Scr->use3Diconmanagers) {
749 Scr->IconManagerShadowDepth = 0;
751 if(!
Scr->use3Dborders) {
752 Scr->ThreeDBorderWidth = 0;
756 if(!
Scr->BeNiceToColormap) {
761 if(
Scr->use3Dtitles) {
764 if(
Scr->use3Dmenus) {
767 if(
Scr->use3Dmenus) {
770 if(
Scr->use3Dborders) {
777 if(ir->TitleJustification ==
TJ_UNDEF) {
778 ir->TitleJustification =
Scr->IconJustification;
781 ir->Justification =
Scr->IconRegionJustification;
784 ir->Alignement =
Scr->IconRegionAlignement;
792#define DEFCURSOR(name, val) if(!Scr->name) NewFontCursor(&Scr->name, val)
793 DEFCURSOR(FrameCursor,
"top_left_arrow");
794 DEFCURSOR(TitleCursor,
"top_left_arrow");
796 DEFCURSOR(IconMgrCursor,
"top_left_arrow");
804 DEFCURSOR(AlterCursor,
"question_arrow");
817 if(!
Scr->HaveFonts) {
823 Scr->TitleBarFont.y +=
Scr->FramePadding;
824 Scr->TitleHeight =
Scr->TitleBarFont.height +
Scr->FramePadding * 2;
825 if(
Scr->use3Dtitles) {
826 Scr->TitleHeight += 2 *
Scr->TitleShadowDepth;
829 if(!(
Scr->TitleHeight & 1)) {
948 if(
Scr->ShowWorkspaceManager &&
Scr->workSpaceManagerActive) {
950 if(
Scr->WindowMask) {
953 for(vs =
Scr->vScreenList; vs !=
NULL; vs = vs->
next) {
980 Scr->InfoWindow.win =
1010 " 8888 x 8888 ", 13,
1016 if(
Scr->SaveUnder) {
1023 Scr->SizeStringWidth,
1024 (
Scr->SizeFont.height +
1034 Scr->rootw,
Scr->rooth, 0, 0, 0);
1038 if(
Scr->ShowWelcomeWindow) {
1044 Scr->FirstTime =
false;
1058 fprintf(
stderr,
"%s: unable to find any unmanaged screens\n",
1125#define Scr StupidProgrammer
1298 scr->PreferredIconWidth = 48;
1299 scr->PreferredIconHeight = 48;
1301 scr->ewmh_CLIENT_LIST_used = 0;
1302 scr->ewmh_CLIENT_LIST_size = 16;
1303 scr->ewmh_CLIENT_LIST =
calloc(scr->ewmh_CLIENT_LIST_size,
1304 sizeof(scr->ewmh_CLIENT_LIST[0]));
1305 if(scr->ewmh_CLIENT_LIST ==
NULL) {
1332#define DEFAULT_NICE_FONT "-*-helvetica-bold-r-normal-*-*-120-*"
1333#define DEFAULT_FAST_FONT "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*"
1334#define SETFONT(fld, var) (scr->fld##Font.basename = DEFAULT_##var##_FONT)
1343 "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1";
1346#undef DEFAULT_FAST_FONT
1347#undef DEFAULT_NICE_FONT
1372 unsigned int width,
unsigned int height)
1383 wmhints.input =
True;
void StartAnimation(void)
char * AddToCaptiveList(const char *cptname)
void clargs_parse(int argc, char *argv[])
bool InstallColormaps(int type, Colormaps *cmaps)
ColormapWindow * CreateColormapWindow(Window w, bool creating_parent, bool property_window)
void LocateStandardColormaps(void)
bool RestartPreviousState
int NumScreens
How many Screens are on our display.
int ctwm_main(int argc, char *argv[])
Start up ctwm.
bool ctwm_test
Magic flag for tests. Nothing else should touch this!
Atom XCTWMAtom[NUM_CTWM_XATOMS]
Our various common atoms.
static bool cfgerrs
Whether there were config parsing errors.
static bool MappedNotOverride(Window w)
Return true if a window is not set to override_redirect ("Hey! WM! Leave those wins alone!...
#define SETFONT(fld, var)
#define DEFCURSOR(name, val)
ScreenInfo ** ScreenList
List of ScreenInfo structs for each Screen.
ScreenInfo * InitScreenInfo(int scrnum, Window croot, int crootx, int crooty, unsigned int crootw, unsigned int crooth)
Initialize ScreenInfo for a Screen.
int(* ctwm_test_postparse)(void)
Magic callback for tests.
bool takeover_screen(ScreenInfo *scr)
Take over as WM for a screen.
void NewFontCursor(Cursor *cp, const char *str)
void SimulateMapRequest(Window w)
void EwmhInitScreenLate(ScreenInfo *scr)
short DarkShadowContrast
The contrast of the dark shadow.
short ClearShadowContrast
The contrast of the clear shadow.
TitleJust IconJustification
How icon images/titles are aligned.
IcStyle IconifyStyle
How to animate window iconification, if any.
IRJust IconRegionJustification
How icons are laid out horizontally inside a region.
IRAlignement IconRegionAlignement
How icons are laid out vertically inside a region.
int MaxIconTitleWidth
Limit on icon title size. From MaxIconTitleWidth config var.
Window XineramaRoot
Root window holding our vscreens.
Window RealRoot
The actual X root window of the display.
Window Root
Root window for the current vscreen.
Window frame
The X window for the overall frame.
IconMgr * AllocateIconManager(char *name, char *icon_name, char *geom, int columns)
void AllocateOtherIconManagers(void)
void CreateIconManagers(void)
void MaskScreen(char *file)
void CreateOccupyWindow(void)
void OtpScrInitData(ScreenInfo *scr)
bool LoadTwmrc(const char *filename)
Principal entry point from top-level code to parse the config file.
void assign_var_savecolor(void)
void chk_keytable_order(void)
RArea * RAreaNewStatic(int x, int y, int width, int height)
Return a pointer to a static newly constructed RArea.
RAreaList * RAreaListNew(int cap,...)
Create an RAreaList from a set of RArea's.
int RLayoutNumMonitors(const RLayout *self)
How many monitors does a given RLayout contain?
void RLayoutPrint(const RLayout *self)
Pretty-print an RLayout.
RArea RLayoutGetAreaIndex(const RLayout *self, int index)
Return the index'th RArea in an RLayout, or RAreaInvalid() with an out of range index.
RLayout * RLayoutNew(RAreaList *monitors)
Create an RLayout for a given set of monitors.
RLayout * RLayoutCopyCropped(const RLayout *self, int left_margin, int right_margin, int top_margin, int bottom_margin)
Create a copy of an RLayout with given amounts cropped off the sides.
#define SIZE_VINDENT
Internal padding in the size window.
void ReadWinConfigFile(char *filename)
void ConnectToSessionManager(char *previous_id)
void setup_signal_handlers(void)
Setup signal handlers (run during startup)
void sound_load_list(void)
void play_startup_sound(void)
A particular extent of space.
Info and control for each X Screen we control.
bool BackingStore
BackingStore config var.
bool DecorateTransients
DecorateTransients config var.
int TitlePadding
TitlePadding config var. Distance between items in titlebar.
bool NoRaiseMove
NoRaiseOnMove config var.
bool IconManagerDontShow
IconManagerDontShow config var.
bool use3Dmenus
UseThreeDMenus config var.
bool NoWarpToMenuTitle
NoWarpToMenuTitle config var.
bool SloppyFocus
SloppyFocus config var.
bool use3Dtitles
UseThreeDTitles config var.
bool AutoFocusToTransients
AutoFocusToTransients config var.
bool BeNiceToColormap
BeNiceToColormap config var.
unsigned short OpaqueResizeThreshold
OpaqueResizeThreshold config var.
bool AutoRaiseIcons
AutoRaiseIcons config var.
bool NoIconManagers
NoIconManagers config var.
short IconManagerShadowDepth
IconManagerShadowDepth config var.
bool AutoOccupy
AutoOccupy config var.
int TransientOnTop
TransientOnTop config var.
bool NoGrabServer
NoGrabServer config var.
bool IgnoreCaseInMenuSelection
IgnoreCaseInMenuSelection config var.
bool ClickToFocus
ClickToFocus config var.
short MoveDelta
MoveDelta config var. Number of pixels before f.move starts.
int BorderTop
BorderTop config var.
bool use3Dborders
UseThreeDBorders config var.
short MenuShadowDepth
MenuShadowDepth config var.
bool DontWarpCursorInWMap
DontWarpCursorInWMap config var.
bool DontPaintRootWindow
DontPaintRootWindow config var.
int MaxWindowWidth
Largest window width to allow.
bool OpaqueResize
Whether we're in the midst of an opaque resizing.
int NumAutoRaises
Number of autoraise windows on screen.
bool WindowRingAll
WindowRing config var.
bool ForceFocus
ForceFocus config var.
bool InterpolateMenuColors
InterpolateMenuColors config var.
short BorderShadowDepth
BorderShadowDepth config var.
bool NoRaiseDeicon
NoRaiseOnDeiconify config var.
bool FocusRoot
Whether focus is allowed to move.
short RandomDisplacementY
RandomPlacement config var (2nd arg)
short TitleButtonShadowDepth
TitleButtonShadowDepth config var.
int MaxWindowHeight
Largest window height to allow.
WorkSpaceMgr workSpaceMgr
Info about the WorkSpaceManager (and Occupy window) for the screen.
int BorderBottom
BorderBottom config var.
int BorderRight
BorderRight config var.
short RandomDisplacementX
RandomPlacement config var (2nd arg)
short WMgrVertButtonIndent
WMgrVertButtonIndent config var.
int SizeStringOffset
X offset in size window for drawing.
bool use3Diconmanagers
UseThreeDIconManagers config var.
short WMgrButtonShadowDepth
WMgrButtonShadowDepth config var.
int ButtonIndent
ButtonIndent config var. Amount to shrink titlebar buttons.
bool FirstTime
Some sort of attempt to determine whether this is the first config file we've parsed for this screen ...
bool SqueezeTitle
SqueezeTitle and/or DontSqueezeTitle config vars.
bool DoZoom
Whether we're animating [de]iconification zooms.
bool WarpCursor
WarpCursor config var.
int NumAutoLowers
Number of autolower windows on screen.
int IconBorderWidth
IconBorderWidth config var.
bool ForceIcon
ForceIcons config var.
short OpenWindowTimeout
OpenWindowTimeout config var.
bool NoDefaults
NoDefaults config var.
int BorderLeft
BorderLeft config var.
int ThreeDBorderWidth
ThreeDBorderWidth config var.
int MovePackResistance
MovePackResistence config var.
RandPlac RandomPlacement
RandomPlacement config var (1st arg)
int FramePadding
FramePadding config var.
bool WarpUnmapped
WarpUnmapped config var.
int rootx
The x coordinate of the root window relative to RealRoot.
int rooty
The y coordinate of the root window relative to RealRoot.
bool ReallyMoveInWorkspaceManager
ReallyMoveInWorkspaceManager config var.
bool WarpToDefaultMenuEntry
WarpToDefaultMenuEntry config var.
bool RaiseOnClick
RaiseOnClick config var.
UsePPoss UsePPosition
UsePPosition config var.
bool Shadow
NoMenuShadows config var (inverse)
char * PixmapDirectory
PixmapDirectory config var.
bool TransientHasOccupation
TransientHasOccupation config var.
bool UseSunkTitlePixmap
UseSunkTitlePixmap config var.
bool Highlight
NoHighlight config var (inverse).
bool ShrinkIconTitles
ShrinkIconTitles config var.
bool DontMoveOff
DontMoveOff config var.
short ZoomCount
Zoom config var. Number of animated steps in [de]iconifying.
struct ScreenInfo::_TBInfo TBInfo
Various titlebar buttons that will be put in the window decorations for the screen....
int mm_h
Physical mm height of the root.
int rootw
Copy of DisplayWidth(dpy, screen)
int d_depth
Copy of DefaultDepth(dpy, screen)
bool ShowWinWhenMovingInWmgr
AlwaysShowWindowWhenMovingFromWorkspaceManager config var.
bool StackMode
NoStackMode config var (inverse).
bool NoIconTitlebar
NoIconTitle config var.
int screen
Which screen (i.e., the x after the dot in ":0.x")
bool ShowIconManager
ShowIconManager config var.
bool use3Dwmap
UseThreeDWMap config var.
int BorderWidth
BorderWidth config var.
bool AlwaysSqueezeToGravity
AlwaysSqueezeToGravity config var.
bool DoOpaqueMove
OpaqueMove config var.
int rooth
Copy of DisplayHeight(dpy, screen)
TitleJust TitleJustification
How title text is aligned in window titlebars.
unsigned int IgnoreModifier
IgnoreModifier config var.
bool HaveFonts
Whether fonts have been loaded yet in the startup process.
bool BorderCursors
BorderResizeCursors config var.
bool RaiseWhenAutoUnSqueeze
RaiseWhenAutoUnSqueeze config var.
bool ShowWorkspaceManager
ShowWorkSpaceManager config var.
bool SaveWorkspaceFocus
SaveWorkspaceFocus config var.
bool NameDecorations
DontNameDecorations config var (inverse)
bool DontToggleWorkspaceManagerState
DontToggleWorkspaceManagerState config var.
int Monochrome
Is the display monochrome?
bool ShortAllWindowsMenus
ShortAllWindowsMenus config var.
short XMoveGrid
XMoveGrid config var.
bool SaveUnder
NoSaveUnders config var (inverse)
bool PackNewWindows
PackNewWindows config var.
bool RaiseOnWarp
NoRaiseOnWarp config var (inverse)
unsigned short OpaqueMoveThreshold
OpaqueMoveThreshold config var.
int MoveOffResistance
MoveOffResistence config var.
short WMgrHorizButtonIndent
WMgrHorizButtonIndent config var.
short RaiseOnClickButton
RaiseOnClickButton config var.
bool ClientBorderWidth
ClientBorderWidth config var.
bool NoTitlebar
NoTitle config var.
bool WarpRingAnyWhere
WarpRingOnScreen config var (inverse)
bool TitleFocus
NoTitleFocus config var (inverse)
bool SortIconMgr
SortIconManager config var.
short TitleShadowDepth
TitleShadowDepth config var.
bool OpaqueMove
Whether we're doing a window opaque move.
bool TitleHighlight
NoTitleHighlight config var (inverse).
short YMoveGrid
YMoveGrid config var.
bool CaseSensitive
NoCaseSensitive config var (inverse)
bool ReverseCurrentWorkspace
ReverseCurrentWorkspace config var.
bool IconManagerFocus
NoIconManagerFocus config var (inverse)
bool NoRaiseResize
NoRaiseOnResize config var.
bool CenterFeedbackWindow
CenterFeedbackWindow config var.
bool DoOpaqueResize
OpaqueResize config var.
bool SunkFocusWindowTitle
SunkFocusWindowTitle config var.
bool StayUpMenus
StayUpMenus config var.
bool IconifyByUnmapping
IconifyByUnmapping config var.
int mm_w
Physical mm width of the root.
bool mapped
Is the window mapped ?
struct VirtualScreen * next
struct WorkSpaceWindow * wsw
struct OccupyWindow * occupyWindow
void GetColor(int kind, Pixel *what, const char *name)
Get info from the server about a given color.
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
void CreateFonts(ScreenInfo *scr)
Load up our various defined fonts.
void InitVirtualScreens(ScreenInfo *scr)
void InitTitlebarButtons(void)
void Squeeze(TwmWindow *tmp_win)
void SetFocus(TwmWindow *tmp_win, Time tim)
void CreateWindowRegions(void)
void SetMapStateProp(TwmWindow *tmp_win, int state)
void createWindowBoxes(void)
void InitWorkSpaceManagerContext(void)
void CreateWorkSpaceManager(void)
void ConfigureWorkSpaceManager(ScreenInfo *scr)
Prep up structures for WSM windows in each VS.
RLayout * XrandrNewLayout(Display *disp, Window rootw)
Use XRANDR to figure out how our monitors are laid out.