fixed autogrouping

This commit is contained in:
fluxgen 2002-08-11 22:44:29 +00:00
parent b32511f411
commit c8c612e7d2

View file

@ -22,19 +22,10 @@
// 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.65 2002/08/04 15:15:22 fluxgen Exp $ // $Id: Window.cc,v 1.66 2002/08/11 22:44:29 fluxgen Exp $
#include "Window.hh" #include "Window.hh"
//use GNU extensions
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif // _GNU_SOURCE
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif // HAVE_CONFIG_H
#include "i18n.hh" #include "i18n.hh"
#include "fluxbox.hh" #include "fluxbox.hh"
#include "Icon.hh" #include "Icon.hh"
@ -43,25 +34,26 @@
#include "Windowmenu.hh" #include "Windowmenu.hh"
#include "StringUtil.hh" #include "StringUtil.hh"
#ifdef SLIT #ifdef SLIT
# include "Slit.hh" #include "Slit.hh"
#endif // SLIT #endif // SLIT
//use GNU extensions
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif // _GNU_SOURCE
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif // HAVE_CONFIG_H
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#ifdef STDC_HEADERS #include <cstring>
# include <string.h> #include <cstdio>
#endif // STDC_HEADERS
#ifdef DEBUG
# ifdef HAVE_STDIO_H
# include <stdio.h>
# endif // HAVE_STDIO_H
#endif // DEBUG
#include <iostream> #include <iostream>
using namespace std; using namespace std;
FluxboxWindow::FluxboxWindow(Window w, BScreen *s): FluxboxWindow::FluxboxWindow(Window w, BScreen *s):
@ -82,7 +74,7 @@ tab(0)
{ {
lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0; lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, fprintf(stderr,
I18n::instance()-> I18n::instance()->
getMessage( getMessage(
@ -90,7 +82,7 @@ tab(0)
"FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"),
w); w);
#endif //DEBUG #endif //DEBUG
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
display = fluxbox->getXDisplay(); display = fluxbox->getXDisplay();
@ -333,10 +325,9 @@ tab(0)
updateGnomeAtoms(); updateGnomeAtoms();
#endif #endif
#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 // DEBUG
} }
@ -2713,52 +2704,81 @@ void FluxboxWindow::redrawAllButtons() {
} }
void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) { void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) {
if (re->window == client.window) { if (re->window != client.window)
#ifdef DEBUG return;
#ifdef DEBUG
fprintf(stderr, fprintf(stderr,
I18n::instance()->getMessage( I18n::instance()->getMessage(
FBNLS::WindowSet, FBNLS::WindowMapRequest, FBNLS::WindowSet, FBNLS::WindowMapRequest,
"FluxboxWindow::mapRequestEvent() for 0x%lx\n"), "FluxboxWindow::mapRequestEvent() for 0x%lx\n"),
client.window); client.window);
#endif // DEBUG #endif // DEBUG
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
BaseDisplay::GrabGuard gg(*fluxbox); BaseDisplay::GrabGuard gg(*fluxbox);
fluxbox->grab(); fluxbox->grab();
if (! validateClient()) if (! validateClient())
return; return;
bool get_state_ret = getState(); bool get_state_ret = getState();
if (! (get_state_ret && fluxbox->isStartup())) { if (! (get_state_ret && fluxbox->isStartup())) {
if ((client.wm_hint_flags & StateHint) && if ((client.wm_hint_flags & StateHint) &&
(! (current_state == NormalState || current_state == IconicState))) (! (current_state == NormalState || current_state == IconicState))) {
current_state = client.initial_state; current_state = client.initial_state;
else } else
current_state = NormalState;
} else if (iconic)
current_state = NormalState; current_state = NormalState;
} else if (iconic)
current_state = NormalState;
switch (current_state) {
case IconicState:
iconify();
break;
switch (current_state) { case WithdrawnState:
case IconicState: withdraw();
iconify(); break;
break; case NormalState:
//check WM_CLASS only when we changed state to NormalState from
// WithdrawnState (ICCC 4.1.2.5)
XClassHint ch;
case WithdrawnState: if (XGetClassHint(display, getClientWindow(), &ch) == 0) {
withdraw(); cerr<<"Faild to ready class hint!"<<endl;
} else {
if (ch.res_name != 0) {
m_instance_name = const_cast<char *>(ch.res_name);
XFree(ch.res_name);
} else
m_instance_name = "";
break; if (ch.res_class != 0) {
m_class_name = const_cast<char *>(ch.res_class);
XFree(ch.res_class);
} else
m_class_name = "";
case NormalState: Workspace *wsp = screen->getWorkspace(workspace_number);
case InactiveState: // we must be resizable AND maximizable to be autogrouped
case ZoomState: // TODO: there should be an isGroupable() function
default: if (wsp != 0 && isResizable() && isMaximizable()) {
deiconify(false); wsp->checkGrouping(*this);
}
break; }
}
deiconify(false);
fluxbox->ungrab();
break;
case InactiveState:
case ZoomState:
default:
deiconify(false);
break;
} }
fluxbox->ungrab();
} }
@ -2879,9 +2899,9 @@ bool FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) {
void FluxboxWindow::propertyNotifyEvent(Atom atom) { void FluxboxWindow::propertyNotifyEvent(Atom atom) {
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
// BaseDisplay::GrabGuard gg(*fluxbox);
// fluxbox->grab(); if (! validateClient())
if (! validateClient()) return; return;
switch(atom) { switch(atom) {
case XA_WM_CLASS: case XA_WM_CLASS:
@ -2976,7 +2996,6 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) {
break; break;
} }
// fluxbox->ungrab();
} }