diff options
author | fluxgen <fluxgen> | 2002-01-18 01:25:58 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-01-18 01:25:58 (GMT) |
commit | e0f3b3cafff6bb41baa01a5fdfa2a6523af58460 (patch) | |
tree | b1cec94d016864b21d83d14a1e8f5f1ff4927c2e /src | |
parent | f16075f27763005cd9de7a7166f7f56f86910bb4 (diff) | |
download | fluxbox-e0f3b3cafff6bb41baa01a5fdfa2a6523af58460.zip fluxbox-e0f3b3cafff6bb41baa01a5fdfa2a6523af58460.tar.bz2 |
fixed som indentation,throw statement in constructor and variable init
Diffstat (limited to 'src')
-rw-r--r-- | src/Window.cc | 155 |
1 files changed, 82 insertions, 73 deletions
diff --git a/src/Window.cc b/src/Window.cc index 588e7a5..a7997c9 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.19 2002/01/11 17:01:31 fluxgen Exp $ | 25 | // $Id: Window.cc,v 1.20 2002/01/18 01:25:58 fluxgen Exp $ |
26 | 26 | ||
27 | // stupid macros needed to access some functions in version 2 of the GNU C | 27 | // stupid macros needed to access some functions in version 2 of the GNU C |
28 | // library | 28 | // library |
@@ -41,7 +41,6 @@ | |||
41 | #include "Toolbar.hh" | 41 | #include "Toolbar.hh" |
42 | #include "Window.hh" | 42 | #include "Window.hh" |
43 | #include "Windowmenu.hh" | 43 | #include "Windowmenu.hh" |
44 | #include "Workspace.hh" | ||
45 | #include "StringUtil.hh" | 44 | #include "StringUtil.hh" |
46 | 45 | ||
47 | #ifdef SLIT | 46 | #ifdef SLIT |
@@ -65,26 +64,34 @@ | |||
65 | #include <iostream> | 64 | #include <iostream> |
66 | using namespace std; | 65 | using namespace std; |
67 | 66 | ||
68 | FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | 67 | FluxboxWindow::FluxboxWindow(Window w, BScreen *s): |
68 | image_ctrl(0), | ||
69 | moving(false), resizing(false), shaded(false), maximized(false), | ||
70 | visible(false), iconic(false), transient(false), focused(false), | ||
71 | stuck(false), modal(false), send_focus_message(false), managed(false), | ||
72 | screen(0), | ||
73 | timer(0), | ||
74 | display(0), | ||
75 | lastButtonPressTime(0), | ||
76 | windowmenu(0), | ||
77 | tab(0) | ||
78 | { | ||
69 | 79 | ||
70 | #ifdef DEBUG | 80 | #ifdef DEBUG |
71 | fprintf(stderr, | 81 | fprintf(stderr, |
72 | I18n::instance()-> | 82 | I18n::instance()-> |
73 | getMessage( | 83 | getMessage( |
74 | # ifdef NLS | 84 | # ifdef NLS |
75 | WindowSet, WindowCreating, | 85 | WindowSet, WindowCreating, |
76 | # else // !NLS | 86 | # else // !NLS |
77 | 0, 0, | 87 | 0, 0, |
78 | # endif // NLS | 88 | # endif // NLS |
79 | "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), | 89 | "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), |
80 | w); | 90 | w); |
81 | #endif // DEBUG | 91 | #endif // DEBUG |
82 | 92 | ||
83 | Fluxbox *fluxbox = Fluxbox::instance(); | 93 | Fluxbox *fluxbox = Fluxbox::instance(); |
84 | display = fluxbox->getXDisplay(); | 94 | display = fluxbox->getXDisplay(); |
85 | |||
86 | moving = resizing = shaded = maximized = visible = iconic = false; | ||
87 | transient = focused = stuck = modal = send_focus_message = managed = false; | ||
88 | 95 | ||
89 | blackbox_attrib.workspace = workspace_number = window_number = -1; | 96 | blackbox_attrib.workspace = workspace_number = window_number = -1; |
90 | 97 | ||
@@ -94,7 +101,6 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
94 | //use tab as default | 101 | //use tab as default |
95 | decorations.tab = true; | 102 | decorations.tab = true; |
96 | client.window = w; | 103 | client.window = w; |
97 | tab = 0; | ||
98 | frame.window = frame.plate = frame.title = frame.handle = None; | 104 | frame.window = frame.plate = frame.title = frame.handle = None; |
99 | frame.right_grip = frame.left_grip = None; | 105 | frame.right_grip = frame.left_grip = None; |
100 | 106 | ||
@@ -147,37 +153,16 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
147 | client.mwm_hint = (MwmHints *) 0; | 153 | client.mwm_hint = (MwmHints *) 0; |
148 | client.blackbox_hint = 0; | 154 | client.blackbox_hint = 0; |
149 | 155 | ||
150 | windowmenu = 0; | ||
151 | lastButtonPressTime = 0; | ||
152 | timer = 0; | ||
153 | screen = 0; | ||
154 | image_ctrl = 0; | ||
155 | |||
156 | fluxbox->grab(); | 156 | fluxbox->grab(); |
157 | if (! validateClient()) | 157 | if (! validateClient()) |
158 | return; | 158 | return; |
159 | 159 | ||
160 | // fetch client size and placement | 160 | // fetch client size and placement |
161 | XWindowAttributes wattrib; | 161 | XWindowAttributes wattrib; |
162 | if ((! XGetWindowAttributes(display, client.window, &wattrib)) || | 162 | if ((! XGetWindowAttributes(display, client.window, &wattrib)) || |
163 | (! wattrib.screen) || wattrib.override_redirect) { | 163 | (! wattrib.screen) || wattrib.override_redirect) { |
164 | #ifdef DEBUG | ||
165 | fprintf(stderr, | ||
166 | I18n::instance()-> | ||
167 | getMessage( | ||
168 | # ifdef NLS | ||
169 | WindowSet, WindowXGetWindowAttributesFail, | ||
170 | # else // !NLS | ||
171 | 0, 0, | ||
172 | # endif // NLS | ||
173 | "FluxboxWindow::FluxboxWindow(): XGetWindowAttributes " | ||
174 | "failed\n")); | ||
175 | #endif // DEBUG | ||
176 | |||
177 | delete this; | ||
178 | |||
179 | fluxbox->ungrab(); | 164 | fluxbox->ungrab(); |
180 | return; | 165 | throw FluxboxWindow::XGETWINDOWATTRIB; |
181 | } | 166 | } |
182 | 167 | ||
183 | if (s) | 168 | if (s) |
@@ -185,24 +170,9 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
185 | else | 170 | else |
186 | screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen)); | 171 | screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen)); |
187 | 172 | ||
188 | if (! screen) { | 173 | if (!screen) { |
189 | #ifdef DEBUG | 174 | fluxbox->ungrab(); |
190 | fprintf(stderr, | 175 | throw FluxboxWindow::CANTFINDSCREEN; |
191 | I18n::instance()-> | ||
192 | getMessage( | ||
193 | # ifdef NLS | ||
194 | WindowSet, WindowCannotFindScreen, | ||
195 | # else // !NLS | ||
196 | 0, 0, | ||
197 | # endif // NLS | ||
198 | "FluxboxWindow::FluxboxWindow(): can't find screen\n" | ||
199 | " for root window 0x%lx\n"), | ||
200 | RootWindowOfScreen(wattrib.screen)); | ||
201 | #endif // DEBUG | ||
202 | delete this; | ||
203 | |||
204 | fluxbox->ungrab(); | ||
205 | return; | ||
206 | } | 176 | } |
207 | 177 | ||
208 | image_ctrl = screen->getImageControl(); | 178 | image_ctrl = screen->getImageControl(); |
@@ -230,10 +200,8 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
230 | #ifdef SLIT | 200 | #ifdef SLIT |
231 | if (client.initial_state == WithdrawnState) { | 201 | if (client.initial_state == WithdrawnState) { |
232 | screen->getSlit()->addClient(client.window); | 202 | screen->getSlit()->addClient(client.window); |
233 | delete this; | ||
234 | |||
235 | fluxbox->ungrab(); | 203 | fluxbox->ungrab(); |
236 | return; | 204 | throw NOERROR; |
237 | } | 205 | } |
238 | #endif // SLIT | 206 | #endif // SLIT |
239 | 207 | ||
@@ -332,8 +300,8 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
332 | } | 300 | } |
333 | 301 | ||
334 | frame.window = createToplevelWindow(frame.x, frame.y, frame.width, | 302 | frame.window = createToplevelWindow(frame.x, frame.y, frame.width, |
335 | frame.height, | 303 | frame.height, |
336 | screen->getBorderWidth()); //create frame window | 304 | screen->getBorderWidth()); //create frame window |
337 | 305 | ||
338 | fluxbox->saveWindowSearch(frame.window, this); //save frame window | 306 | fluxbox->saveWindowSearch(frame.window, this); //save frame window |
339 | 307 | ||
@@ -364,24 +332,24 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
364 | 332 | ||
365 | 333 | ||
366 | XGrabButton(display, Button1, AnyModifier, | 334 | XGrabButton(display, Button1, AnyModifier, |
367 | frame.plate, True, ButtonPressMask, | 335 | frame.plate, True, ButtonPressMask, |
368 | GrabModeSync, GrabModeSync, None, None); | 336 | GrabModeSync, GrabModeSync, None, None); |
369 | XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, frame.plate); | 337 | XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, frame.plate); |
370 | 338 | ||
371 | 339 | ||
372 | XGrabButton(display, Button1, Mod1Mask, frame.window, True, | 340 | XGrabButton(display, Button1, Mod1Mask, frame.window, True, |
373 | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, | 341 | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, |
374 | GrabModeAsync, None, fluxbox->getMoveCursor()); | 342 | GrabModeAsync, None, fluxbox->getMoveCursor()); |
375 | 343 | ||
376 | //----grab with "all" modifiers | 344 | //----grab with "all" modifiers |
377 | grabButton(display, Button1, frame.window, fluxbox->getMoveCursor()); | 345 | grabButton(display, Button1, frame.window, fluxbox->getMoveCursor()); |
378 | 346 | ||
379 | XGrabButton(display, Button2, Mod1Mask, frame.window, True, | 347 | XGrabButton(display, Button2, Mod1Mask, frame.window, True, |
380 | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); | 348 | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); |
381 | 349 | ||
382 | XGrabButton(display, Button3, Mod1Mask, frame.window, True, | 350 | XGrabButton(display, Button3, Mod1Mask, frame.window, True, |
383 | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, | 351 | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, |
384 | GrabModeAsync, None, fluxbox->getLowerRightAngleCursor()); | 352 | GrabModeAsync, None, fluxbox->getLowerRightAngleCursor()); |
385 | 353 | ||
386 | //---grab with "all" modifiers | 354 | //---grab with "all" modifiers |
387 | grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor()); | 355 | grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor()); |
@@ -429,11 +397,12 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
429 | #ifdef DEBUG | 397 | #ifdef DEBUG |
430 | fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); | 398 | fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); |
431 | #endif | 399 | #endif |
400 | |||
432 | //TODO move this | 401 | //TODO move this |
433 | #ifdef GNOME | 402 | #ifdef GNOME |
434 | int val = workspace_number; | 403 | int val = workspace_number; |
435 | XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom(), XA_CARDINAL, 32, | 404 | XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom(), XA_CARDINAL, 32, |
436 | PropModeReplace, (unsigned char *)&val, 1); | 405 | PropModeReplace, (unsigned char *)&val, 1); |
437 | #endif | 406 | #endif |
438 | 407 | ||
439 | } | 408 | } |
@@ -442,6 +411,9 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s) { | |||
442 | FluxboxWindow::~FluxboxWindow(void) { | 411 | FluxboxWindow::~FluxboxWindow(void) { |
443 | Fluxbox *fluxbox = Fluxbox::instance(); | 412 | Fluxbox *fluxbox = Fluxbox::instance(); |
444 | 413 | ||
414 | //TODO: Move this to Workspace::removeWindow | ||
415 | if (client.transient_for) | ||
416 | fluxbox->setFocusedWindow(client.transient_for); | ||
445 | 417 | ||
446 | if (moving || resizing) { | 418 | if (moving || resizing) { |
447 | screen->hideGeometry(); | 419 | screen->hideGeometry(); |
@@ -527,9 +499,9 @@ FluxboxWindow::~FluxboxWindow(void) { | |||
527 | fluxbox->removeWindowSearch(frame.handle); | 499 | fluxbox->removeWindowSearch(frame.handle); |
528 | fluxbox->removeWindowSearch(frame.right_grip); | 500 | fluxbox->removeWindowSearch(frame.right_grip); |
529 | fluxbox->removeWindowSearch(frame.left_grip); | 501 | fluxbox->removeWindowSearch(frame.left_grip); |
530 | XDestroyWindow(display, frame.right_grip); | ||
531 | XDestroyWindow(display, frame.left_grip); | ||
532 | XDestroyWindow(display, frame.handle); | 502 | XDestroyWindow(display, frame.handle); |
503 | XDestroyWindow(display, frame.right_grip); | ||
504 | XDestroyWindow(display, frame.left_grip); | ||
533 | } | 505 | } |
534 | 506 | ||
535 | if (frame.fbutton) | 507 | if (frame.fbutton) |
@@ -556,14 +528,46 @@ FluxboxWindow::~FluxboxWindow(void) { | |||
556 | fluxbox->removeWindowSearch(client.window); | 528 | fluxbox->removeWindowSearch(client.window); |
557 | screen->removeNetizen(client.window); | 529 | screen->removeNetizen(client.window); |
558 | } | 530 | } |
559 | //TODO: Move this to Workspace::removeWindow | 531 | |
560 | if (client.transient_for) | ||
561 | fluxbox->setFocusedWindow(client.transient_for); | ||
562 | #ifdef DEBUG | 532 | #ifdef DEBUG |
563 | fprintf(stderr, "%s(%d): ~FluxboxWindow(this=%p) done\n", __FILE__, __LINE__, this); | 533 | fprintf(stderr, "%s(%d): ~FluxboxWindow(this=%p) done\n", __FILE__, __LINE__, this); |
564 | #endif | 534 | #endif |
565 | } | 535 | } |
566 | 536 | ||
537 | void FluxboxWindow::showError(FluxboxWindow::Error error) { | ||
538 | |||
539 | #ifdef DEBUG | ||
540 | switch (error) { | ||
541 | case NOERROR: | ||
542 | break; | ||
543 | case XGETWINDOWATTRIB: | ||
544 | fprintf(stderr, | ||
545 | I18n::instance()-> | ||
546 | getMessage( | ||
547 | #ifdef NLS | ||
548 | WindowSet, WindowXGetWindowAttributesFail, | ||
549 | #else // !NLS | ||
550 | 0, 0, | ||
551 | #endif // NLS | ||
552 | "FluxboxWindow::FluxboxWindow(): XGetWindowAttributes " | ||
553 | "failed\n") | ||
554 | ); | ||
555 | break; | ||
556 | case CANTFINDSCREEN: | ||
557 | fprintf(stderr, | ||
558 | I18n::instance()-> | ||
559 | getMessage( | ||
560 | #ifdef NLS | ||
561 | WindowSet, WindowCannotFindScreen, | ||
562 | #else // !NLS | ||
563 | 0, 0, | ||
564 | #endif // NLS | ||
565 | "FluxboxWindow::FluxboxWindow(): can't find screen\n" | ||
566 | " for root window")); | ||
567 | break; | ||
568 | }; | ||
569 | #endif // DEBUG | ||
570 | } | ||
567 | 571 | ||
568 | Window FluxboxWindow::createToplevelWindow(int x, int y, unsigned int width, | 572 | Window FluxboxWindow::createToplevelWindow(int x, int y, unsigned int width, |
569 | unsigned int height, | 573 | unsigned int height, |
@@ -1704,8 +1708,13 @@ void FluxboxWindow::setTab(bool flag) { | |||
1704 | decorations.tab = flag; | 1708 | decorations.tab = flag; |
1705 | } | 1709 | } |
1706 | 1710 | ||
1711 | //------------- iconify ---------------- | ||
1712 | // Unmaps the window and removes it from workspace list | ||
1713 | //-------------------------------------- | ||
1707 | void FluxboxWindow::iconify(void) { | 1714 | void FluxboxWindow::iconify(void) { |
1708 | if (iconic) return; | 1715 | |
1716 | if (iconic) | ||
1717 | return; | ||
1709 | 1718 | ||
1710 | if (windowmenu) | 1719 | if (windowmenu) |
1711 | windowmenu->hide(); | 1720 | windowmenu->hide(); |