34#include <X11/extensions/shape.h>
41#include "ctwm_atoms.h"
45# include "ewmh_atoms.h"
85static void DealWithNonSensicalGeometries(Display *
dpy, Window vroot,
121 short restore_icon_x, restore_icon_y;
122 bool restore_iconified =
false;
123 bool restore_icon_info_present =
false;
125 bool restoredFromPrevSession =
false;
126 int saved_occupation = 0;
127 bool random_placed =
false;
134 fprintf(stderr,
"AddWindow: w = 0x%x\n", w);
153 if(tmp_win == NULL) {
154 fprintf(stderr,
"%s: Unable to allocate memory to manage window ID %lx.\n",
204 XSelectInput(
dpy, tmp_win->
w, PropertyChangeMask);
205 XGetWindowAttributes(
dpy, tmp_win->
w, &tmp_win->
attr);
234 namelen = strlen(tmp_win->
name);
238 XGetClassHint(
dpy, tmp_win->
w, &tmp_win->
class);
239 if(tmp_win->
class.res_name == NULL) {
242 if(tmp_win->
class.res_class == NULL) {
248 XA_CTWM_WM_ICON_NAME);
251 XA__NET_WM_ICON_NAME);
259#define CHKL(lst) IsInList(Scr->lst, tmp_win)
274 if(
CHKL(IgnoreTransientL)) {
285 short saved_x, saved_y;
286 unsigned short saved_width, saved_height;
287 bool width_ever_changed_by_user;
288 bool height_ever_changed_by_user;
291 &saved_x, &saved_y, &saved_width, &saved_height,
292 &restore_iconified, &restore_icon_info_present,
293 &restore_icon_x, &restore_icon_y,
294 &width_ever_changed_by_user,
295 &height_ever_changed_by_user,
296 &saved_occupation)) {
298 restoredFromPrevSession =
true;
300 tmp_win->
attr.x = saved_x;
301 tmp_win->
attr.y = saved_y;
306 if(width_ever_changed_by_user) {
307 tmp_win->
attr.width = saved_width;
310 if(height_ever_changed_by_user) {
311 tmp_win->
attr.height = saved_height;
324 if(tmp_win->
attr.width >
Scr->MaxWindowWidth) {
325 tmp_win->
attr.width =
Scr->MaxWindowWidth;
327 if(tmp_win->
attr.height >
Scr->MaxWindowHeight) {
328 tmp_win->
attr.height =
Scr->MaxWindowHeight;
340 fprintf(stderr,
"Failed allocating memory for hints!\n");
351 if(restore_iconified) {
352 tmp_win->
wmhints->initial_state = IconicState;
353 tmp_win->
wmhints->flags |= StateHint;
356 if(restore_icon_info_present) {
357 tmp_win->
wmhints->icon_x = restore_icon_x;
358 tmp_win->
wmhints->icon_y = restore_icon_y;
359 tmp_win->
wmhints->flags |= IconPositionHint;
374 ||
CHKL(AlwaysSqueezeToGravityL);
385 Scr->NumAutoRaises++;
390 Scr->NumAutoLowers++;
394 if(
CHKL(OpaqueMoveList)) {
397 else if(
CHKL(NoOpaqueMoveList)) {
402 if(
CHKL(OpaqueResizeList)) {
405 else if(
CHKL(NoOpaqueResizeList)) {
417 bool ibum =
CHKL(IconifyByUn);
423 ibum =
Scr->IconifyByUnmapping;
441 if(!t && tmp_win->
group) {
457 if(
CHKL(WindowRingL) ||
463 && !
CHKL(WindowRingExcludeL))) {
534 else if(
Scr->ClientBorderWidth) {
561 if(
Scr->NoTitlebar) {
564 if(
CHKL(MakeTitle)) {
584 else if(have_title) {
612 if(
CHKL(StartIconified)) {
613 tmp_win->
wmhints->initial_state = IconicState;
614 tmp_win->
wmhints->flags |= StateHint;
622 if(restoredFromPrevSession) {
659 else if(tmp_win->
hints.flags & USPosition) {
662 else if(tmp_win->
hints.flags & PPosition) {
667 && (tmp_win->
attr.x != 0 || tmp_win->
attr.y != 0)) {
735 (
unsigned int *) &tmp_win->
attr.width,
736 (
unsigned int *) &tmp_win->
attr.height);
738 if(mask & XNegative) {
739 tmp_win->
attr.x +=
Scr->rootw - tmp_win->
attr.width;
741 if(mask & YNegative) {
742 tmp_win->
attr.y +=
Scr->rooth - tmp_win->
attr.height;
780 ((tmp_win->
wmhints->initial_state == IconicState) ||
786 "DEBUG[RandomPlacement]: win: %dx%d+%d+%d, screen: %dx%d, title height: %d, random: +%d+%d\n",
787 tmp_win->
attr.width, tmp_win->
attr.height,
796 if(
Scr->RandomDisplacementX >= 0) {
802 if(
Scr->RandomDisplacementY >= 0) {
807 -
Scr->BorderBottom - 5;
814 if(
Scr->RandomDisplacementX >= 0
816 >
Scr->rootw -
Scr->BorderRight - 5)) {
833 if(
Scr->RandomDisplacementY >= 0
835 >
Scr->rooth -
Scr->BorderBottom - 5)) {
846 -
Scr->BorderBottom - 5;
857 if(
Scr->DontMoveOff) {
862 "DEBUG[DontMoveOff]: win: %dx%d+%d+%d, screen: %dx%d, bw2: %d, bw3D: %d\n",
932 "DEBUG[DontMoveOff]: win: %dx%d+%d+%d, screen: %dx%d\n",
1048 FB(
Scr->DefaultC.fore,
Scr->DefaultC.back);
1067 Scr->NormalGC, width,
1079 if(
Scr->OpenWindowTimeout) {
1084 .tv_sec =
Scr->OpenWindowTimeout,
1113 AddingX =
event.xbutton.x_root;
1114 AddingY =
event.xbutton.y_root;
1118 if(
Scr->PackNewWindows) {
1123 if(
Scr->DontMoveOff) {
1137 if(
Scr->PackNewWindows) {
1140 if(
Scr->DontMoveOff) {
1163 Scr->NormalGC, width,
1170#define HALF_AVE_CURSOR_SIZE 8
1177#undef HALF_AVE_CURSOR_SIZE
1186 if(
dx > 0 &&
dy > 0) {
1311 if(!
Scr->ClientBorderWidth) {
1350#define SETC(lst, save) GetColorFromList(Scr->lst, tmp_win->name, \
1351 &tmp_win->class, &tmp_win->save)
1354 tmp_win->borderC.fore =
Scr->BorderColorC.fore;
1355 tmp_win->borderC.back =
Scr->BorderColorC.back;
1356 SETC(BorderColorL, borderC.fore);
1357 SETC(BorderColorL, borderC.back);
1359 tmp_win->border_tile.fore =
Scr->BorderTileC.fore;
1360 tmp_win->border_tile.back =
Scr->BorderTileC.back;
1361 SETC(BorderTileForegroundL, border_tile.fore);
1362 SETC(BorderTileBackgroundL, border_tile.back);
1366 SETC(TitleForegroundL, title.fore);
1367 SETC(TitleBackgroundL, title.back);
1372 if(
Scr->use3Dtitles && !
Scr->BeNiceToColormap) {
1375 if(
Scr->use3Dborders && !
Scr->BeNiceToColormap) {
1415 if(
Scr->FirstWindow !=
NULL) {
1538 if(
Scr->BorderCursors) {
1546 if(
tmp_win->attr.save_under) {
1564 if(
Scr->NameDecorations) {
1599 if(
Scr->NameDecorations) {
1619 if(
Scr->use3Dtitles && (
Scr->Monochrome !=
COLOR)) {
1629 tmp_win->hasfocusvisible =
true;
1777#define SETCTXS(win) do { \
1778 XSaveContext(dpy, win, TwmContext, (XPointer) tmp_win); \
1779 XSaveContext(dpy, win, ScreenContext, (XPointer) Scr); \
1789 int nb =
Scr->TBInfo.nleft +
Scr->TBInfo.nright;
1793 for(i = 0; i <
nb; i++) {
1897#define grabbutton(button, modifier, window, pointer_mode) \
1898 XGrabButton (dpy, button, modifier, window, \
1899 True, ButtonPressMask | ButtonReleaseMask, \
1900 pointer_mode, GrabModeAsync, None, \
1918 for(i = 0 ; i < 8 ; i++) {
1924 if(
Scr->ClickToFocus) {
1926 for(i = 0 ; i < 8 ; i++) {
1930 else if(
Scr->RaiseOnClick) {
1932 for(i = 0 ; i < 8 ; i++) {
1951#define grabkey(funckey, modifier, window) \
1952 XGrabKey(dpy, funckey->keycode, funckey->mods | modifier, window, True, \
1953 GrabModeAsync, GrabModeAsync);
1954#define ungrabkey(funckey, modifier, window) \
1955 XUngrabKey (dpy, funckey->keycode, funckey->mods | modifier, window);
1971#define AltMask (Alt1Mask | Alt2Mask | Alt3Mask | Alt4Mask | Alt5Mask)
1979 for(i = 0 ; i < 8 ; i++) {
1994 for(i = 0 ; i < 8 ; i++) {
2009 for(i = 0 ; i < 8 ; i++) {
2019 for(i = 0 ; i < 8 ; i++) {
2028 for(i = 0 ; i < 8 ; i++) {
2038 for(i = 0 ; i < 8 ; i++) {
2047#ifdef EWMH_DESKTOP_ROOT
2055 for(i = 0 ; i < 8 ; i++) {
2077 for(i = 0 ; i < 8 ; i++) {
2135 for(vs =
myvs->next; vs; vs = vs->
next) {
2139 for(vs =
Scr->vScreenList; vs && vs !=
myvs; vs = vs->
next) {
void GrabButtons(TwmWindow *tmp_win)
#define grabbutton(button, modifier, window, pointer_mode)
void GrabKeys(TwmWindow *tmp_win)
#define ungrabkey(funckey, modifier, window)
#define HALF_AVE_CURSOR_SIZE
#define grabkey(funckey, modifier, window)
TwmWindow * AddWindow(Window w, AWType wtype, IconMgr *iconp, VirtualScreen *vs)
void SetPropsIfCaptiveCtwm(TwmWindow *win)
bool RedirectToCaptive(Window window)
void FetchWmColormapWindows(TwmWindow *tmp)
void UninstallRootColormap(void)
void InstallRootColormap(void)
#define FB(fix_fore, fix_back)
#define ALLOW_DEAD_STORE(x)
int NumScreens
How many Screens are on our display.
void FixRootEvent(XEvent *e)
void EwmhSet_NET_FRAME_EXTENTS(TwmWindow *twm_win)
Set _NET_FRAME_EXTENTS property.
bool EwmhHasBorder(TwmWindow *twm_win)
bool EwmhOnWindowRing(TwmWindow *twm_win)
void EwmhGetProperties(TwmWindow *twm_win)
bool EwmhHasTitle(TwmWindow *twm_win)
#define EWMH_STATE_SHADED
int frame_bw
2d border width.
unsigned int title_height
Height of the full title bar.
unsigned int frame_width
Width of frame.
unsigned int frame_height
Height of frame.
int frame_bw3D
3d border width.
WList * AddIconManager(TwmWindow *tmp_win)
Pixmap mk_blackgray_pixmap(const char *which, Drawable dw, unsigned long fg, unsigned long bg)
void * LookInListWin(name_list *list_head, TwmWindow *twin)
int mwm_has_border(MotifWmHints *hints)
bool mwm_sets_title(MotifWmHints *hints)
bool GetMWMHints(Window w, MotifWmHints *mwmHints)
bool mwm_has_title(MotifWmHints *hints)
void SetupOccupation(TwmWindow *twm_win, int occupation_hint)
void OtpAdd(TwmWindow *twm_win, WinType wintype)
RArea RAreaNew(int x, int y, int width, int height)
Construct an RArea from given components.
void RLayoutFindTopBottomEdges(const RLayout *self, const RArea *area, int *top, int *bottom)
Figure the position (or nearest practical position) of an area in our screen layout,...
int RLayoutFindMonitorRightEdge(const RLayout *self, const RArea *area)
Find the right edge of the left-most monitor that contains the most of a given RArea.
int RLayoutFindMonitorBottomEdge(const RLayout *self, const RArea *area)
Find the bottom edge of the top-most monitor that contains the most of a given RArea.
void RLayoutFindLeftRightEdges(const RLayout *self, const RArea *area, int *left, int *right)
Figure the position (or nearest practical position) of an area in our screen layout,...
#define SIZE_VINDENT
Internal padding in the size window.
#define SIZE_HINDENT
Internal padding in the size window.
int GetWindowConfig(TwmWindow *theWindow, short *x, short *y, unsigned short *width, unsigned short *height, bool *iconified, bool *icon_info_present, short *icon_x, short *icon_y, bool *width_ever_changed_by_user, bool *height_ever_changed_by_user, int *occupation)
A particular extent of space.
The layout of our display.
char * ctwm_wm_icon_name
Icon name from override CTWM_WM_ICON_NAME property.
char * wm_name
Name from ICCCM WM_NAME property.
char * wm_icon_name
Icon name from WM_ICON_NAME property.
char * ctwm_wm_name
Name from override CTWM_WM_NAME property.
bool cursor_valid
Whether curs_x and curs_y are usable.
unsigned int width
Saved width.
Info and control for every X Window we take over.
bool iswspmgr
This is a workspace manager window.
bool OpaqueMove
Move opaquely.
bool titlehighlight
Should I highlight the title bar?
bool isiconmgr
This is an icon manager window.
XWMHints * wmhints
Window manager hints.
bool heightEverChangedByUser
Has TwmWindow::attr height ever changed? Used only in sessions.
bool iconified
Has the window ever been iconified?
bool OpaqueResize
Resize opaquely.
Window w
The actual X Window handle.
bool auto_raise
Should we auto-raise this window ?
bool nameChanged
Has TwmWindow::name ever changed? Used only in session saving.
bool stackmode
Honor stackmode requests.
bool istransient
This is a transient window.
int zoomed
ZOOM_NONE || function causing zoom.
int old_bw
Original window border width before we took it over and made our own bordering.
struct TwmWindow::_ring ring
Window ring connectivity. "
char * name
Current window name. Points into TwmWindow::names.
bool auto_lower
Should we auto-lower this window ?
bool squeeze_info_copied
Should ->squeeze_info be free()'d?
bool widthEverChangedByUser
Has TwmWindow::attr width ever changed? Used only in sessions.
bool AlwaysSqueezeToGravity
SqueezeInfo * squeeze_info
Control info for title squeezing.
struct VirtualScreen * vs
Where the window is currently mapped (may be NULL)
bool icon_on
Is the icon visible.
XClassHint class
Window class info. From XGetClassHint().
XSizeHints hints
Window size hints.
Colormaps cmaps
colormaps for this application
struct IconMgr * iconmgrp
Pointer to the icon manager structure, for windows that are icon managers.
struct VirtualScreen * savevs
Where the window would be.
struct VirtualScreen * parent_vs
Where the window is parented. Always set.
struct TwmWindow::_savegeometry savegeometry
Saved window geometry. "
struct TwmWindow::_names names
Various sources of window/icon names. "
XWindowAttributes attr
Window attributes from XGetWindowAttributes()
Window transientfor
What window it's transient for.
bool UnmapByMovingFarAway
Window group
Window group, from WM hints.
bool iconify_by_unmapping
Unmap window to iconify it.
bool isoccupy
This is an Occupy window.
bool highlight
Should highlight this window.
bool isicon
Is the window an icon now ?
bool squeezed
Is the window squeezed ?
struct VirtualScreen * next
struct WindowBox WindowBox
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
void CreateWindowTitlebarButtons(TwmWindow *tmp_win)
void ComputeTitleLocation(TwmWindow *tmp)
void SetupFrame(TwmWindow *tmp_win, int x, int y, int w, int h, int bw, bool sendEvent)
void SetFocusVisualAttributes(TwmWindow *tmp_win, bool focus)
void MoveOutline(Window root, int x, int y, int width, int height, int bw, int th)
void AutoSqueeze(TwmWindow *tmp_win)
bool PlaceWindowInRegion(TwmWindow *tmp_win, int *final_x, int *final_y)
void ConstrainSize(TwmWindow *tmp_win, unsigned int *widthp, unsigned int *heightp)
void AddEndResize(TwmWindow *tmp_win)
void AddStartResize(TwmWindow *tmp_win, int x, int y, int w, int h)
void DoResize(int x_root, int y_root, TwmWindow *tmp_win)
void savegeometry(TwmWindow *tmp_win)
void UnlinkWindowFromRing(TwmWindow *win)
void AddWindowToRing(TwmWindow *win)
#define InitWindowNotOnRing(win)
void GetWindowSizeHints(TwmWindow *tmp)
bool set_window_name(TwmWindow *win)
[Re]set a window's name.
XWMHints * munge_wmhints(TwmWindow *win, XWMHints *hints)
Perform whatever adaptations of WM_HINTS info we do.
void DisplayPosition(const TwmWindow *_unused_tmp_win, int x, int y)
bool visible(const TwmWindow *tmp_win)
void MoveResizeSizeWindow(int x, int y, unsigned int width, unsigned int height)
TwmWindow * GetTwmWindow(Window w)
void ConstrainByBorders(TwmWindow *twmwin, int *left, int width, int *top, int height)
XWMHints * gen_synthetic_wmhints(TwmWindow *win)
void FetchWmProtocols(TwmWindow *tmp)
void TryToGrid(TwmWindow *tmp_win, int *x, int *y)
void TryToPack(TwmWindow *tmp_win, int *x, int *y)
char * GetWMPropertyString(Window w, Atom prop)
void GetGravityOffsets(TwmWindow *tmp, int *xp, int *yp)
bool set_window_icon_name(TwmWindow *win)
[Re]set a window's icon name.
WindowBox * findWindowBox(TwmWindow *twmwin)
void ConstrainedToWinBox(TwmWindow *twmwin, int x, int y, int *nx, int *ny)
void WMapAddWindow(TwmWindow *win)
int RLayoutXParseGeometry(RLayout *layout, const char *geometry, int *x, int *y, unsigned int *width, unsigned int *height)
Parse an X Geometry out to get the positions and sizes.