35#include <X11/extensions/shape.h>
37#include "ctwm_atoms.h"
39#include "ewmh_atoms.h"
43#include "functions_defs.h"
63#define NET_WM_STATE_REMOVE 0
64#define NET_WM_STATE_ADD 1
65#define NET_WM_STATE_TOGGLE 2
67#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
68#define _NET_WM_MOVERESIZE_SIZE_TOP 1
69#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
70#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
71#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
72#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
73#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
74#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
75#define _NET_WM_MOVERESIZE_MOVE 8
76#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
77#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
78#define _NET_WM_MOVERESIZE_CANCEL 11
96#define ALL_WORKSPACES 0xFFFFFFFFU
107 e.xclient.display =
dpy;
109 e.xclient.format = 32;
110 e.xclient.data.l[0] =
l0;
111 e.xclient.data.l[1] =
l1;
112 e.xclient.data.l[2] =
l2;
113 e.xclient.data.l[3] =
l3;
114 e.xclient.data.l[4] =
l4;
153 tosleep.tv_nsec = (10 * 1000 * 1000);
174 fprintf(
stderr,
"GenerateTimestamp: time = %ld, timeout left = %d\n",
234 fprintf(
stderr,
"A window manager is already running on screen %d\n",
244 fprintf(
stderr,
"Did not get window manager selection on screen %d\n",
261 tosleep.tv_nsec = (100 * 1000 * 1000);
274 fprintf(
stderr,
"Timed out waiting for other window manager "
275 "on screen %d to quit\n",
327 fprintf(
stderr,
"EwmhInitScreenEarly: call EwmhReplaceWM\n");
331 scr->icccm_Window =
None;
354 data[0] = scr->icccm_Window;
358 (
unsigned char *)
data, 1);
367 (
unsigned char *)
"ctwm", 4);
369 data[0] = scr->icccm_Window;
373 (
unsigned char *)
data, 1);
383 (
unsigned char *)
data, 2);
390 (
unsigned char *)
data, 2);
404 (
unsigned char *)
data, 1);
417 (
unsigned char *)
data, 1);
489 vs = vs->
next, i++) {
506 (
unsigned char *)&
d0, 1);
563 if(
msg->format != 32) {
590 if(
msg->window !=
Scr->XineramaRoot &&
591 msg->window !=
Scr->Root) {
593 fprintf(
stderr,
"Received unrecognized client message: %s\n",
609 fprintf(
stderr,
"Received unrecognized client message about root window: %s\n",
690 const int area = w * h;
802 fprintf(
stderr,
"offset + 2 + area = %d fetch_offset + nitems = %ld\n",
826 assert(width * height == area);
840 int r = (
argb >> 16) & 0xFF;
841 int g = (
argb >> 8) & 0xFF;
842 int b = (
argb >> 0) & 0xFF;
908 for(
y = 0;
y < height;
y++) {
909 for(
x = 0;
x < width;
x++) {
931 width, height, 1, 0, 1);
936 image->
width = width;
1030# define CRWARN(x) fprintf(stderr, "atomToFlag: ignoring " #x "\n")
1032# define CRWARN(x) (void)0
1034#define CHKNRET(st) \
1035 if(a == XA__NET_WM_##st) { \
1036 if(LookInNameList(Scr->EWMHIgnore, #st)) { \
1074 if(twm_win ==
NULL) {
1090 switch(
msg->data.l[0]) {
1093 printf(
"NET_WM_STATE_REMOVE: ");
1099 printf(
"NET_WM_STATE_ADD: ");
1105 printf(
"NET_WM_STATE_TOGGLE: ");
1111 printf(
"invalid operation in NET_WM_STATE: %ld\n",
msg->data.l[0]);
1180 printf(
"EWMH_STATE_SHADED: change it\n");
1195#define DOBIT(fld) do { \
1196 if(change & EWMH_STATE_##fld) { omask |= OTP_AFLAG_##fld; } \
1197 if(newValue & EWMH_STATE_##fld) { oval |= OTP_AFLAG_##fld; } \
1234 if(twm_win ==
NULL) {
1250 if(
Scr->RaiseOnWarp) {
1275 if(twm_win ==
NULL) {
1283 switch(
msg->data.l[2]) {
1447 if(twm_win->
names.net_wm_icon_name !=
NULL
1492 if(!
Scr->workSpaceManagerActive) {
1512 int wsn =
ws->number;
1515 occupation &= ~(1 <<
wsn);
1521 if(occupation != 0) {
1526 if(occupation & mask) {
1546 unsigned long *
prop;
1547 unsigned long value;
1583 unsigned long *
prop;
1586 0, 8192,
False, type,
1605 unsigned long *
prop;
1615 for(i = 0; i <
nitems; i++) {
1621 occupation |= 1 <<
val;
1624 occupation |= 1 << (
Scr->workSpaceMgr.count - 1);
1658 if(twm_win ==
NULL) {
1665 if((vs = twm_win->
vs) !=
NULL) {
1676 occupation |= 1 <<
val;
1679 occupation |= 1 << (
Scr->workSpaceMgr.count - 1);
1703 if(
Scr->ewmh_CLIENT_LIST_size == 0) {
1709 Scr->ewmh_CLIENT_LIST_used++;
1710 if(
Scr->ewmh_CLIENT_LIST_used >
Scr->ewmh_CLIENT_LIST_size) {
1712 int tsz =
Scr->ewmh_CLIENT_LIST_size;
1714 Scr->ewmh_CLIENT_LIST_size *= 2;
1716 sizeof(
long) *
Scr->ewmh_CLIENT_LIST_size);
1718 Scr->ewmh_CLIENT_LIST_size =
tsz;
1719 fprintf(
stderr,
"Unable to allocate memory for EWMH client list.\n");
1722 Scr->ewmh_CLIENT_LIST =
tp;
1724 if(
Scr->ewmh_CLIENT_LIST) {
1725 Scr->ewmh_CLIENT_LIST[
Scr->ewmh_CLIENT_LIST_used - 1] =
new_win->w;
1728 Scr->ewmh_CLIENT_LIST_size = 0;
1729 fprintf(
stderr,
"Unable to allocate memory for EWMH client list.\n");
1734 Scr->ewmh_CLIENT_LIST_used);
1749 if(
Scr->ewmh_CLIENT_LIST_size == 0) {
1752 for(i =
Scr->ewmh_CLIENT_LIST_used - 1; i >= 0; i--) {
1755 &
Scr->ewmh_CLIENT_LIST[i + 1],
1756 (
Scr->ewmh_CLIENT_LIST_used - 1 - i) *
sizeof(
Scr->ewmh_CLIENT_LIST[0]));
1757 Scr->ewmh_CLIENT_LIST_used--;
1758 if(
Scr->ewmh_CLIENT_LIST_used &&
1759 (
Scr->ewmh_CLIENT_LIST_used * 3) <
Scr->ewmh_CLIENT_LIST_size) {
1760 Scr->ewmh_CLIENT_LIST_size /= 2;
1762 sizeof((
Scr->ewmh_CLIENT_LIST[0])) *
Scr->ewmh_CLIENT_LIST_size);
1772 Scr->ewmh_CLIENT_LIST_used);
1785 unsigned long *
prop;
1790 size =
Scr->ewmh_CLIENT_LIST_used + 10;
1803 prop[i] = twm_win->
w;
1812 if(i !=
Scr->ewmh_CLIENT_LIST_used) {
1813 fprintf(
stderr,
"Incorrect number of stacked windows: %d (expected %d)\n",
1814 i,
Scr->ewmh_CLIENT_LIST_used);
1825 unsigned long prop[1];
1844 twm_win->ewmhFlags = 0;
1852 twm_win->ewmhWindowType =
wt_Dock;
1866 switch(twm_win->ewmhWindowType) {
1878 switch(twm_win->ewmhWindowType) {
1889 switch(twm_win->ewmhWindowType) {
1900 switch(twm_win->ewmhWindowType) {
1927 bottom =
max(bottom,
strut->bottom);
1932 Scr->BorderLeft = left;
1933 Scr->BorderRight = right;
1934 Scr->BorderTop = top;
1935 Scr->BorderBottom = bottom;
1939 left, right, top, bottom);
1940 if(
Scr->BorderedLayout ==
NULL) {
1941 Scr->BorderedLayout =
Scr->Layout;
1960 unsigned long *
prop;
1984 printf(
"struts: left %ld, right %ld, top %ld, bottom %ld\n",
1998 Scr->BorderBottom) != 0) {
2027 if(
strut->win == twm_win) {
2048 strut->win = twm_win;
2075 if(
strut->win == twm_win) {
2112 (
unsigned char *)
data, 4);
2118 unsigned long prop[1];
2139 unsigned long prop[10];
2146 switch(twm_win->
zoomed) {
2206 flags = twm_win->ewmhFlags;
2240 unsigned long *
prop;
2247 for(i = 0; i <
nitems; i++) {
2262 unsigned long prop[4];
#define ALLOW_DEAD_STORE(x)
int NumScreens
How many Screens are on our display.
ScreenInfo ** ScreenList
List of ScreenInfo structs for each Screen.
void DoShutdown(void)
Cleanup and exit ctwm.
void AutoRaiseWindow(TwmWindow *tmp)
static void EwmhRemoveStrut(TwmWindow *twm_win)
#define _NET_WM_MOVERESIZE_SIZE_TOP
void EwmhInitScreenLate(ScreenInfo *scr)
void EwmhUnmapNotify(TwmWindow *twm_win)
static Image * ExtractIcon(ScreenInfo *scr, unsigned long *prop, int width, int height)
static int EwmhGet_NET_WM_STATE(TwmWindow *twm_win)
int EwmhGetInitPriority(TwmWindow *twm_win)
static void EwmhSet_NET_WORKAREA(ScreenInfo *scr)
void EwmhSet_NET_WM_DESKTOP_ws(TwmWindow *twm_win, WorkSpace *ws)
void EwmhSet_NET_FRAME_EXTENTS(TwmWindow *twm_win)
Set _NET_FRAME_EXTENTS property.
static void convert_for_32(int w, int x, int y, int argb)
static void EwmhGetStrut(TwmWindow *twm_win, bool update)
bool EwmhClientMessage(XClientMessageEvent *msg)
static unsigned long * EwmhGetWindowProperties(Window w, Atom name, Atom type, unsigned long *nitems_return)
static void EwmhTerminateScreen(ScreenInfo *scr)
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT
Atom XEWMHAtom[NUM_EWMH_XATOMS]
static uint16_t * buffer_16bpp
static void EwmhClientMessage_NET_ACTIVE_WINDOW(XClientMessageEvent *msg)
static void EwmhClientMessage_NET_WM_DESKTOP(XClientMessageEvent *msg)
#define NET_WM_STATE_REMOVE
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT
void EwmhSelectionClear(XSelectionClearEvent *sev)
int EwmhHandlePropertyNotify(XPropertyEvent *event, TwmWindow *twm_win)
void EwmhSet_NET_SHOWING_DESKTOP(int state)
#define _NET_WM_MOVERESIZE_SIZE_LEFT
static void EwmhClientMessage_NET_WM_STATE(XClientMessageEvent *msg)
static void EwmhClientMessage_NET_WM_MOVERESIZE(XClientMessageEvent *msg)
bool EwmhInitScreenEarly(ScreenInfo *scr)
void EwmhAddClientWindow(TwmWindow *new_win)
static int atomToFlag(Atom a)
bool EwmhHasBorder(TwmWindow *twm_win)
static void GenerateTimestamp(ScreenInfo *scr)
bool EwmhOnWindowRing(TwmWindow *twm_win)
static bool EwmhReplaceWM(ScreenInfo *scr)
static int CatchError(Display *display, XErrorEvent *event)
static void EwmhInitAtoms(void)
void EwmhSet_NET_WM_DESKTOP(TwmWindow *twm_win)
#define _NET_WM_MOVERESIZE_CANCEL
static void EwmhRecalculateStrut(void)
void EwmhDeleteClientWindow(TwmWindow *old_win)
void EwmhGetProperties(TwmWindow *twm_win)
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD
void EwmhSet_NET_ACTIVE_WINDOW(Window w)
static void EwmhHandle_NET_WM_STRUTNotify(XPropertyEvent *event, TwmWindow *twm_win)
static void SendPropertyMessage(Window to, Window about, Atom messagetype, long l0, long l1, long l2, long l3, long l4, long mask)
bool EwmhHasTitle(TwmWindow *twm_win)
static XEvent synth_btnevent_for_moveresize(TwmWindow *twm_win)
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD
static void EwmhClientMessage_NET_WM_STATEchange(TwmWindow *twm_win, int change, int newVal)
static void EwmhClientMessage_NET_CLOSE_WINDOW(XClientMessageEvent *msg)
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT
static unsigned long EwmhGetWindowProperty(Window w, Atom name, Atom type)
#define NET_WM_STATE_TOGGLE
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM
void EwmhSet_NET_WM_STATE(TwmWindow *twm_win, int changes)
Image * EwmhGetIcon(ScreenInfo *scr, TwmWindow *twm_win)
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT
void EwmhSet_NET_CLIENT_LIST_STACKING(void)
static uint32_t * buffer_32bpp
#define _NET_WM_MOVERESIZE_MOVE
static void EwmhHandle_NET_WM_ICONNotify(XPropertyEvent *event, TwmWindow *twm_win)
int EwmhGetOccupation(TwmWindow *twm_win)
#define _NET_WM_MOVERESIZE_SIZE_RIGHT
static void convert_for_16(int w, int x, int y, int argb)
#define EWMH_STATE_MAXIMIZED_VERT
#define EWMH_STATE_MAXIMIZED_HORZ
#define EWMH_STATE_SHADED
#define EWMH_STATE_FULLSCREEN
void ExecuteFunction(int func, void *action, Window w, TwmWindow *tmp_win, XEvent *eventp, int context, bool pulldown)
Window XineramaRoot
Root window holding our vscreens.
Window Root
Root window for the current vscreen.
VirtualScreen * vScreenList
Linked list of per-VS info.
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.
int frame_bw
2d border width.
unsigned int title_height
Height of the full title bar.
int frame_bw3D
3d border width.
void RedoIconName(TwmWindow *win)
int GetIconOffset(Icon *icon)
void FreeImage(Image *image)
void ChangeOccupation(TwmWindow *tmp_win, int newoccupation)
void OtpSetAflagMask(TwmWindow *twm_win, unsigned mask, unsigned setto)
int OtpEffectivePriority(TwmWindow *twm_win)
void OtpRestackWindow(TwmWindow *twm_win)
TwmWindow * OtpNextWinUp(TwmWindow *twm_win)
int OtpEffectiveDisplayPriority(TwmWindow *twm_win)
TwmWindow * OtpBottomWin(void)
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.
Info and control for each X Screen we control.
int BorderTop
BorderTop config var.
WorkSpaceMgr workSpaceMgr
Info about the WorkSpaceManager (and Occupy window) for the screen.
int BorderBottom
BorderBottom config var.
int BorderRight
BorderRight config var.
bool workSpaceManagerActive
Whether the WSM is being shown.
int BorderLeft
BorderLeft config var.
int rootw
Copy of DisplayWidth(dpy, screen)
int d_depth
Copy of DefaultDepth(dpy, screen)
int screen
Which screen (i.e., the x after the dot in ":0.x")
int rooth
Copy of DisplayHeight(dpy, screen)
Info and control for every X Window we take over.
bool iswspmgr
This is a workspace manager window.
bool isiconmgr
This is an icon manager window.
Window w
The actual X Window handle.
int zoomed
ZOOM_NONE || function causing zoom.
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 ?
struct WList * iconmanagerlist
List of the icon managers the window is in.
struct VirtualScreen * parent_vs
Where the window is parented. Always set.
struct TwmWindow::_names names
Various sources of window/icon names. "
bool squeezed
Is the window squeezed ?
struct VirtualScreen * next
struct WorkSpaceWindow * wsw
static int max(int a, int b)
void DeIconify(TwmWindow *tmp_win)
void Squeeze(TwmWindow *tmp_win)
void SetFocus(TwmWindow *tmp_win, Time tim)
void fullzoom(TwmWindow *tmp_win, int func)
void apply_window_icon_name(TwmWindow *win)
[Re]set and apply changes to a window's icon name.
void FreeWMPropertyString(char *prop)
TwmWindow * GetTwmWindow(Window w)
void WarpToWindow(TwmWindow *t, bool must_raise)
void apply_window_name(TwmWindow *win)
[Re]set and apply changes to a window's name.
char * GetWMPropertyString(Window w, Atom prop)
void GotoWorkSpaceByNumber(VirtualScreen *vs, int workspacenum)
void ShowBackground(VirtualScreen *vs, int newstate)