summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Kostiuk <d@myhost.localdomain>2011-07-24 16:27:18 +0300
committerDmitriy Kostiuk <d@myhost.localdomain>2011-07-24 16:27:18 +0300
commit8864ef854936e5e2c9ff2def48f778d74fde0e51 (patch)
tree31b208a75cfa144f0abf19075f8dcdb3ff5d32dd
parent30e174a0eeba1b0e0132690963155db4d17236f3 (diff)
downloaddock-master.tar.gz
dock-master.tar.bz2
update on groupingHEADmaster
-rw-r--r--dock.xml.in4
-rw-r--r--src/dock.cpp161
-rw-r--r--src/dock.h11
-rw-r--r--src/ipw.cpp27
4 files changed, 177 insertions, 26 deletions
diff --git a/dock.xml.in b/dock.xml.in
index 273affc..9691dc6 100644
--- a/dock.xml.in
+++ b/dock.xml.in
@@ -25,6 +25,10 @@
<_short>Toggle docked state</_short>
<default>&lt;Super&gt;t</default>
</option>
+ <option name="group_key" type="key">
+ <_short>Toggle grouped state</_short>
+ <default>&lt;Super&gt;g</default>
+ </option>
</group>
<group>
<_short>Behaviour</_short>
diff --git a/src/dock.cpp b/src/dock.cpp
index ec4000e..cce223a 100644
--- a/src/dock.cpp
+++ b/src/dock.cpp
@@ -20,7 +20,9 @@ DockWindow::DockWindow (CompWindow *window) :
cWindow (CompositeWindow::get (window)),
gWindow (GLWindow::get (window)),
window (window),
- ipw (NULL)
+ ipw (NULL),
+ grouped_l (false),
+ grouped_r (false)
{
WindowInterface::setHandler (window, false);
CompositeWindowInterface::setHandler (cWindow, false);
@@ -75,6 +77,7 @@ DockScreen::DockScreen (CompScreen *screen) :
/* control bindings */
optionSetToggleKeyInitiate(boost::bind(&DockScreen::toggleDock, this, _1, _2, _3));
+ optionSetGroupKeyInitiate(boost::bind(&DockScreen::groupDock, this, _1, _2, _3));
/* load backgrounds */
CompString pname ("dock");
@@ -90,11 +93,18 @@ DockScreen::DockScreen (CompScreen *screen) :
centerTex = GLTexture::readImageToTexture (fname_center, pname, imgSizeCenter);
rightTex = GLTexture::readImageToTexture (fname_right, pname, imgSizeRight);
+// if (!grabIndex) grabIndex = screen->pushGrab (None, "dock");
+
}
DockScreen::~DockScreen () {
if (moveCursor)
XFreeCursor(screen->dpy(), moveCursor);
+
+ if (grabIndex) {
+ screen->removeGrab (grabIndex, NULL);
+ grabIndex = 0;
+ }
}
bool
@@ -106,20 +116,26 @@ DockWindow::dock(int docked_size) {
docked = true;
toggleHandlers(true);
- int max_dim = window->height() > window->width() ?
- window->height() : window->width();
+ //int max_dim = window->height() > window->width() ?
+ // window->height() : window->width();
// TODO: check for max_dim != 0
- wScale = docked_size / (float)max_dim;
+ int max_dim = window->height();
+ //float additional_space_factor = 1.9;
+ //wScale = docked_size / (float)max_dim / additional_space_factor;
+
+ wScale = (docked_size - docked_size*0.3) / (float) max_dim;
move_dx = move_dy = 0;
/* create the IPW */
if (ipw) delete ipw;
ipw = new IPWindow(window);
-
+ // ipw->syncIPW();
/* damage the window */
cWindow->addDamage();
-
+ char ccc[90];
+ sprintf(ccc,"DockWindow::dock - window %ld, ipw %ld",window,ipw);
+ compLogMessage ("dock", CompLogLevelWarn, ccc);
return true;
}
@@ -173,6 +189,39 @@ DockWindow::isDocked() const {
}
bool
+DockScreen::groupDock(CompAction *action, CompAction::State state,
+ CompOption::Vector options) {
+ CompWindow *w = screen->findWindow(screen->activeWindow());
+ if (!w)
+ return true;
+
+ //DOCK_WINDOW(w);
+ //setWindowDocked(sw, !sw->isDocked());
+ //sw->grouped=sw->grouped?false:true;
+
+ std::list<DockWindow*>::iterator it;
+ CompWindow *prev_w = NULL, *cur_w = NULL;
+ DockWindow * sw;
+ for (it = dockedWindows.begin(); it != dockedWindows.end(); it++) {
+ prev_w = cur_w;
+ cur_w = (*it)->window;
+ if (cur_w == w) {// toggling grouping on the left
+ if (prev_w)
+ { sw = DockWindow::get (prev_w);
+ sw->grouped_r=sw->grouped_r?false:true;
+ sw->cWindow->addDamage();
+ }
+ sw = DockWindow::get (cur_w);
+ sw->grouped_l=sw->grouped_l?false:true;
+ sw->cWindow->addDamage();
+ }
+ }
+ sw->cWindow->addDamage();
+
+ return true;
+}
+
+bool
DockScreen::toggleDock(CompAction *action, CompAction::State state,
CompOption::Vector options) {
CompWindow *w = screen->findWindow(screen->activeWindow());
@@ -250,37 +299,83 @@ DockScreen::refreshDock(DockWindow *w) {
dockedWindows.insert(it, w);
}
}
+/*
+CompWindow *
+DockScreen::findRealWindowID (Window wid) {
+ CompWindow *orig;
+
+ orig = screen->findWindow (wid);
+ if (!orig)
+ return NULL;
+
+ return DockWindow::get (orig)->getRealWindow ();
+}*/
+
+/* Checks if w is a ipw and returns the real window */
+/*CompWindow *
+DockWindow::getRealWindow ()
+{
+ WindowInfo *run;
+ SHELF_SCREEN (screen);
+
+ foreach (run, ss->shelfedWindows)
+ {
+ if (window->id () == run->ipw)
+ return run->w;
+ }
+
+ return NULL;
+}*/
void
DockScreen::handleEvent(XEvent *ev) {
CompWindow *w;
-
+//compLogMessage ("dock", CompLogLevelWarn, "event");
switch (ev->type) {
case EnterNotify:
if ((w = IPW2OverridenWin(ev->xcrossing.window))) {
+ compLogMessage ("dock", CompLogLevelWarn, "enter");
XEvent e;
memcpy(&e.xcrossing, &ev->xcrossing, sizeof(XCrossingEvent));
e.xcrossing.window = w->frame() ? w->frame() : w->id();
XSendEvent(screen->dpy(), w->id(), false, EnterWindowMask, &e);
+ if (!grabIndex) grabIndex = screen->pushGrab (None, "dock");
+ }
+ break;
+ case LeaveNotify:
+ if ((w = IPW2OverridenWin(ev->xcrossing.window))) {
+ compLogMessage ("dock", CompLogLevelWarn, "leave");
+ XEvent e;
+ memcpy(&e.xcrossing, &ev->xcrossing, sizeof(XCrossingEvent));
+ e.xcrossing.window = w->frame() ? w->frame() : w->id();
+ XSendEvent(screen->dpy(), w->id(), false, LeaveWindowMask, &e);
+ if (grabIndex) {
+ screen->removeGrab (grabIndex, NULL);
+ grabIndex = 0;
+ }
}
break;
-
case MotionNotify:
+ compLogMessage ("dock", CompLogLevelWarn, "motion");
if (grabIndex && (w = screen->findWindow(grabbedWindow))) {
int dx = ev->xmotion.x_root - motion_lastx;
int dy = ev->xmotion.y_root - motion_lasty;
DockWindow::get(w)->dockMove(dx, dy);
-
motion_lastx += dx;
motion_lasty += dy;
}
break;
case ButtonPress:
+ compLogMessage ("dock", CompLogLevelWarn, "press");
+
+
+
if ((w = IPW2OverridenWin(ev->xbutton.window))) {
+ compLogMessage ("dock", CompLogLevelWarn, "press ipw");
if (!screen->otherGrabExist("dock", 0)) {
w->activate();
grabbedWindow = w->id();
@@ -292,11 +387,25 @@ DockScreen::handleEvent(XEvent *ev) {
break;
case ButtonRelease:
-
+ compLogMessage ("dock", CompLogLevelWarn, "release");
+ //CompWindow *highlightedWindow = getHoveredWindow ();
+ //w = screen->findWindow (wid);
+ //CompWindow *w;
+ w = screen->findWindow (ev->xbutton.window);
+ char ccc[50];
+ sprintf(ccc,"ButtonRelease: release window is %ld",w);
+ compLogMessage ("dock", CompLogLevelWarn, ccc);
+ if ((w = IPW2OverridenWin(ev->xcrossing.window))) {
+ //char ccc[50];
+ sprintf(ccc,"ButtonRelease: window x is %d",w->inputRect().x());
+ compLogMessage ("dock", CompLogLevelWarn, ccc);
+ sprintf(ccc,"ButtonRelease: current x is %d",ev->xbutton.x_root);
+ compLogMessage ("dock", CompLogLevelWarn, ccc); }
if ((w = screen->findWindow(grabbedWindow))) {
// TODO:
// Need to get mose x,y coordinate and put them to refreshDock();
- refreshDock(DockWindow::get(w));
+
+ refreshDock(DockWindow::get(w));
setWindowDocked(DockWindow::get(w), true);
adjustDocked();
grabbedWindow = None;
@@ -357,14 +466,19 @@ DockWindow::glPaint(const GLWindowPaintAttrib &attrib,
GLTexture* tex;
int tex_width;
tx = window->input().left * (wScale - 1.0);
+ //tx = window->x()*wScale;
ty = window->input().top * (wScale - 1.0);
// paint tile
// left part:
- //tex=ss->leftTex[0]; tex_width=tex->width(); //for non-grouped
- tex=ss->centerTex[0]; tex_width=ss->dock_spacing/2.0; //for grouped
- { GLTexture::MatrixList matl;
+ if (grouped_l) {
+ tex=ss->centerTex[0]; tex_width=ceilf(ss->dock_spacing/2.0); //for grouped
+ } else {
+ tex=ss->leftTex[0]; tex_width=tex->width(); //for non-grouped
+ }
+
+ if(1){ GLTexture::MatrixList matl;
CompRegion texReg(0, 0, tex_width, ss->docking_size*1.2);
gWindow->geometry ().reset ();
matl.push_back (tex->matrix ());
@@ -420,9 +534,13 @@ DockWindow::glPaint(const GLWindowPaintAttrib &attrib,
}
}
//right part
- //tex=ss->rightTex[0]; // for non-grouped
- tex=ss->centerTex[0]; // for grouped
- { GLTexture::MatrixList matl;
+
+ if (grouped_r) {
+ tex=ss->centerTex[0]; tex_width=floorf(ss->dock_spacing/2.0);// for grouped
+ } else {
+ tex=ss->rightTex[0]; tex_width=tex->width();// for non-grouped
+ }
+ if(1) { GLTexture::MatrixList matl;
CompRegion texReg(0, 0, tex_width, ss->docking_size*1.2);
gWindow->geometry ().reset ();
matl.push_back (tex->matrix ());
@@ -436,7 +554,7 @@ DockWindow::glPaint(const GLWindowPaintAttrib &attrib,
fragment = GLFragment::Attrib (sAttrib);
wTransform.translate(window->x(), window->y(), 0.0);
- wTransform.translate (tx+tex_width+window->width()*wScale,
+ wTransform.translate (floorf(tx+tex_width+window->width()*wScale),
-ss->dock_spacing*1.7, 0.0);
mask |= PAINT_WINDOW_BLEND_MASK;
@@ -450,10 +568,13 @@ DockWindow::glPaint(const GLWindowPaintAttrib &attrib,
// paint mini-window
GLMatrix mTrans = transform;
- mTrans.translate(window->x()+ss->dock_spacing/1.5, window->y()+ss->docking_size*0.15, 0.0);
+ mTrans.translate(window->x()/*+ss->dock_spacing/1.5*/, window->y()+ss->docking_size*0.15, 0.0);
+
mTrans.scale(wScale, wScale, 1.0);
- mTrans.translate(tx / wScale - window->x(),
+ mTrans.translate((tx+tex_width)/wScale/*tx / wScale*/- window->x(),
ty / wScale - window->y(), 0.0);
+
+
mask |= PAINT_WINDOW_TRANSFORMED_MASK;
status = gWindow->glPaint(attrib, mTrans, region, mask);
diff --git a/src/dock.h b/src/dock.h
index 80b0246..52a4cfa 100644
--- a/src/dock.h
+++ b/src/dock.h
@@ -39,7 +39,7 @@
#include "dock_options.h"
#include "ipw.h"
-#define DOCKING_SIZE 150.0 // pixel size of docked windows
+#define DOCKING_SIZE 151.0 // pixel size of docked windows
#define DOCK_SCREEN(s) \
DockScreen *ss = DockScreen::get (s)
@@ -74,7 +74,7 @@ class DockWindow :
float wScale;
bool docked;
-
+ bool grouped_l, grouped_r;
/* undo vector */
int move_dx, move_dy;
@@ -86,7 +86,7 @@ class DockWindow :
/* wraped handlers */
bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
const CompRegion &, unsigned int);
-
+ //CompWindow * getRealWindow ();
};
class DockScreen :
@@ -130,6 +130,9 @@ class DockScreen :
bool toggleDock(CompAction *action, CompAction::State state,
CompOption::Vector options);
+
+ bool groupDock(CompAction *action, CompAction::State state,
+ CompOption::Vector options);
void toggleHandlers(bool state);
@@ -138,6 +141,8 @@ class DockScreen :
bool glPaintOutput (const GLScreenPaintAttrib &, const GLMatrix &,
const CompRegion &, CompOutput *, unsigned int);
+
+ //CompWindow * findRealWindowID (Window wid);
private:
diff --git a/src/ipw.cpp b/src/ipw.cpp
index 03478e6..09dbabc 100644
--- a/src/ipw.cpp
+++ b/src/ipw.cpp
@@ -56,8 +56,13 @@ void IPWindow::syncIPW() {
xwc.stack_mode = Below;
xwc.sibling = overridenWin;
+ char ccc[50];
+ sprintf(ccc,"syncIPW: overridenWin is %ld",overridenWin);
+ compLogMessage ("dock", CompLogLevelWarn, ccc);
+
XConfigureWindow(screen->dpy(), ipwWin,
CWSibling | CWStackMode | CWX | CWY | CWWidth | CWHeight, &xwc);
+ // XMapWindow (screen->dpy(), ipwWin);
}
@@ -77,6 +82,15 @@ IPWindow::IPWindow(CompWindow *cw) : compWin(cw) {
0, CopyFromParent, InputOnly, CopyFromParent,
CWEventMask | CWOverrideRedirect, &attrib);
+// ipwWin = XCreateWindow (screen->dpy(), screen->root(),
+// cw->serverX - cw->input.left,
+// cw->serverY - cw->input.top,
+// cw->serverWidth + cw->input.left + cw->input.right,
+// cw->serverHeight + cw->input.top + cw->input.bottom,
+// 0, CopyFromParent, InputOnly, CopyFromParent,
+// CWEventMask | CWOverrideRedirect,
+// &attrib);
+
XMapWindow(screen->dpy(), ipwWin);
/* put the IPW over the real window */
syncIPW();
@@ -90,17 +104,24 @@ IPWindow::~IPWindow() {
-CompWindow *IPW2OverridenWin(Window ipw) {
+CompWindow *IPW2OverridenWin(Window win) {
DOCK_SCREEN(screen);
std::list<DockWindow *>::iterator it;
+ char ccc[50];
+ sprintf(ccc,"IPW2Over: win is %ld",win);
+ compLogMessage ("dock", CompLogLevelWarn, ccc);
+
for (it = ss->dockedWindows.begin();
it != ss->dockedWindows.end(); it++)
- if ((*it)->ipw && (*it)->ipw->ipwWin == ipw)
+ { sprintf(ccc,"IPW2Over: dockedWin is %ld",(*it)->window);
+ compLogMessage ("dock", CompLogLevelWarn, ccc);
+ if ( ((*it)->ipw) && ((*it)->ipw->overridenWin/*ipwWin*/ == win) )
return (*it)->window;
-
+ }
/* not an IPW window */
return NULL;
}
+//DockWindow::dock - window 21968176, ipw 26791920