aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-01-20 02:14:20 (GMT)
committerfluxgen <fluxgen>2002-01-20 02:14:20 (GMT)
commite1b1f375c6621ab5e51673216522526ad41b29fc (patch)
tree11ddfebb27c318c3a62d7f13b178c7234437f891 /src
parentd462b97960c60c909c4af2077506520f7095a628 (diff)
downloadfluxbox_pavel-e1b1f375c6621ab5e51673216522526ad41b29fc.zip
fluxbox_pavel-e1b1f375c6621ab5e51673216522526ad41b29fc.tar.bz2
Fixed grabguard, return value of destroyNotifyEvent and some indentation
Diffstat (limited to 'src')
-rw-r--r--src/Window.cc88
1 files changed, 53 insertions, 35 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 212a1c2..9e422ae 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.21 2002/01/18 18:28:17 pekdon Exp $ 25// $Id: Window.cc,v 1.22 2002/01/20 02:14:20 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
@@ -92,7 +92,8 @@ tab(0)
92 92
93 Fluxbox *fluxbox = Fluxbox::instance(); 93 Fluxbox *fluxbox = Fluxbox::instance();
94 display = fluxbox->getXDisplay(); 94 display = fluxbox->getXDisplay();
95 95 BaseDisplay::GrabGuard gg(*fluxbox);
96
96 blackbox_attrib.workspace = workspace_number = window_number = -1; 97 blackbox_attrib.workspace = workspace_number = window_number = -1;
97 98
98 blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0l; 99 blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0l;
@@ -161,7 +162,7 @@ tab(0)
161 XWindowAttributes wattrib; 162 XWindowAttributes wattrib;
162 if ((! XGetWindowAttributes(display, client.window, &wattrib)) || 163 if ((! XGetWindowAttributes(display, client.window, &wattrib)) ||
163 (! wattrib.screen) || wattrib.override_redirect) { 164 (! wattrib.screen) || wattrib.override_redirect) {
164 fluxbox->ungrab(); 165 //fluxbox->ungrab();
165 throw FluxboxWindow::XGETWINDOWATTRIB; 166 throw FluxboxWindow::XGETWINDOWATTRIB;
166 } 167 }
167 168
@@ -170,10 +171,9 @@ tab(0)
170 else 171 else
171 screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen)); 172 screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen));
172 173
173 if (!screen) { 174 if (!screen)
174 fluxbox->ungrab();
175 throw FluxboxWindow::CANTFINDSCREEN; 175 throw FluxboxWindow::CANTFINDSCREEN;
176 } 176
177 177
178 image_ctrl = screen->getImageControl(); 178 image_ctrl = screen->getImageControl();
179 179
@@ -200,7 +200,6 @@ tab(0)
200#ifdef SLIT 200#ifdef SLIT
201 if (client.initial_state == WithdrawnState) { 201 if (client.initial_state == WithdrawnState) {
202 screen->getSlit()->addClient(client.window); 202 screen->getSlit()->addClient(client.window);
203 fluxbox->ungrab();
204 throw NOERROR; 203 throw NOERROR;
205 } 204 }
206#endif // SLIT 205#endif // SLIT
@@ -236,7 +235,8 @@ tab(0)
236 } 235 }
237 } 236 }
238 237
239 if (win == screen->getRootWindow()) modal = true; 238 if (win == screen->getRootWindow())
239 modal = true;
240 } 240 }
241 241
242 // adjust the window decorations based on transience and window sizes 242 // adjust the window decorations based on transience and window sizes
@@ -393,7 +393,6 @@ tab(0)
393 393
394 setFocusFlag(false); 394 setFocusFlag(false);
395 395
396 fluxbox->ungrab();
397 #ifdef DEBUG 396 #ifdef DEBUG
398 fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); 397 fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this);
399 #endif 398 #endif
@@ -1644,7 +1643,7 @@ bool FluxboxWindow::setInputFocus(void) {
1644 } 1643 }
1645 1644
1646 Fluxbox *fluxbox = Fluxbox::instance(); 1645 Fluxbox *fluxbox = Fluxbox::instance();
1647 1646 BaseDisplay::GrabGuard gg(*fluxbox);
1648 fluxbox->grab(); 1647 fluxbox->grab();
1649 if (! validateClient()) return false; 1648 if (! validateClient()) return false;
1650 1649
@@ -1851,21 +1850,27 @@ void FluxboxWindow::maximize(unsigned int button) {
1851 case Slit::TOPRIGHT: 1850 case Slit::TOPRIGHT:
1852 slitModT = mSlt->getHeight() + screen->getBevelWidth(); 1851 slitModT = mSlt->getHeight() + screen->getBevelWidth();
1853 switch (screen->getToolbarPlacement()) { 1852 switch (screen->getToolbarPlacement()) {
1854 case Toolbar::TOPLEFT: 1853 case Toolbar::TOPLEFT:
1855 case Toolbar::TOPCENTER: 1854 case Toolbar::TOPCENTER:
1856 case Toolbar::TOPRIGHT: 1855 case Toolbar::TOPRIGHT:
1857 slitModT -= screen->getToolbar()->getExposedHeight() + screen->getBorderWidth(); 1856 slitModT -= screen->getToolbar()->getExposedHeight() +
1858 break; 1857 screen->getBorderWidth();
1858 break;
1859 default:
1860 break;
1859 } 1861 }
1860 break; 1862 break;
1861 default: 1863 default:
1862 slitModB = mSlt->getHeight() + screen->getBevelWidth(); 1864 slitModB = mSlt->getHeight() + screen->getBevelWidth();
1863 switch (screen->getToolbarPlacement()) { 1865 switch (screen->getToolbarPlacement()) {
1864 case Toolbar::BOTTOMLEFT: 1866 case Toolbar::BOTTOMLEFT:
1865 case Toolbar::BOTTOMCENTER: 1867 case Toolbar::BOTTOMCENTER:
1866 case Toolbar::BOTTOMRIGHT: 1868 case Toolbar::BOTTOMRIGHT:
1867 slitModB -= screen->getToolbar()->getExposedHeight() + screen->getBorderWidth(); 1869 slitModB -= screen->getToolbar()->getExposedHeight() +
1868 break; 1870 screen->getBorderWidth();
1871 break;
1872 default:
1873 break;
1869 } 1874 }
1870 break; 1875 break;
1871 } 1876 }
@@ -1926,6 +1931,8 @@ void FluxboxWindow::maximize(unsigned int button) {
1926 dy += screen->getToolbar()->getExposedHeight() + 1931 dy += screen->getToolbar()->getExposedHeight() +
1927 screen->getBorderWidth2x(); 1932 screen->getBorderWidth2x();
1928 break; 1933 break;
1934 default:
1935 break;
1929 } 1936 }
1930 } 1937 }
1931 1938
@@ -2147,6 +2154,7 @@ void FluxboxWindow::setFocusFlag(bool focus) {
2147 2154
2148void FluxboxWindow::installColormap(bool install) { 2155void FluxboxWindow::installColormap(bool install) {
2149 Fluxbox *fluxbox = Fluxbox::instance(); 2156 Fluxbox *fluxbox = Fluxbox::instance();
2157 BaseDisplay::GrabGuard gg(*fluxbox);
2150 fluxbox->grab(); 2158 fluxbox->grab();
2151 if (! validateClient()) return; 2159 if (! validateClient()) return;
2152 2160
@@ -2196,7 +2204,7 @@ void FluxboxWindow::setState(unsigned long new_state) {
2196 (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements); 2204 (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements);
2197} 2205}
2198 2206
2199 2207//TODO: why ungrab in if-statement?
2200bool FluxboxWindow::getState(void) { 2208bool FluxboxWindow::getState(void) {
2201 current_state = 0; 2209 current_state = 0;
2202 2210
@@ -2210,8 +2218,8 @@ bool FluxboxWindow::getState(void) {
2210 &atom_return, &foo, &nitems, &ulfoo, 2218 &atom_return, &foo, &nitems, &ulfoo,
2211 (unsigned char **) &state) != Success) || 2219 (unsigned char **) &state) != Success) ||
2212 (! state)) { 2220 (! state)) {
2213 fluxbox->ungrab(); 2221 fluxbox->ungrab();
2214 return false; 2222 return false;
2215 } 2223 }
2216 2224
2217 if (nitems >= 1) { 2225 if (nitems >= 1) {
@@ -2448,9 +2456,10 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) {
2448 client.window); 2456 client.window);
2449#endif // DEBUG 2457#endif // DEBUG
2450 Fluxbox *fluxbox = Fluxbox::instance(); 2458 Fluxbox *fluxbox = Fluxbox::instance();
2451 2459 BaseDisplay::GrabGuard gg(*fluxbox);
2452 fluxbox->grab(); 2460 fluxbox->grab();
2453 if (! validateClient()) return; 2461 if (! validateClient())
2462 return;
2454 2463
2455 bool get_state_ret = getState(); 2464 bool get_state_ret = getState();
2456 if (! (get_state_ret && fluxbox->isStartup())) { 2465 if (! (get_state_ret && fluxbox->isStartup())) {
@@ -2491,6 +2500,7 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) {
2491 2500
2492 if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) { 2501 if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) {
2493 Fluxbox *fluxbox = Fluxbox::instance(); 2502 Fluxbox *fluxbox = Fluxbox::instance();
2503 BaseDisplay::GrabGuard gg(*fluxbox);
2494 fluxbox->grab(); 2504 fluxbox->grab();
2495 if (! validateClient()) 2505 if (! validateClient())
2496 return; 2506 return;
@@ -2531,8 +2541,10 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
2531#endif // DEBUG 2541#endif // DEBUG
2532 2542
2533 Fluxbox *fluxbox = Fluxbox::instance(); 2543 Fluxbox *fluxbox = Fluxbox::instance();
2544 BaseDisplay::GrabGuard gg(*fluxbox);
2534 fluxbox->grab(); 2545 fluxbox->grab();
2535 if (! validateClient()) return; 2546 if (! validateClient())
2547 return;
2536 2548
2537 XChangeSaveSet(display, client.window, SetModeDelete); 2549 XChangeSaveSet(display, client.window, SetModeDelete);
2538 XSelectInput(display, client.window, NoEventMask); 2550 XSelectInput(display, client.window, NoEventMask);
@@ -2557,7 +2569,6 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
2557 "FluxboxWindow::unmapNotifyEvent(): reparent 0x%lx to " 2569 "FluxboxWindow::unmapNotifyEvent(): reparent 0x%lx to "
2558 "root.\n"), client.window); 2570 "root.\n"), client.window);
2559#endif // DEBUG 2571#endif // DEBUG
2560
2561 restoreGravity(); 2572 restoreGravity();
2562 XReparentWindow(display, client.window, screen->getRootWindow(), 2573 XReparentWindow(display, client.window, screen->getRootWindow(),
2563 client.x, client.y); 2574 client.x, client.y);
@@ -2572,19 +2583,21 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
2572} 2583}
2573 2584
2574 2585
2575void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) { 2586bool FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) {
2576 if (de->window == client.window) { 2587 if (de->window == client.window) {
2577 #ifdef DEBUG 2588 #ifdef DEBUG
2578 fprintf(stderr,"%s(%d): DestroyNotifyEvent this=%p\n", __FILE__, __LINE__, this); 2589 cerr<<__FILE__<<"("<<__LINE__<<":) DestroyNotifyEvent this="<<this<<endl;
2579 #endif 2590 #endif
2580 XUnmapWindow(display, frame.window); 2591 XUnmapWindow(display, frame.window);
2581 delete this; 2592 return true;
2582 } 2593 }
2594 return false;
2583} 2595}
2584 2596
2585 2597
2586void FluxboxWindow::propertyNotifyEvent(Atom atom) { 2598void FluxboxWindow::propertyNotifyEvent(Atom atom) {
2587 Fluxbox *fluxbox = Fluxbox::instance(); 2599 Fluxbox *fluxbox = Fluxbox::instance();
2600 BaseDisplay::GrabGuard gg(*fluxbox);
2588 fluxbox->grab(); 2601 fluxbox->grab();
2589 if (! validateClient()) return; 2602 if (! validateClient()) return;
2590 2603
@@ -2723,6 +2736,7 @@ void FluxboxWindow::exposeEvent(XExposeEvent *ee) {
2723void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) { 2736void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) {
2724 if (cr->window == client.window) { 2737 if (cr->window == client.window) {
2725 Fluxbox *fluxbox = Fluxbox::instance(); 2738 Fluxbox *fluxbox = Fluxbox::instance();
2739 BaseDisplay::GrabGuard gg(*fluxbox);
2726 fluxbox->grab(); 2740 fluxbox->grab();
2727 if (! validateClient()) 2741 if (! validateClient())
2728 return; 2742 return;
@@ -2785,6 +2799,7 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) {
2785 2799
2786void FluxboxWindow::buttonPressEvent(XButtonEvent *be) { 2800void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
2787 Fluxbox *fluxbox = Fluxbox::instance(); 2801 Fluxbox *fluxbox = Fluxbox::instance();
2802 BaseDisplay::GrabGuard gg(*fluxbox);
2788 fluxbox->grab(); 2803 fluxbox->grab();
2789 2804
2790 if (! validateClient()) 2805 if (! validateClient())
@@ -2909,6 +2924,7 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
2909 2924
2910void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) { 2925void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) {
2911 Fluxbox *fluxbox = Fluxbox::instance(); 2926 Fluxbox *fluxbox = Fluxbox::instance();
2927 BaseDisplay::GrabGuard gg(*fluxbox);
2912 fluxbox->grab(); 2928 fluxbox->grab();
2913 2929
2914 if (! validateClient()) 2930 if (! validateClient())
@@ -3069,11 +3085,11 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3069 bool left = (me->window == frame.left_grip); 3085 bool left = (me->window == frame.left_grip);
3070 3086
3071 if (! resizing) { 3087 if (! resizing) {
3072 XGrabPointer(display, me->window, false, ButtonMotionMask | 3088 XGrabPointer(display, me->window, false, ButtonMotionMask |
3073 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, 3089 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None,
3074 ((left) ? fluxbox->getLowerLeftAngleCursor() : 3090 ((left) ? fluxbox->getLowerLeftAngleCursor() :
3075 fluxbox->getLowerRightAngleCursor()), 3091 fluxbox->getLowerRightAngleCursor()),
3076 CurrentTime); 3092 CurrentTime);
3077 3093
3078 resizing = true; 3094 resizing = true;
3079 3095
@@ -3135,6 +3151,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3135#ifdef SHAPE 3151#ifdef SHAPE
3136void FluxboxWindow::shapeEvent(XShapeEvent *) { 3152void FluxboxWindow::shapeEvent(XShapeEvent *) {
3137 Fluxbox *fluxbox = Fluxbox::instance(); 3153 Fluxbox *fluxbox = Fluxbox::instance();
3154 BaseDisplay::GrabGuard gg(*fluxbox);
3155
3138 if (fluxbox->hasShapeExtensions()) { 3156 if (fluxbox->hasShapeExtensions()) {
3139 if (frame.shaped) { 3157 if (frame.shaped) {
3140 fluxbox->grab(); 3158 fluxbox->grab();