summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormraustin1337 <mraustin1337@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-17 12:43:27 +0000
committermraustin1337 <mraustin1337@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-17 12:43:27 +0000
commitc53ff45152ed3c74e199af6f5b199aab85965b99 (patch)
tree6c67b43d1ed8148b0697af3e046dc442d0010164
parent4ed5bd64e30a16ada10c78d4025b3694fc2b512f (diff)
downloadmarex-dev-c53ff45152ed3c74e199af6f5b199aab85965b99.tar.gz
marex-dev-c53ff45152ed3c74e199af6f5b199aab85965b99.tar.bz2
- Several major bug fixes
- Made miniview screens only drag with shift + click and mouse in the miniview. - Added a screengrab for moving the miniview. - General code cleanup including removal of some un-needed damages. git-svn-id: file:///beryl/trunk@4116 d7aaf104-2d23-0410-ae22-9d23157bf5a3
-rw-r--r--beryl-plugins/src/miniview.c112
1 files changed, 89 insertions, 23 deletions
diff --git a/beryl-plugins/src/miniview.c b/beryl-plugins/src/miniview.c
index c10195e..0371010 100644
--- a/beryl-plugins/src/miniview.c
+++ b/beryl-plugins/src/miniview.c
@@ -5,6 +5,7 @@
* miniview.c
*
* Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
+ * New Maintainer: Nicholas J, Krut <njkrut@pcsystemsinc.com> (MrAustin1337)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -16,6 +17,17 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
+ * Changes made (2/17/2007):
+ * - Several major bug fixes
+ * - Made miniview screens only drag with shift + click and mouse in the miniview.
+ * - Added a screengrab for moving the miniview.
+ * - General code cleanup including removal of some un-needed damages.
+ * TODO:
+ * - Move towards using windows instead of screens.
+ * - Transparent miniview.
+ * - Swap (like PiP on TVs)
+ * - Ideas?
+ * i C
**/
#include <stdio.h>
#include <stdlib.h>
@@ -52,7 +64,7 @@ static int displayPrivateIndex;
typedef struct _MiniviewDisplay
{
int screenPrivateIndex;
- HandleEventProc handleEvent;
+ HandleEventProc handleEvent;
CompOption opt[MINIVIEW_DISPLAY_OPTION_NUM];
} MiniviewDisplay;
@@ -67,11 +79,14 @@ typedef struct _MiniviewScreen
Bool showing;
int miniX;
int miniY;
+ int miniWidth;
+ int miniHeight;
int miniViewport;
int miniViewportY;
int moveStep;
float zCam;
+ int miniviewAtom;
float size;
@@ -79,7 +94,6 @@ typedef struct _MiniviewScreen
int grabIndex;
-
} MiniviewScreen;
#define GET_MINIVIEW_DISPLAY(d) \
@@ -99,9 +113,26 @@ static void miniviewHandleEvent(CompDisplay * d, XEvent * event)
{
MINIVIEW_DISPLAY(d);
+
CompScreen *s;
+
+
switch (event->type)
{
+ case ButtonRelease:
+ // Find the screen
+ s = findScreenAtDisplay(d, event->xkey.root);
+ MINIVIEW_SCREEN(s);
+
+ // If the screen is grabbed remove the grab on release:
+ if (ms->grabIndex != 0)
+ {
+ removeScreenGrab(s, ms->grabIndex, 0);
+ ms->grabIndex = 0;
+ ms->moving = FALSE;
+ }
+
+ break;
default:
break;
}
@@ -121,14 +152,18 @@ static Bool miniviewCreate(CompDisplay * d, CompAction * action,
s = findScreenAtDisplay(d, xid);
MINIVIEW_SCREEN(s);
ms->showing = !ms->showing;
- ms->miniViewport = s->x;
- ms->miniViewportY = s->y;
- ms->miniX = d->pointerX;
- ms->miniY = d->pointerY;
- ms->zCam = 0;
- ms->moveStep = 1;
- damageScreen(s);
- return FALSE;
+
+ if (ms->showing)
+ {
+ ms->miniViewport = s->x;
+ ms->miniViewportY = s->y;
+ ms->miniX = d->pointerX;
+ ms->miniY = d->pointerY;
+ ms->zCam = 0;
+ ms->moveStep = 1;
+ }
+
+ return TRUE;
}
static Bool miniviewMove(CompDisplay * d, CompAction * action,
@@ -137,12 +172,29 @@ static Bool miniviewMove(CompDisplay * d, CompAction * action,
{
CompScreen *s;
Window xid;
+ int winX, winY;
+ int rootX, rootY;
+ unsigned int mask_return;
+ Window root_return;
+ Window child_return;
xid = getIntOptionNamed(option, nOption, "root", 0);
s = findScreenAtDisplay(d, xid);
MINIVIEW_SCREEN(s);
- ms->moving = !ms->moving;
- damageScreen(s);
+
+ XQueryPointer(d->display, s->root,
+ &root_return, &child_return,
+ &rootX, &rootY, &winX, &winY, &mask_return);
+
+ // Check to see if the click is on the miniview:
+
+ if ((ms->miniX + (ms->miniWidth / 2)) > rootX && (ms->miniX - (ms->miniWidth / 2)) < rootX && // If the pointer is in theX
+ (ms->miniY + (ms->miniHeight / 2)) > rootY && (ms->miniY - (ms->miniHeight / 2)) < rootY) // and the pointer is in the Y
+ {
+ // Attach the grab index
+ ms->grabIndex = pushScreenGrab(s, s->invisibleCursor, "miniview");
+ ms->moving = !ms->moving;
+ }
return FALSE;
@@ -174,6 +226,7 @@ static Bool miniviewPaintScreen(CompScreen * s,
Bool status;
MINIVIEW_SCREEN(s);
+
if (ms->showing)
{
mask |= PAINT_SCREEN_TRANSFORMED_MASK;
@@ -187,22 +240,24 @@ static Bool miniviewPaintScreen(CompScreen * s,
static void miniviewPreparePaintScreen(CompScreen *s, int ICouldCareLess)
{
+ Window xid;
+ int winX, winY;
+ int rootX, rootY;
+ int myWidth, myHeight;
+ unsigned int mask_return;
+ Window root_return;
+ Window child_return;
+
MINIVIEW_SCREEN(s);
+
if ((ms->moving && ms->showing))
{
- int winX, winY;
- int rootX, rootY;
- unsigned int mask_return;
- Window root_return;
- Window child_return;
-
XQueryPointer(s->display->display, s->root,
&root_return, &child_return,
&rootX, &rootY, &winX, &winY, &mask_return);
-
+ // Place the miniview:
ms->miniX = rootX;
ms->miniY = rootY;
-
}
UNWRAP(ms,s,preparePaintScreen);
(*s->preparePaintScreen) (s,ICouldCareLess);
@@ -218,8 +273,9 @@ static void miniviewPaintTransformedScreen(CompScreen * s,
MINIVIEW_SCREEN(s);
UNWRAP(ms, s, paintTransformedScreen);
+
(*s->paintTransformedScreen) (s, sAttrib, transform, region, output, mask);
- if (ms->showing )
+ if (ms->showing && !otherScreenGrabExist(s, "miniview", 0))
{
//mask &= PAINT_SCREEN_TRANSFORMED_MASK;
int oldFilter = s->display->textureFilter;
@@ -227,10 +283,11 @@ static void miniviewPaintTransformedScreen(CompScreen * s,
if (ms->zCam > -ms->size)
ms->zCam -= .075;
-
+
CompTransform sTransform = *transform;
ScreenPaintAttrib * sa = sAttrib;
+
matrixScale(&sTransform, 1.0f,1.0f,1.0f*-ms->zCam);
matrixTranslate(&sTransform, -1.0,1.0,0);
@@ -245,20 +302,25 @@ static void miniviewPaintTransformedScreen(CompScreen * s,
matrixTranslate(&sTransform, (1/((float)s->width/(float)ms->miniX)*-ms->zCam),
(-1/((float)s->height/(float)ms->miniY)*-ms->zCam),
0);
+
+
int move = 0;
int ymove = 0;
+
while (s->x != ms->miniViewport)
{
moveScreenViewport(s, 1, 0, FALSE);
move++;
}
- while (s->y != ms->miniViewport)
+ while (s->y != ms->miniViewportY)
{
moveScreenViewport(s,0,1,FALSE);
ymove++;
}
+
(*s->paintTransformedScreen) (s, sa, &sTransform, &s->region, output, mask);
+
s->display->textureFilter = oldFilter;
moveScreenViewport(s,-move,-ymove,FALSE);
@@ -439,6 +501,10 @@ static Bool miniviewInitScreen(CompPlugin * p, CompScreen * s)
ms->grabIndex = ms->moving = ms->miniX = ms->miniY = ms->miniViewport = ms->showing = ms->zCam =
ms->moveStep = 0;
ms->size = 3.0;
+ ms->miniWidth = s->width * (1 / ms->size);
+ ms->miniHeight = s->height * (1 / ms->size);
+ ms->miniviewAtom = IPCS_GetAtom(IPCS_OBJECT(s), IPCS_BOOL, "IS_MINIVIEW_PAINT", TRUE);
+
addScreenAction(s, &md->opt[MINIVIEW_DISPLAY_OPTION_CREATE].value.action);
addScreenAction(s, &md->opt[MINIVIEW_DISPLAY_OPTION_MOVE].value.action);
addScreenAction(s, &md->opt[MINIVIEW_DISPLAY_OPTION_HIDE].value.action);