From 890ba372b26c029b1fb147d1668cde942b43393a Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 17 Feb 2002 18:48:22 +0000 Subject: gnome functions --- src/Window.cc | 229 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 205 insertions(+), 24 deletions(-) diff --git a/src/Window.cc b/src/Window.cc index c4e211e..aee5504 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.28 2002/02/16 11:25:41 fluxgen Exp $ +// $Id: Window.cc,v 1.29 2002/02/17 18:48:22 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -74,6 +74,9 @@ display(0), lastButtonPressTime(0), windowmenu(0), tab(0) +#ifdef GNOME +,gnome_hints(0) +#endif { #ifdef DEBUG @@ -386,10 +389,6 @@ FluxboxWindow::~FluxboxWindow(void) { if (screen==0) //the window wasn't created return; - #ifdef GNOME - XDeleteProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom()); - #endif - Fluxbox *fluxbox = Fluxbox::instance(); @@ -856,6 +855,7 @@ void FluxboxWindow::grabButtons() { //---grab with "all" modifiers grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor()); } + void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventProc released, ButtonDrawProc draw) { Button b; b.win = createChildWindow(frame.title); @@ -867,27 +867,46 @@ void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventP b.released = released; buttonlist.push_back(b); } + #ifdef GNOME +//TODO void FluxboxWindow::updateGnomeAtoms() { + updateGnomeWorkspaceAtom(); + updateGnomeStateAtom(); + updateGnomeLayerAtom(); + updateGnomeWorkspaceAtom(); +} + +void FluxboxWindow::updateGnomeStateAtom() { + BaseDisplay *bd = screen->getBaseDisplay(); + int val = getGnomeWindowState(); + XChangeProperty(display, client.window, bd->getGnomeStateAtom(), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); +} + +void FluxboxWindow::updateGnomeLayerAtom() { + BaseDisplay *bd = screen->getBaseDisplay(); + int val = getGnomeLayer(); + XChangeProperty(display, client.window, bd->getGnomeLayerAtom(), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); +} + +void FluxboxWindow::updateGnomeWorkspaceAtom() { + BaseDisplay *bd = screen->getBaseDisplay(); int val = workspace_number; - XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom(), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); - long state = getGnomeWindowState(); - XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeStateAtom(), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&state, 1); - #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): 0x"<getBaseDisplay()->getGnomeStateAtom()<getGnomeWorkspaceAtom(), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); } -long FluxboxWindow::getGnomeWindowState() { - long state=0; +//TODO +int FluxboxWindow::getGnomeWindowState() { + int state=0; if (isStuck()) - state |= BaseDisplay::WIN_STATE_STICKY; + state |= WIN_STATE_STICKY; if (isIconic()) - state |= BaseDisplay::WIN_STATE_MINIMIZED; + state |= WIN_STATE_MINIMIZED; if (isShaded()) - state |= BaseDisplay::WIN_STATE_SHADED; + state |= WIN_STATE_SHADED; /*TODO: states: WIN_STATE_MAXIMIZED_VERT // window in maximized V state WIN_STATE_MAXIMIZED_HORIZ // window in maximized H state @@ -899,8 +918,148 @@ long FluxboxWindow::getGnomeWindowState() { */ return state; } + +//TODO +int FluxboxWindow::getGnomeLayer() { + return WIN_LAYER_NORMAL; +} + +bool FluxboxWindow::handleGnomePropertyNotify(Atom atom) { + BaseDisplay *bd = screen->getBaseDisplay(); + + if (atom == bd->getGnomeStateAtom()) { + #ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): gnome state"<getGnomeWorkspaceAtom()) { + #ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): gnome workspace"<getGnomeHintsAtom()) { + #ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): gnome hints"<getGnomeLayerAtom()){ + #ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): gnome layer"<getBaseDisplay(); + if (XGetWindowProperty (bd->getXDisplay(), getClientWindow(), + bd->getGnomeStateAtom(), 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, + (unsigned char **) &data) == Success && data) { + flags = *data; + setGnomeState(flags); + XFree (data); + } +} + +//--------- loadGnomeHintsAtom --------- +// Gets the gnome hint from the atom +//---------------------------------------- +void FluxboxWindow::loadGnomeHintsAtom() { + Atom ret_type; + int fmt; + unsigned long nitems, bytes_after; + long *data = 0; + BaseDisplay *bd = screen->getBaseDisplay(); + if (XGetWindowProperty (bd->getXDisplay(), getClientWindow(), + bd->getGnomeHintsAtom(), 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, + (unsigned char **) &data) == Success && data) { + gnome_hints = static_cast(*data); + #ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): gnome hints:0x"<getBorderWidth(), screen->getBorderWidth(), @@ -1848,9 +2011,7 @@ void FluxboxWindow::close(void) { void FluxboxWindow::withdraw(void) { visible = false; iconic = false; -// -// setState(WithdrawnState); -// + XUnmapWindow(display, frame.window); XSelectInput(display, client.window, NoEventMask); @@ -2091,11 +2252,14 @@ void FluxboxWindow::setWorkspace(int n) { blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE; blackbox_attrib.workspace = workspace_number; + #ifdef GNOME + updateGnomeWorkspaceAtom(); + #endif } void FluxboxWindow::shade(void) { - if (decorations.titlebar) + if (decorations.titlebar) { if (shaded) { XResizeWindow(display, frame.window, frame.width, frame.height); shaded = false; @@ -2111,6 +2275,10 @@ void FluxboxWindow::shade(void) { setState(IconicState); } + #ifdef GNOME + updateGnomeStateAtom(); + #endif + } } @@ -2138,6 +2306,9 @@ void FluxboxWindow::stick(void) { //find a STICK button in window redrawAllButtons(); setState(current_state); + #ifdef GNOME + updateGnomeStateAtom(); + #endif } @@ -2557,7 +2728,9 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) { void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) { - + #ifdef GNOME + loadGnomeAtoms(); + #endif if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) { Fluxbox *fluxbox = Fluxbox::instance(); BaseDisplay::GrabGuard gg(*fluxbox); @@ -2786,8 +2959,16 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) { if (windowmenu) windowmenu->reconfigure(); } + } else { + bool val = false; + #ifdef GNOME + val = handleGnomePropertyNotify(atom); + #endif + #ifdef NEWWMSPEC + if (!val) + handleNETWMPropertyNotify(atom); + #endif } - break; } -- cgit v0.11.2