summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2009-01-16 10:00:56 +1000
committerPeter Hutterer <peter.hutterer@redhat.com>2009-01-16 10:00:56 +1000
commitcadad265730418b023a1be16f95cf6754e928d06 (patch)
tree6840e5e3695ecfd9493d741b38ac24000d96b625
parentcb34a86e8e6fbc5966432e1234c610a24ea03392 (diff)
Remove floor control code, the matching bits aren't in MPX anymore
-rw-r--r--src/DockApp.cpp1
-rw-r--r--src/FloorControl.cpp285
-rw-r--r--src/FloorControl.h66
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Manager.cpp28
-rw-r--r--src/Overlay.cpp39
-rw-r--r--src/PointerDevice.cpp1
-rw-r--r--src/WMWindow.cpp84
-rw-r--r--src/WMWindow.h3
9 files changed, 5 insertions, 504 deletions
diff --git a/src/DockApp.cpp b/src/DockApp.cpp
index 0363506..e2b0287 100644
--- a/src/DockApp.cpp
+++ b/src/DockApp.cpp
@@ -4,6 +4,7 @@
#include "logger.h"
#include <cairo.h>
#include <cairo-xlib.h>
+#include <stdlib.h>
DockApp::DockApp(XConn* x11, const char* app, char* imgfile)
{
diff --git a/src/FloorControl.cpp b/src/FloorControl.cpp
deleted file mode 100644
index 382ef32..0000000
--- a/src/FloorControl.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* $Id: FloorControl.cpp,v 1.9 2007/01/07 05:00:56 whot Exp $ */
-
-/*--
- --*/
-
-#include "FloorControl.h"
-
-FloorControl::FloorControl(Manager* manager, WMWindow* client, XConn* x11)
-{
- this->manager = manager;
- this->client = client;
- this->x11 = x11;
-}
-
-FloorControl::~FloorControl()
-{
- XDestroyWindow(x11->dpy, root->fcwin);
- freeSubNodes(root);
- delete root;
-}
-
-/**
- * Frees all subnodes of a node (recursively).
- * Does NOT release the memory for the node itself.
- */
-void FloorControl::freeSubNodes(WinTreeNodePtr node)
-{
- vector<WinTreeNodePtr>::iterator it = node->children.begin();
- while(it != node->children.end())
- {
- freeSubNodes(*it);
- delete (*it);
- it++;
- }
-}
-
-/**
- * Queries a WinTreeNode's window for the subchildren and fills the data into
- * the node. This works recursively.
- */
-bool FloorControl::getChildren(WinTreeNodePtr node)
-{
- Window root_return, parent_return;
- Window* children;
- unsigned int no_children;
- unsigned int i;
-
- XQueryTree(x11->dpy, node->win, &root_return, &parent_return, &children, &no_children);
-
- if (!no_children)
- {
- node->children.clear();
- return false;
- }
-
- i = 0;
- while (i < no_children)
- {
- WinTreeNodePtr kidnode;
- kidnode = new WinTreeNode;
- memset(kidnode, 0, sizeof(WinTreeNode));
- kidnode->win = children[i];
- kidnode->parent = node;
-
- XGetWindowAttributes(x11->dpy, kidnode->win, &kidnode->attr);
-
- node->children.push_back(kidnode);
- i++;
- }
- XFree(children);
- return true;
-}
-
-/**
- * Initialises internal structures. This means querying the client window for
- * child windows and building up the hierarchy.
- */
-
-void FloorControl::init()
-{
- WinTreeNodePtr node = NULL;
-
- // list of windows that have not been queried for children yet.
- deque<WinTreeNodePtr> unqueried;
-
- root = new WinTreeNode;
- root->win = client->getClientWindow();
- root->parent = NULL;
-
- XGetWindowAttributes(x11->dpy, root->win, &root->attr);
-
- unqueried.push_back(root);
-
- do {
- node = unqueried[0];
- unqueried.pop_front();
-
- getChildren(node);
-
- if (!node->children.empty())
- {
- vector<WinTreeNodePtr>::iterator it = node->children.begin();
- while(it != node->children.end())
- {
- unqueried.push_back(*it);
- it++;
- }
- }
- } while(!unqueried.empty());
-}
-
-
-/**
- * For each window in the hierarchy starting with the given parent window do
- * the following:
- * - create a new window in exactly the same place.
- * - set the window to listen to button events.
- * - call the method for all childs.
- * This builds up a simple rebuilt GUI of the underlying client.
- */
-void FloorControl::buildNodeGUI(WinTreePtr node, Window parent)
-{
- if (node->attr.map_state != IsViewable)
- return;
-
- node->fcwin = XCreateSimpleWindow(x11->dpy, parent, node->attr.x, node->attr.y,
- node->attr.width - 2, node->attr.height - 2, 1,
- BlackPixel(x11->dpy, 0), WhitePixel(x11->dpy, 0));
-
- TRACE("Floor control creating window %x\n", (int)node->fcwin);
-
- XSelectInput(x11->dpy, node->fcwin, EnterWindowMask | LeaveWindowMask);
- manager->setButtonPressMask(node->fcwin);
- XMapWindow(x11->dpy, node->fcwin);
- XFlush(x11->dpy);
-
- vector<WinTreePtr>::iterator it = node->children.begin();
-
- while(it != node->children.end())
- {
- buildNodeGUI(*it, node->fcwin);
- it++;
- }
-}
-
-
-
-/**
- * Display floor control overlay windows.
- */
-void FloorControl::display()
-{
- buildNodeGUI(root, client->getContainer());
- XFlush(x11->dpy);
-}
-
-
-/**
- * Returns true if the floor control window has the given window.
- */
-bool FloorControl::hasWindow(Window win)
-{
- return nodeHasWindow(root, win);
-}
-
-/**
- * Returns true if the node or any of its subnodes contains the given window.
- */
-bool FloorControl::nodeHasWindow(WinTreeNodePtr node, Window win)
-{
- if (node->fcwin == win)
- return true;
-
- vector<WinTreeNodePtr>::iterator it = node->children.begin();
-
- while(it != node->children.end())
- {
- if (nodeHasWindow(*it, win))
- return true;
- it++;
- }
- return false;
-}
-
-/**
- * Handles enter/leave events. These events occur when a mouse moves over one
- * of the floor control windows.
- */
-void FloorControl::handleEnterLeave(XCrossingEvent* ev)
-{
- WinTreeNodePtr node = getNodeByWindow(ev->window);
- if (!node)
- return;
-
- XSetWindowAttributes attr;
-
- if (ev->type == EnterNotify)
- attr.background_pixel = BlackPixel(x11->dpy, 0);
- else
- attr.background_pixel = WhitePixel(x11->dpy, 0);
-
-
- XChangeWindowAttributes(x11->dpy, node->fcwin, CWBackPixel, &attr);
- XClearWindow(x11->dpy, node->fcwin);
- XFlush(x11->dpy);
-}
-
-
-WinTreeNodePtr FloorControl::getNodeByWindow(Window win)
-{
- return findNodeForWindow(root, win);
-}
-
-WinTreeNodePtr FloorControl::findNodeForWindow(WinTreeNodePtr node, Window win)
-{
- if (node->fcwin == win)
- return node;
-
- vector<WinTreeNodePtr>::iterator it = node->children.begin();
- while(it != node->children.end())
- {
- WinTreeNodePtr kidnode;
- kidnode = findNodeForWindow(*it, win);
- if (kidnode)
- return kidnode;
- it++;
- }
-
- return NULL;
-}
-
-void FloorControl::handleButtonPress(XDeviceButtonEvent* ev, PointerDevice* dev)
-{
- WinTreeNodePtr node = getNodeByWindow(ev->window);
- int id = dev->getID();
-
- if (node)
- {
- XID *permdevs = NULL,
- *denydevs = NULL;
- int nperm, ndeny, rule;
-
- XQueryWindowAccess(x11->dpy, client->getClientWindow(), &rule,
- &permdevs, &nperm, &denydevs, &ndeny);
-
- if (ev->state & Button1Mask)
- {
- int i;
- for (i = 0; i < nperm; i++)
- {
- if (permdevs[i] == (XID)id)
- break;
- }
-
- if (i >= nperm)
- {
- permdevs = (XID*)realloc(permdevs, (nperm + 1) * sizeof(XID));
- permdevs[nperm++] = (char)id;
- XPermitDevices(x11->dpy, client->getClientWindow(), permdevs, nperm);
- }
- }
- else if (ev->state & Button3Mask)
- {
- for (int i = 0; i < nperm; i++)
- {
- if (permdevs[i] == (XID)id)
- {
- if (i + 1 < nperm)
- memmove(&permdevs[i], &permdevs[i+1], nperm - i - 1);
- nperm--;
- XPermitDevices(x11->dpy, client->getClientWindow(), permdevs, nperm);
- break;
- }
- }
- }
-
- if (nperm > 0)
- XChangeAccessRule(x11->dpy, node->win, WindowAccessDenyAll);
- else
- XWindowClearAccess(x11->dpy, node->win, WindowAccessClearRule);
-
- free(permdevs);
- free(denydevs);
- }
-}
diff --git a/src/FloorControl.h b/src/FloorControl.h
deleted file mode 100644
index de1b034..0000000
--- a/src/FloorControl.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* $Id: FloorControl.h,v 1.4 2007/01/07 05:00:56 whot Exp $ */
-/*--
- --*/
-
-#ifndef __FLOORCONTROL_H__
-#define __FLOORCONTROL_H__
-
-#include<X11/Xlib.h>
-#include<vector>
-#include<deque>
-#include "WMWindow.h"
-#include "Manager.h"
-#include "PointerDevice.h"
-#include "XConn.h"
-
-using namespace std;
-
-/**
- * This struct is used for the window hierarchy tree. To resemble the GUI of a
- * client program we need to find all windows and query their attributes. This
- * node structure represents one window.
- */
-typedef struct _WinTreeNode {
- struct _WinTreeNode* parent;
- vector<struct _WinTreeNode*> children;
- Window win;
- XWindowAttributes attr;
- Window fcwin; // floor control window
-} WinTreeNode, *WinTreeNodePtr;
-
-typedef WinTreeNodePtr WinTreePtr;
-
-class Manager;
-class WMWindow;
-class PointerDevice;
-
-class FloorControl
-{
- private:
- XConn* x11;
- WinTreePtr root;
- Manager* manager;
- WMWindow* client;
-
- public:
- FloorControl(Manager* manager, WMWindow* wmwindow, XConn* x11);
- ~FloorControl();
- void init();
- void display();
- void handleButtonPress(XDeviceButtonEvent* ev, PointerDevice* dev);
- void handleEnterLeave(XCrossingEvent* ev);
- bool hasWindow(Window win);
-
- private:
- bool getChildren(WinTreeNodePtr node);
- void printHierarchy(WinTreeNodePtr node, int indentation);
- void buildNodeGUI(WinTreeNodePtr, Window parent);
- void freeSubNodes(WinTreeNodePtr node);
- bool nodeHasWindow(WinTreeNodePtr node, Window win);
- WinTreeNodePtr getNodeByWindow(Window win);
- WinTreeNodePtr findNodeForWindow(WinTreeNodePtr node, Window win);
-
-};
-
-#endif
-
diff --git a/src/Makefile.am b/src/Makefile.am
index 017f63b..6300ea5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,8 +14,6 @@ mpwm_SOURCES = main.cpp \
DeviceError.cpp \
DeviceError.h \
UnknownWindowException.h \
- FloorControl.cpp \
- FloorControl.h \
PointerDevice.cpp \
PointerDevice.h \
Process.cpp \
diff --git a/src/Manager.cpp b/src/Manager.cpp
index 084d135..a2783ef 100644
--- a/src/Manager.cpp
+++ b/src/Manager.cpp
@@ -671,11 +671,6 @@ void Manager::handleButtonPress(XDeviceButtonEvent* bev)
TRACE(" - Resize on for %x\n", (int)bev->window);
}
- if (wmwindow->isFloorControlWindow(bev->window))
- {
- wmwindow->floorControlButtonPress(bev, dev);
- }
-
if (wmwindow->isButtonMinimize(bev->window))
{
wmwindow->setMinimize(true);
@@ -727,26 +722,6 @@ void Manager::handleButtonRelease(XDeviceButtonEvent* bev)
return;
}
- // leftclick on button: lock window to pointer
- // rightclick on button: display floor control gui
- if (win->isButtonFloor(bev->window))
- {
- if (bev->button == Button3)
- {
- win->toggleFloorControl();
- } else
- if (win->isLocked())
- win->release(dev);
- else
- {
- if (win->restrictTo(dev))
- TRACE("Window %x limited to device %s\n",
- (int)win->getClientWindow(), dev->getName().c_str());
- else
- ERR("Could not limit window\n");
- }
- }
-
if (win->isButtonOverlay(bev->subwindow))
{
if (bev->device_state & Button1Mask)
@@ -765,9 +740,6 @@ void Manager::handleButtonRelease(XDeviceButtonEvent* bev)
void Manager::handleEnterLeaveNotify(XCrossingEvent* ev)
{
- WMWindow* client = windowToWMWindow(ev->window);
- if (client)
- client->handleEnterLeaveNotify(ev);
}
void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index f92dfe1..4f10134 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -4,6 +4,8 @@
--*/
#include "Overlay.h"
+#include <stdlib.h>
+#include <string.h>
Overlay::Overlay(Manager* manager, WMWindow* client, XConn* x11)
{
@@ -74,54 +76,17 @@ void Overlay::initWindows()
*/
void Overlay::toggle(int id)
{
- XID *permdevs,
- *denydevs;
- int nperm, ndeny, rule;
-
- XQueryWindowAccess(x11->dpy, client->getClientWindow(), &rule,
- &permdevs, &nperm, &denydevs, &ndeny);
-
if (!layers[id]->visible)
{
TRACE("Overlay on\n");
XMapRaised(x11->dpy, layers[id]->win);
layers[id]->visible = !layers[id]->visible;
-
- int i;
- for (i = 0; i < ndeny; i++)
- {
- if (denydevs[i] == (XID)id)
- break;
- }
-
- if (i >= ndeny)
- {
- denydevs = (XID*)realloc(denydevs, (ndeny + 1) * sizeof(XID));
- denydevs[ndeny++] = (char)id;
- XDenyDevices(x11->dpy, client->getClientWindow(), denydevs, ndeny);
- }
-
} else
{
TRACE("Overlay off\n");
XUnmapWindow(x11->dpy, layers[id]->win);
layers[id]->visible = !layers[id]->visible;
-
- for (int i = 0; i < ndeny; i++)
- {
- if (denydevs[i] == (XID)id)
- {
- if (i + 1 < ndeny)
- memmove(&denydevs[i], &denydevs[i+1], ndeny - i - 1);
- ndeny--;
- XDenyDevices(x11->dpy, client->getClientWindow(), denydevs, ndeny);
- break;
- }
- }
}
-
- free(permdevs);
- free(denydevs);
}
/*
diff --git a/src/PointerDevice.cpp b/src/PointerDevice.cpp
index 603a7a2..a4629ae 100644
--- a/src/PointerDevice.cpp
+++ b/src/PointerDevice.cpp
@@ -5,6 +5,7 @@
#include "PointerDevice.h"
#include <X11/Xcursor/Xcursor.h>
+#include <stdlib.h>
int PointerDevice::XI_MotionNotify;
int PointerDevice::XI_ButtonPress;
diff --git a/src/WMWindow.cpp b/src/WMWindow.cpp
index 40749c4..597e4a9 100644
--- a/src/WMWindow.cpp
+++ b/src/WMWindow.cpp
@@ -30,7 +30,6 @@ WMWindow::WMWindow(Manager* manager, Window w, XConn* x11)
this->process = NULL;
this->state = 0;
this->overlay = NULL;
- this->fcgui = NULL;
this->minimized = false;
this->resizing = false;
this->clientOffset = Config::getInstance()->clientOffset;
@@ -94,8 +93,6 @@ WMWindow::~WMWindow()
XDestroyWindow(x11->dpy, container);
- if (fcgui)
- delete fcgui;
if (process != NULL)
process->removeWindow(this);
delete overlay;
@@ -112,8 +109,7 @@ bool WMWindow::hasWindow(Window window)
return (window == container || window == client || window == windowBar ||
window == btClose || window == btFloor || window == resizeBar ||
window == btOwner || window == btOverlay || window == btMinimize
- || isResizeButton(window) || overlay->hasWindow(window) ||
- ((fcgui != NULL) ? fcgui->hasWindow(window) : false));
+ || isResizeButton(window) || overlay->hasWindow(window));
}
bool WMWindow::isWindowBar(Window window)
@@ -159,12 +155,6 @@ bool WMWindow::isClientWindow(Window window)
}
-bool WMWindow::isFloorControlWindow(Window win)
-{
- return (fcgui) ? fcgui->hasWindow(win) : false;
-}
-
-
bool WMWindow::onPosition(int x, int y)
{
return (x >= this->x && x <= this->x + this->width && y >= this->y &&
@@ -594,43 +584,6 @@ void WMWindow::destroy()
TRACE("suggesting client window deletion\n");
}
-/**
- * Restrict a window to the given pointer. The window will then be locked to
- * the given device (using MPGXlib).
- * @return true on success, false if the window can't be restricted ATM.
- */
-bool WMWindow::restrictTo(PointerDevice* dev)
-{
- if (restrictedTo != NULL && dev != restrictedTo)
- return false;
- XID id = (XID)dev->getID();
-
- XChangeAccessRule(x11->dpy, client, WindowAccessDenyAll);
- XPermitDevices(x11->dpy, client, &id, 1);
-
- restrictedTo = dev;
- TRACE("Window %x locked to %s\n", (int)container, dev->getName().c_str());
- return true;
-}
-
-/**
- * Release any device-locks. The given device has to be the same as the one
- * the window is currently locked, otherwise nothing happens.
- * @param dev The device to unlock the window from.
- * @return true if unlock was successful, otherwise false;
- */
-bool WMWindow::release(PointerDevice* dev)
-{
-
- if (dev == restrictedTo)
- {
- XWindowClearAccess(x11->dpy, client, WindowAccessClearAll);
- restrictedTo = NULL;
- }
- return (restrictedTo == NULL);
-}
-
-
void WMWindow::raise()
{
XRaiseWindow(x11->dpy, container);
@@ -765,41 +718,6 @@ void WMWindow::handleOverlayPress(XDeviceButtonEvent* bev,
}
-/**
- * Toggles the floor control GUI windows.
- */
-void WMWindow::toggleFloorControl()
-{
- if (!fcgui)
- {
- fcgui = new FloorControl(manager, this, x11);
- fcgui->init();
- fcgui->display();
- } else
- {
- delete fcgui;
- fcgui = NULL;
- }
-
-}
-
-/**
- * EnterLeaveEvent occurs if the mouse enters one of the floor control GUI
- * elements.
- */
-void WMWindow::handleEnterLeaveNotify(XCrossingEvent* ev)
-{
- if (fcgui)
- fcgui->handleEnterLeave(ev);
-
-}
-
-void WMWindow::floorControlButtonPress(XDeviceButtonEvent* bev, PointerDevice* dev)
-{
- if (fcgui)
- fcgui->handleButtonPress(bev, dev);
-}
-
void WMWindow::setResizeInProgress(bool on)
{
if (on && !resizing)
diff --git a/src/WMWindow.h b/src/WMWindow.h
index 8f30a24..9ba8048 100644
--- a/src/WMWindow.h
+++ b/src/WMWindow.h
@@ -16,7 +16,6 @@
#include "Manager.h"
#include "Process.h"
#include "Overlay.h"
-#include "FloorControl.h"
#include "XConn.h"
#include <cairo.h>
@@ -26,7 +25,6 @@ class Manager;
class PointerDevice;
class Process;
class Overlay;
-class FloorControl;
/**
* Describes a top-level window. A window consists of a container (with the
@@ -83,7 +81,6 @@ class WMWindow
bool exception; // used to indicate a failed startup.
Overlay* overlay;
- FloorControl* fcgui;
private:
void paintWindowBar();