JWM Source Documentation
status.c
Go to the documentation of this file.
1 
10 #include "jwm.h"
11 #include "status.h"
12 #include "font.h"
13 #include "screen.h"
14 #include "main.h"
15 #include "client.h"
16 #include "settings.h"
17 #include "hint.h"
18 
19 static Window statusWindow;
20 static unsigned int statusWindowHeight;
21 static unsigned int statusWindowWidth;
23 
24 static void CreateMoveResizeWindow(const ClientNode *np,
25  StatusWindowType type);
26 static void DrawMoveResizeWindow(const ClientNode *np, StatusWindowType type);
27 static void DestroyMoveResizeWindow(void);
28 static void GetMoveResizeCoordinates(const ClientNode *np,
29  StatusWindowType type, int *x, int *y);
30 
33  int *x, int *y)
34 {
35 
36  const ScreenType *sp;
37 
38  if(type == SW_WINDOW) {
39  *x = np->x + (np->width - statusWindowWidth) / 2;
40  *y = np->y + (np->height - statusWindowHeight) / 2;
41  return;
42  }
43 
44  sp = GetCurrentScreen(np->x, np->y);
45 
46  if(type == SW_CORNER) {
47  *x = sp->x;
48  *y = sp->y;
49  return;
50  }
51 
52  /* SW_SCREEN */
53  *x = sp->x + (sp->width - statusWindowWidth) / 2;
54  *y = sp->y + (sp->height - statusWindowHeight) / 2;
55 
56 }
57 
60 {
61 
62  XSetWindowAttributes attrs;
63  long attrMask;
64 
65  if(type == SW_OFF) {
66  return;
67  }
68 
70  statusWindowWidth = GetStringWidth(FONT_MENU, " 00000 x 00000 ") + 2;
71 
73 
74  attrMask = 0;
75 
76  attrMask |= CWBackPixel;
77  attrs.background_pixel = colors[COLOR_MENU_BG];
78 
79  attrMask |= CWSaveUnder;
80  attrs.save_under = True;
81 
82  attrMask |= CWOverrideRedirect;
83  attrs.override_redirect = True;
84 
88  CopyFromParent, InputOutput, CopyFromParent,
89  attrMask, &attrs);
92 
94 
95 }
96 
99 {
100 
101  int x, y;
102 
103  GetMoveResizeCoordinates(np, type, &x, &y);
104  if(x != statusWindowX || y != statusWindowX) {
105  statusWindowX = x;
106  statusWindowY = y;
109  }
110 
111  /* Clear the background. */
113 
114  /* Draw the border. */
118  0, 0, statusWindowWidth, 0);
120  0, 0, 0, statusWindowHeight);
126  } else {
130  }
131 
132 }
133 
136 {
137  if(statusWindow != None) {
139  statusWindow = None;
140  }
141 }
142 
145 {
147 }
148 
151 {
152  char str[80];
153  unsigned int width;
154 
156  return;
157  }
158 
160 
161  snprintf(str, sizeof(str), "(%d, %d)", np->x, np->y);
162  width = GetStringWidth(FONT_MENU, str);
164  (statusWindowWidth - width) / 2, 5, rootWidth, str);
165 }
166 
169 {
171 }
172 
175 {
177 }
178 
180 void UpdateResizeWindow(ClientNode *np, int gwidth, int gheight)
181 {
182 
183  char str[80];
184  unsigned int fontWidth;
185 
187  return;
188  }
189 
191 
192  snprintf(str, sizeof(str), "%d x %d", gwidth, gheight);
193  fontWidth = GetStringWidth(FONT_MENU, str);
195  (statusWindowWidth - fontWidth) / 2, 5, rootWidth, str);
196 
197 }
198 
201 {
203 }

joewing.net / Projects / JWM