Fixed grabguard, return value of destroyNotifyEvent and some indentation

This commit is contained in:
fluxgen 2002-01-20 02:14:20 +00:00
parent d462b97960
commit e1b1f375c6

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Window.cc,v 1.21 2002/01/18 18:28:17 pekdon Exp $ // $Id: Window.cc,v 1.22 2002/01/20 02:14:20 fluxgen Exp $
// stupid macros needed to access some functions in version 2 of the GNU C // stupid macros needed to access some functions in version 2 of the GNU C
// library // library
@ -92,6 +92,7 @@ tab(0)
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
display = fluxbox->getXDisplay(); display = fluxbox->getXDisplay();
BaseDisplay::GrabGuard gg(*fluxbox);
blackbox_attrib.workspace = workspace_number = window_number = -1; blackbox_attrib.workspace = workspace_number = window_number = -1;
@ -161,7 +162,7 @@ tab(0)
XWindowAttributes wattrib; XWindowAttributes wattrib;
if ((! XGetWindowAttributes(display, client.window, &wattrib)) || if ((! XGetWindowAttributes(display, client.window, &wattrib)) ||
(! wattrib.screen) || wattrib.override_redirect) { (! wattrib.screen) || wattrib.override_redirect) {
fluxbox->ungrab(); //fluxbox->ungrab();
throw FluxboxWindow::XGETWINDOWATTRIB; throw FluxboxWindow::XGETWINDOWATTRIB;
} }
@ -170,10 +171,9 @@ tab(0)
else else
screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen)); screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen));
if (!screen) { if (!screen)
fluxbox->ungrab();
throw FluxboxWindow::CANTFINDSCREEN; throw FluxboxWindow::CANTFINDSCREEN;
}
image_ctrl = screen->getImageControl(); image_ctrl = screen->getImageControl();
@ -200,7 +200,6 @@ tab(0)
#ifdef SLIT #ifdef SLIT
if (client.initial_state == WithdrawnState) { if (client.initial_state == WithdrawnState) {
screen->getSlit()->addClient(client.window); screen->getSlit()->addClient(client.window);
fluxbox->ungrab();
throw NOERROR; throw NOERROR;
} }
#endif // SLIT #endif // SLIT
@ -236,7 +235,8 @@ tab(0)
} }
} }
if (win == screen->getRootWindow()) modal = true; if (win == screen->getRootWindow())
modal = true;
} }
// adjust the window decorations based on transience and window sizes // adjust the window decorations based on transience and window sizes
@ -393,7 +393,6 @@ tab(0)
setFocusFlag(false); setFocusFlag(false);
fluxbox->ungrab();
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this);
#endif #endif
@ -1644,7 +1643,7 @@ bool FluxboxWindow::setInputFocus(void) {
} }
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) return false; if (! validateClient()) return false;
@ -1854,7 +1853,10 @@ void FluxboxWindow::maximize(unsigned int button) {
case Toolbar::TOPLEFT: case Toolbar::TOPLEFT:
case Toolbar::TOPCENTER: case Toolbar::TOPCENTER:
case Toolbar::TOPRIGHT: case Toolbar::TOPRIGHT:
slitModT -= screen->getToolbar()->getExposedHeight() + screen->getBorderWidth(); slitModT -= screen->getToolbar()->getExposedHeight() +
screen->getBorderWidth();
break;
default:
break; break;
} }
break; break;
@ -1864,7 +1866,10 @@ void FluxboxWindow::maximize(unsigned int button) {
case Toolbar::BOTTOMLEFT: case Toolbar::BOTTOMLEFT:
case Toolbar::BOTTOMCENTER: case Toolbar::BOTTOMCENTER:
case Toolbar::BOTTOMRIGHT: case Toolbar::BOTTOMRIGHT:
slitModB -= screen->getToolbar()->getExposedHeight() + screen->getBorderWidth(); slitModB -= screen->getToolbar()->getExposedHeight() +
screen->getBorderWidth();
break;
default:
break; break;
} }
break; break;
@ -1926,6 +1931,8 @@ void FluxboxWindow::maximize(unsigned int button) {
dy += screen->getToolbar()->getExposedHeight() + dy += screen->getToolbar()->getExposedHeight() +
screen->getBorderWidth2x(); screen->getBorderWidth2x();
break; break;
default:
break;
} }
} }
@ -2147,6 +2154,7 @@ void FluxboxWindow::setFocusFlag(bool focus) {
void FluxboxWindow::installColormap(bool install) { void FluxboxWindow::installColormap(bool install) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) return; if (! validateClient()) return;
@ -2196,7 +2204,7 @@ void FluxboxWindow::setState(unsigned long new_state) {
(unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements); (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements);
} }
//TODO: why ungrab in if-statement?
bool FluxboxWindow::getState(void) { bool FluxboxWindow::getState(void) {
current_state = 0; current_state = 0;
@ -2448,9 +2456,10 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) {
client.window); client.window);
#endif // DEBUG #endif // DEBUG
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) return; if (! validateClient())
return;
bool get_state_ret = getState(); bool get_state_ret = getState();
if (! (get_state_ret && fluxbox->isStartup())) { if (! (get_state_ret && fluxbox->isStartup())) {
@ -2491,6 +2500,7 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) {
if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) { if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) if (! validateClient())
return; return;
@ -2531,8 +2541,10 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
#endif // DEBUG #endif // DEBUG
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) return; if (! validateClient())
return;
XChangeSaveSet(display, client.window, SetModeDelete); XChangeSaveSet(display, client.window, SetModeDelete);
XSelectInput(display, client.window, NoEventMask); XSelectInput(display, client.window, NoEventMask);
@ -2557,7 +2569,6 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
"FluxboxWindow::unmapNotifyEvent(): reparent 0x%lx to " "FluxboxWindow::unmapNotifyEvent(): reparent 0x%lx to "
"root.\n"), client.window); "root.\n"), client.window);
#endif // DEBUG #endif // DEBUG
restoreGravity(); restoreGravity();
XReparentWindow(display, client.window, screen->getRootWindow(), XReparentWindow(display, client.window, screen->getRootWindow(),
client.x, client.y); client.x, client.y);
@ -2572,19 +2583,21 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
} }
void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) { bool FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) {
if (de->window == client.window) { if (de->window == client.window) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"%s(%d): DestroyNotifyEvent this=%p\n", __FILE__, __LINE__, this); cerr<<__FILE__<<"("<<__LINE__<<":) DestroyNotifyEvent this="<<this<<endl;
#endif #endif
XUnmapWindow(display, frame.window); XUnmapWindow(display, frame.window);
delete this; return true;
} }
return false;
} }
void FluxboxWindow::propertyNotifyEvent(Atom atom) { void FluxboxWindow::propertyNotifyEvent(Atom atom) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) return; if (! validateClient()) return;
@ -2723,6 +2736,7 @@ void FluxboxWindow::exposeEvent(XExposeEvent *ee) {
void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) { void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) {
if (cr->window == client.window) { if (cr->window == client.window) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) if (! validateClient())
return; return;
@ -2785,6 +2799,7 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) {
void FluxboxWindow::buttonPressEvent(XButtonEvent *be) { void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) if (! validateClient())
@ -2909,6 +2924,7 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) { void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) if (! validateClient())
@ -3135,6 +3151,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
#ifdef SHAPE #ifdef SHAPE
void FluxboxWindow::shapeEvent(XShapeEvent *) { void FluxboxWindow::shapeEvent(XShapeEvent *) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox);
if (fluxbox->hasShapeExtensions()) { if (fluxbox->hasShapeExtensions()) {
if (frame.shaped) { if (frame.shaped) {
fluxbox->grab(); fluxbox->grab();