13#include "ctwm_atoms.h"
157 if(!
Scr->workSpaceManagerActive) {
162 Scr->workSpaceMgr.windowFont.basename =
163 "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1";
164 Scr->workSpaceMgr.buttonFont =
Scr->IconManagerFont;
165 Scr->workSpaceMgr.cp =
Scr->IconManagerC;
166 if(!
Scr->BeNiceToColormap) {
202 if(
Scr->workSpaceMgr.curImage ==
NULL) {
203 if(
Scr->workSpaceMgr.curPaint) {
256 unsigned int width, height;
260 const int vspace =
Scr->workSpaceMgr.vspace;
261 const int hspace =
Scr->workSpaceMgr.hspace;
262 const long count =
Scr->workSpaceMgr.count;
275 columns =
Scr->workSpaceMgr.columns;
278 columns = ((count - 1) / lines) + 1;
281 lines = ((count - 1) / columns) + 1;
283 Scr->workSpaceMgr.lines = lines;
284 Scr->workSpaceMgr.columns = columns;
290 unsigned int bwidth, bheight;
293 const char *geometry =
Scr->workSpaceMgr.geometry;
294 const int lines =
Scr->workSpaceMgr.lines;
295 const int columns =
Scr->workSpaceMgr.columns;
303 const MyFont font =
Scr->workSpaceMgr.buttonFont;
317 if(geometry !=
NULL) {
327 bwidth = (width - (columns * hspace)) / columns;
330 bheight = (height - (lines * vspace)) / lines;
334 width = columns * (bwidth + hspace);
335 height = lines * (bheight + vspace);
365 x = (vs->
w - width) / 2;
372 bwidth =
strWid + 2 *
Scr->WMgrButtonShadowDepth + 6;
374 width = columns * (bwidth + hspace);
375 height = lines * (bheight + vspace);
376 x = (vs->
w - width) / 2;
392 Scr->Black,
Scr->workSpaceMgr.cp.back);
405 const unsigned long border =
Scr->workSpaceMgr.defBorderColor;
418 0,
Scr->Black,
ws->cp.back);
422 1, border,
ws->cp.back);
435 if(
ws->image ==
NULL ||
Scr->NoImagesInWorkSpaceManager) {
443 if(
Scr->workSpaceMgr.defImage ==
NULL ||
Scr->NoImagesInWorkSpaceManager) {
464 const int lines =
Scr->workSpaceMgr.lines;
465 const int columns =
Scr->workSpaceMgr.columns;
466 const char *name =
Scr->workSpaceMgr.name;
467 const char *icon_name =
Scr->workSpaceMgr.icon_name;
477 sizehints.min_width = columns * (hspace + 2);
478 sizehints.min_height = lines * (vspace + 2);
482 wmhints.input =
True;
494 fprintf(
stderr,
"cannot create workspace manager window, exiting...\n");
513 attr.cursor =
Scr->ButtonCursor;
596 const int hspace =
Scr->workSpaceMgr.hspace;
597 const int vspace =
Scr->workSpaceMgr.vspace;
598 const int lines =
Scr->workSpaceMgr.lines;
599 const int columns =
Scr->workSpaceMgr.columns;
600 const int bwidth = (
neww - (columns * hspace)) / columns;
601 const int bheight = (
newh - (lines * vspace)) / lines;
602 const int wwidth =
neww / columns;
603 const int wheight =
newh / lines;
629 i * (bwidth + hspace) + (hspace / 2),
630 j * (bheight + vspace) + (vspace / 2),
635 msw->y =
j * wheight;
646 wl->width = (
unsigned int)((
tmp_win->frame_width *
wf) + 0.5);
647 wl->height = (
unsigned int)((
tmp_win->frame_height *
hf) + 0.5);
832 if(!
Scr->DontToggleWorkspaceManagerState) {
852 if(!
Scr->DontToggleWorkspaceManagerState) {
897 for(
int i = 0 ; i <
nkeys ; i++) {
898 unsigned char k =
keys[i];
904 else if((
k == 127) || (
k == 8)) {
963 const Window sw =
event->xbutton.subwindow;
965 const unsigned int button =
event->xbutton.button;
1032 if(
Scr->ReallyMoveInWorkspaceManager) {
1047 if(
Scr->OpaqueMoveThreshold >= 200) {
1052 const unsigned long scrsz = vs->
w * vs->
h;
1053 const float sf =
Scr->OpaqueMoveThreshold / 100.0;
1055 Scr->OpaqueMove =
false;
1058 Scr->OpaqueMove =
true;
1063 Scr->OpaqueMove =
false;
1138 if(
Scr->OpaqueMove) {
1187 event->xbutton.y_root,
1210 switch(
ev.xany.type) {
1213 if(
ev.xexpose.window == w) {
1271 for(
cws =
Scr->workSpaceMgr.workSpaceList ;
1322 if(
Scr->DontMoveOff) {
1327 (
winX >
Scr->BorderLeft -
Scr->MoveOffResistance))) {
1331 if(((
winX + width) > vs->
w -
Scr->BorderRight) &&
1332 ((
Scr->MoveOffResistance < 0) ||
1333 ((
winX + width) < vs->
w -
Scr->BorderRight +
Scr->MoveOffResistance))) {
1334 winX = vs->
w -
Scr->BorderRight - width;
1339 (
winY >
Scr->BorderTop -
Scr->MoveOffResistance))) {
1343 if(((
winY + height) > vs->
h -
Scr->BorderBottom) &&
1344 ((
Scr->MoveOffResistance < 0) ||
1345 ((
winY + height) < vs->
h -
Scr->BorderBottom +
Scr->MoveOffResistance))) {
1346 winY = vs->
h -
Scr->BorderBottom - height;
1364 if(
Scr->ShowWinWhenMovingInWmgr) {
1380 if(
Scr->OpaqueMove) {
1422 if(
Scr->OpaqueMove) {
1438 if(
Scr->OpaqueMove) {
1475 if(!
Scr->OpaqueMove) {
1519 if(!
Scr->DontWarpCursorInWMap) {
1593 occupation |= (1 <<
newws->number);
1594 occupation &= ~(1 <<
oldws->number);
1669 for(vs =
Scr->vScreenList; vs !=
NULL; vs = vs->
next) {
1670 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
1745 for(vs =
Scr->vScreenList; vs !=
NULL; vs = vs->
next) {
1746 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
1781 if(win ==
Scr->workSpaceMgr.occupyWindow->twm_win) {
1791 for(vs =
Scr->vScreenList; vs !=
NULL; vs = vs->
next) {
1803 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
1807 if(win == wl->twm_win) {
1817 wl->width = (
unsigned int)((w *
wf) + 0.5);
1818 wl->height = (
unsigned int)((h *
hf) + 0.5);
1819 if(!
Scr->use3Dwmap) {
1826 if(wl->height < 1) {
1830 wl->width, wl->height);
1856 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
1908 for(
int i =
nchildren - 1; i >= 0; i--) {
1932 (
void *)wl, (
void *)wl->
twm_win);
1979 for(vs =
Scr->vScreenList; vs !=
NULL; vs = vs->
next) {
1980 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
2022 const MyFont font =
Scr->workSpaceMgr.windowFont;
2056 for(i = 0, descent = 0; i <
fnum; i++) {
2058 descent = ((descent < (
xfonts[i]->max_bounds.descent)) ?
2059 (
xfonts[i]->max_bounds.descent) : descent);
2062 y = ((height +
strhei) / 2) - descent;
2066 if(
Scr->use3Dwmap) {
2079 label, strlen(label));
2083 label, strlen(label));
2107 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
2130 if(
Scr->workSpaceMgr.windowcpgiven) {
2131 cp.
back =
Scr->workSpaceMgr.windowcp.back;
2134 cp.
fore =
Scr->workSpaceMgr.windowcp.fore;
2138 if(
Scr->use3Dwmap && !
Scr->BeNiceToColormap) {
2146 const float wf = (
float)(vs->wsw->wwidth - 2) / (
float) vs->
w;
2147 const float hf = (
float)(vs->wsw->wheight - 2) / (
float) vs->h;
2162 if(!
Scr->use3Dwmap) {
2187 if(
Scr->BackingStore) {
2228 for(
ws =
Scr->workSpaceMgr.workSpaceList;
ws !=
NULL;
ws =
ws->next) {
2244 occwin->twm_win->mapped =
false;
2245 occwin->twm_win->occupation = 0;
2263 for(vs =
Scr->vScreenList; vs !=
NULL; vs = vs->
next) {
2268 if(win != wl->twm_win) {
2333 if(win ==
Scr->workSpaceMgr.occupyWindow->twm_win) {
2339 if(
Scr->workSpaceMgr.noshowoccupyall &&
TwmWindow * AddWindow(Window w, AWType wtype, IconMgr *iconp, VirtualScreen *vs)
#define FB(fix_fore, fix_back)
void NewFontCursor(Cursor *cp, const char *str)
void Draw3DBorder(Window w, int x, int y, int width, int height, int bw, ColorPair cp, ButtonState state, bool fill, bool forcebw)
void PaintWsButton(PWBType which, VirtualScreen *vs, Window w, char *label, ColorPair cp, ButtonState state)
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.
unsigned int frame_width
Width of frame.
unsigned int frame_height
Height of frame.
int frame_bw3D
3d border width.
bool GetColorFromList(name_list *list_head, char *name, XClassHint *class, Pixel *ptr)
void ChangeOccupation(TwmWindow *tmp_win, int newoccupation)
int GetPropertyFromMask(unsigned int mask, char **prop)
void ResizeOccupyWindow(TwmWindow *win)
void OtpRaise(TwmWindow *twm_win, WinType wintype)
Info and control for each X Screen we control.
WorkSpaceMgr workSpaceMgr
Info about the WorkSpaceManager (and Occupy window) for the screen.
Info and control for every X Window we take over.
bool iswspmgr
This is a workspace manager window.
bool OpaqueMove
Move opaquely.
bool isiconmgr
This is an icon manager window.
bool istransient
This is a transient window.
char * name
Current window name. Points into TwmWindow::names.
char * icon_name
Current icon name. Points into TwmWindow::names.
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 ?
XClassHint class
Window class info. From XGetClassHint().
ColorPair title
ColorPair for various other titlebar bits.
XWindowAttributes attr
Window attributes from XGetWindowAttributes()
struct VirtualScreen * next
struct WorkSpaceWindow * wsw
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
char * CtwmGetVScreenMap(Display *display, Window rootw)
void Vanish(VirtualScreen *vs, TwmWindow *tmp_win)
void DisplayWin(VirtualScreen *vs, TwmWindow *tmp_win)
void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw)
void MoveOutline(Window root, int x, int y, int width, int height, int bw, int th)
TwmWindow * GetTwmWindow(Window w)
void SetMapStateProp(TwmWindow *tmp_win, int state)
void WarpToWindow(TwmWindow *t, bool must_raise)
void WMapLower(TwmWindow *win)
void WMapRedrawName(VirtualScreen *vs, WinList *wl)
void WMapAddWindowToWorkspace(TwmWindow *win, WorkSpace *ws)
void WMapDeIconify(TwmWindow *win)
void WMapIconify(TwmWindow *win)
void WMgrToggleState(VirtualScreen *vs)
void WMapRemoveWindow(TwmWindow *win)
static void WMapRedrawWindow(Window window, int width, int height, ColorPair cp, const char *label)
static void wmap_mapwin_backend(TwmWindow *win, bool handleraise)
void WMapRestack(WorkSpace *ws)
void WMapSetupWindow(TwmWindow *win, int x, int y, int w, int h)
void InitWorkSpaceManagerContext(void)
void WMapRaiseLower(TwmWindow *win)
void WMgrHandleKeyPressEvent(VirtualScreen *vs, XEvent *event)
static void CreateWorkSpaceManagerWindow(VirtualScreen *vs)
static XContext MapWListContext
void WMapUpdateIconName(TwmWindow *win)
void WMapMapWindow(TwmWindow *win)
void CreateWorkSpaceManager(void)
void WMgrSetButtonsState(VirtualScreen *vs)
bool WMapWindowMayBeAdded(TwmWindow *win)
static void PaintWorkSpaceManagerBorder(VirtualScreen *vs)
void ConfigureWorkSpaceManager(ScreenInfo *scr)
Prep up structures for WSM windows in each VS.
void WMapAddWindow(TwmWindow *win)
void WMapRemoveWindowFromWorkspace(TwmWindow *win, WorkSpace *ws)
void WMgrSetMapState(VirtualScreen *vs)
void WMapRaise(TwmWindow *win)
void PaintWorkSpaceManager(VirtualScreen *vs)
void WMgrHandleExposeEvent(VirtualScreen *vs, XEvent *event)
void WMgrHandleKeyReleaseEvent(VirtualScreen *vs, XEvent *event)
static void InvertColorPair(ColorPair *cp)
static void ResizeWorkSpaceManager(VirtualScreen *vs, TwmWindow *win)
void WMgrHandleButtonEvent(VirtualScreen *vs, XEvent *event)
void GotoWorkSpace(VirtualScreen *vs, WorkSpace *ws)
WorkSpace * GetWorkspace(const char *wname)
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.