summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-03-15 21:01:13 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-03-15 21:01:13 +1030
commit949a17768d1bed6486d221bf835f2dcfd04ed0f4 (patch)
tree83ec5ef22da941cde937446530e5e086a83eccf2 /src
parent058d8adbbea00e30218a79287b89915a91d5165d (diff)
o Try a bit of optimizing on window resizes to make it slightly faster.
Diffstat (limited to 'src')
-rw-r--r--src/Manager.cpp22
-rw-r--r--src/WMWindow.cpp26
2 files changed, 32 insertions, 16 deletions
diff --git a/src/Manager.cpp b/src/Manager.cpp
index 7f504dc..b743e7e 100644
--- a/src/Manager.cpp
+++ b/src/Manager.cpp
@@ -545,8 +545,26 @@ void Manager::handleMotionEvent(XDeviceMotionEvent* mev)
if (dev->isDragging())
dev->dragTo(mev->x_root, mev->y_root);
+ // Resizing is slow. We check if there are other events in the queue cos
+ // if there are, we don't resize.
if (dev->isResizing())
- dev->resizeTo(mev->x_root, mev->y_root);
+ {
+ XDeviceMotionEvent ev;
+ if (!XCheckTypedEvent(x11->dpy,
+ PointerDevice::XI_MotionNotify,
+ (XEvent*) &ev))
+ {
+ if (mev->deviceid == ev.deviceid && mev->state == ev.state)
+ {
+ // skip
+ } else
+ {
+ XPutBackEvent(x11->dpy, (XEvent*)&ev);
+ dev->resizeTo(mev->x_root, mev->y_root);
+ }
+ } else
+ dev->resizeTo(mev->x_root, mev->y_root);
+ }
WMWindow* win = xyToWMWindow(mev->x_root, mev->y_root);
@@ -753,7 +771,7 @@ bool Manager::hasShapeExtension()
*/
void Manager::paintBackground(XExposeEvent* ev)
{
- XCopyArea(x11->dpy, pxBackground, x11->root, root_gc, ev->x, ev->y,
+ XCopyArea(x11->dpy, pxBackground, x11->root, root_gc, ev->x, ev->y,
ev->width, ev->height, ev->x, ev->y);
}
diff --git a/src/WMWindow.cpp b/src/WMWindow.cpp
index daca5fd..cc4d422 100644
--- a/src/WMWindow.cpp
+++ b/src/WMWindow.cpp
@@ -202,10 +202,6 @@ void WMWindow::decorate()
TRACE(" - container %x\n", (unsigned int)container);
- resizeWin = XCreateSimpleWindow(x11->dpy, container, clientOffset,
- Config::getInstance()->windowBarHeight, totalWidth, height, 0, 0,
- x11->white);
-
windowBar = XCreateWindow(x11->dpy, container, 0, 0, totalWidth,
Config::getInstance()->windowBarHeight, 0, 0, InputOnly,
x11->vis, 0, &attr);
@@ -281,7 +277,6 @@ void WMWindow::decorate()
Config::getInstance()->resizeButtonHeight,
0, 0, InputOnly, x11->vis, 0, &attr);
- paintWindowBar();
overlay = new Overlay(manager, this, x11);
@@ -299,6 +294,7 @@ void WMWindow::decorate()
XMapWindow(x11->dpy, resizeBtNE);
XMapWindow(x11->dpy, resizeBtSW);
XMapWindow(x11->dpy, resizeBtNW);
+ paintWindowBar();
XFlush(x11->dpy);
}
@@ -488,6 +484,7 @@ void WMWindow::resizeDirected(Window button, int x, int y)
void WMWindow::resize(int width, int height)
{
resizeAbsolute(-1, -1, width, height);
+ paintWindowBar();
}
/**
@@ -507,9 +504,6 @@ void WMWindow::resizeAbsolute(int posx, int posy, int w, int h)
if (!resizing)
XConfigureWindow(x11->dpy, client, mask, &wc);
- else
- XConfigureWindow(x11->dpy, resizeWin, mask, &wc);
-
wc.width = width + clientOffset * 2;
wc.height = height + Config::getInstance()->windowBarHeight +
@@ -582,7 +576,6 @@ void WMWindow::resizeAbsolute(int posx, int posy, int w, int h)
overlay->resize(width, height);
TRACE(" - resized client %x\n", (unsigned int)client);
- paintWindowBar();
}
void WMWindow::destroy()
@@ -712,6 +705,7 @@ void WMWindow::recolor()
void WMWindow::expose(XExposeEvent* ev)
{
+ if (!resizing)
XCopyArea(x11->dpy, pxContainer, container, containerGC,
ev->x, ev->y, ev->width, ev->height, ev->x, ev->y);
}
@@ -811,17 +805,21 @@ void WMWindow::setResizeInProgress(bool on)
{
if (on && !resizing)
{
-
- XResizeWindow(x11->dpy, resizeWin, width, height);
- XMapRaised(x11->dpy, resizeWin);
XUnmapWindow(x11->dpy, client);
+ XSetWindowAttributes attr;
+ attr.background_pixel = x11->black;
+ XChangeWindowAttributes(x11->dpy, container, CWBackPixel, &attr);
resizing = true;
} else if (!on && resizing)
{
- XUnmapWindow(x11->dpy, resizeWin);
XResizeWindow(x11->dpy, client, width, height);
XMapWindow(x11->dpy, client);
resizing = false;
+ paintWindowBar();
+ XCopyArea(x11->dpy, pxContainer, container, containerGC,
+ 0, 0, width + clientOffset * 2, height +
+ Config::getInstance()->windowBarHeight +
+ Config::getInstance()->resizeBarHeight, 0, 0);
}
}
@@ -838,7 +836,7 @@ void WMWindow::paintWindowBar()
if (pxContainer)
XFreePixmap(x11->dpy, pxContainer);
pxContainer =
- XCreatePixmap(x11->dpy, container, totalWidth, totalHeight, x11->depth);
+ XCreatePixmap(x11->dpy, container, totalWidth, totalHeight, x11->depth);
cr_sf = cairo_xlib_surface_create(x11->dpy, pxContainer, x11->vis,
totalWidth, totalHeight);