summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-12-27 13:26:58 +0100
committerDanny Baumann <dannybaumann@web.de>2008-12-27 13:26:58 +0100
commit537474d1aa5ba7fa41f7ec1251e17f175d3b73fd (patch)
tree1e683f3675bedf59a4ba9ca3c9316e3b85ce32a7
parent36a0cfc95281a2e1face87ac31fe7594690f9d4e (diff)
downloadextrawm-537474d1aa5ba7fa41f7ec1251e17f175d3b73fd.tar.gz
extrawm-537474d1aa5ba7fa41f7ec1251e17f175d3b73fd.tar.bz2
Added shortcut to move window to another (next, or arbitrary via dbus) output device.
-rw-r--r--extrawm.c105
-rw-r--r--extrawm.xml.in4
2 files changed, 109 insertions, 0 deletions
diff --git a/extrawm.c b/extrawm.c
index 8d4c721..4910326 100644
--- a/extrawm.c
+++ b/extrawm.c
@@ -144,6 +144,110 @@ activateDemandsAttention (CompDisplay *d,
}
static Bool
+sendToNextOutput (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed (option, nOption, "window", 0);
+ w = findWindowAtDisplay (d, xid);
+
+ if (w)
+ {
+ CompScreen *s = w->screen;
+ int outputNum, currentNum;
+ CompOutput *currentOutput, *newOutput;
+ int dx, dy;
+
+ currentNum = outputDeviceForWindow (w);
+ outputNum = getIntOptionNamed (option, nOption, "output",
+ (currentNum + 1) % s->nOutputDev);
+
+ if (outputNum >= s->nOutputDev)
+ return FALSE;
+
+ currentOutput = &s->outputDev[currentNum];
+ newOutput = &s->outputDev[outputNum];
+
+ /* move by the distance of the output center points */
+ dx = (newOutput->region.extents.x1 + newOutput->width / 2) -
+ (currentOutput->region.extents.x1 + currentOutput->width / 2);
+ dy = (newOutput->region.extents.y1 + newOutput->height / 2) -
+ (currentOutput->region.extents.y1 + currentOutput->height / 2);
+
+ if (dx || dy)
+ {
+ /* constrain to work area of new output and move */
+ CompWindowExtents newExtents;
+ XRectangle *workArea = &newOutput->workArea;
+ XWindowChanges xwc;
+ int width, height;
+ unsigned int mask = 0;
+
+ newExtents.left = w->serverX + dx - w->input.left;
+ newExtents.right = w->serverX + dx +
+ w->serverWidth + w->input.right;
+ newExtents.top = w->serverY + dy - w->input.top;
+ newExtents.bottom = w->serverY + dy +
+ w->serverHeight + w->input.bottom;
+
+ width = newExtents.right - newExtents.left;
+ height = newExtents.bottom - newExtents.top;
+
+ if (newExtents.left < workArea->x)
+ {
+ dx += workArea->x - newExtents.left;
+ }
+ else if (width <= workArea->width &&
+ newExtents.right > workArea->x + workArea->width)
+ {
+ dx += workArea->x + workArea->width - newExtents.right;
+ }
+
+ if (newExtents.top < workArea->y)
+ {
+ dy += workArea->y - newExtents.top;
+ }
+ else if (height <= workArea->height &&
+ newExtents.bottom > workArea->y + workArea->height)
+ {
+ dy += workArea->y + workArea->width - newExtents.right;
+ }
+
+ if (dx)
+ {
+ xwc.x = w->serverX + dx;
+ mask |= CWX;
+ }
+
+ if (dy)
+ {
+ xwc.y = w->serverY + dy;
+ mask |= CWY;
+ }
+
+ if (mask)
+ configureXWindow (w, mask, &xwc);
+
+ if (w->state & (MAXIMIZE_STATE | CompWindowStateFullscreenMask))
+ updateWindowAttributes (w, CompStackingUpdateModeNone);
+
+ /* make sure the window keeps focus */
+ if (d->activeWindow == w->id)
+ sendWindowActivationRequest (s, w->id);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static Bool
activateWin (CompDisplay *d,
CompAction *action,
CompActionState state,
@@ -358,6 +462,7 @@ extraWMInitDisplay (CompPlugin *p,
extrawmSetToggleFullscreenKeyInitiate (d, toggleFullscreen);
extrawmSetActivateInitiate (d, activateWin);
extrawmSetActivateDemandsAttentionKeyInitiate (d, activateDemandsAttention);
+ extrawmSetToNextOutputKeyInitiate (d, sendToNextOutput);
WRAP (ed, d, handleEvent, extraWMHandleEvent);
diff --git a/extrawm.xml.in b/extrawm.xml.in
index 7b7397e..20bc105 100644
--- a/extrawm.xml.in
+++ b/extrawm.xml.in
@@ -29,6 +29,10 @@
<_short>Activate Demanding Attention Window</_short>
<_long>Activate next window which has the "demands attention" flag set.</_long>
</option>
+ <option name="to_next_output_key" type="key">
+ <_short>Move Window To Next Output</_short>
+ <_long>Move the selected window to the next output device.</_long>
+ </option>
</display>
</plugin>
</compiz>