summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/miniview.c
diff options
context:
space:
mode:
authorracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-02 19:33:44 +0000
committerracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-02 19:33:44 +0000
commit39b78413d58b6808cd38bbea9033934d6657993b (patch)
tree4e578b52f286b7418f637fc34ce602c1401507c4 /beryl-plugins/src/miniview.c
parentd63695d5c0ee8d98e68fb876434e67bdb1481f2e (diff)
downloadmarex-dev-39b78413d58b6808cd38bbea9033934d6657993b.tar.gz
marex-dev-39b78413d58b6808cd38bbea9033934d6657993b.tar.bz2
Implement basic mouse movement for miniviews
git-svn-id: file:///beryl/trunk@3580 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/miniview.c')
-rw-r--r--beryl-plugins/src/miniview.c70
1 files changed, 68 insertions, 2 deletions
diff --git a/beryl-plugins/src/miniview.c b/beryl-plugins/src/miniview.c
index 0cf707c..460e52e 100644
--- a/beryl-plugins/src/miniview.c
+++ b/beryl-plugins/src/miniview.c
@@ -47,7 +47,7 @@ static int displayPrivateIndex;
typedef struct _MiniviewDisplay
{
int screenPrivateIndex;
-// HandleEventProc handleEvent;
+ HandleEventProc handleEvent;
CompOption opt[MINIVIEW_DISPLAY_OPTION_NUM];
} MiniviewDisplay;
@@ -56,6 +56,7 @@ typedef struct _MiniviewScreen
{
DonePaintScreenProc donePaintScreen;
PaintScreenProc paintScreen;
+ PreparePaintScreenProc preparePaintScreen;
PaintTransformedScreenProc paintTransformedScreen;
Bool showing;
@@ -67,6 +68,8 @@ typedef struct _MiniviewScreen
float size;
+ Bool moving;
+
} MiniviewScreen;
#define GET_MINIVIEW_DISPLAY(d) \
@@ -81,6 +84,39 @@ typedef struct _MiniviewScreen
#define NUM_OPTIONS(d) (sizeof ((d->opt)) / sizeof (CompOption))
+
+static void miniviewHandleEvent(CompDisplay * d, XEvent * event)
+{
+ MINIVIEW_DISPLAY(d);
+
+ CompScreen *s;
+ switch (event->type)
+ {
+ case ButtonPress:
+ s = findScreenAtDisplay(d, event->xbutton.root);
+ if (s)
+ {
+ MINIVIEW_SCREEN(s);
+ if ( (d->pointerX > (ms->miniX - 50)) && (d->pointerX < (ms->miniX + 50)))
+ {
+ if ( ( d->pointerY > (ms->miniY - 50)) && (d->pointerY < (ms->miniY + 50)))
+ {
+ ms->moving = !ms->moving;
+ damageScreen(s);
+ }
+ }
+ }
+ break;
+
+ break;
+ default:
+ break;
+ }
+ UNWRAP(md,d,handleEvent);
+ (*d->handleEvent)(d,event);
+ WRAP(md,d,handleEvent,miniviewHandleEvent);
+}
+
static Bool miniviewCreate(CompDisplay * d, CompAction * action,
CompActionState state, CompOption * option,
int nOption)
@@ -138,6 +174,28 @@ static Bool miniviewPaintScreen(CompScreen * s,
return status;
}
+static void miniviewPreparePaintScreen(CompScreen *s, int ICouldCareLess)
+{
+ 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);
+ ms->miniX = rootX;
+ ms->miniY = rootY;
+ }
+ UNWRAP(ms,s,preparePaintScreen);
+ (*s->preparePaintScreen) (s,ICouldCareLess);
+ WRAP(ms,s,preparePaintScreen,miniviewPreparePaintScreen);
+}
+
static void miniviewPaintTransformedScreen(CompScreen * s,
const ScreenPaintAttrib * sAttrib,
Region region, int output,
@@ -193,6 +251,8 @@ static void miniviewDonePaintScreen(CompScreen * s)
if (ms->showing)
damageScreen(s);
+
+
UNWRAP(ms, s, donePaintScreen);
(*s->donePaintScreen) (s);
@@ -302,6 +362,8 @@ static Bool miniviewInitDisplay(CompPlugin * p, CompDisplay * d)
}
miniviewDisplayInitOptions(md);
+
+ WRAP(md,d,handleEvent,miniviewHandleEvent);
d->privates[displayPrivateIndex].ptr = md;
return TRUE;
@@ -311,6 +373,8 @@ static void miniviewFiniDisplay(CompPlugin * p, CompDisplay * d)
{
MINIVIEW_DISPLAY(d);
+
+ UNWRAP(md,d,handleEvent);
freeScreenPrivateIndex(d, md->screenPrivateIndex);
free(md);
}
@@ -326,7 +390,7 @@ static Bool miniviewInitScreen(CompPlugin * p, CompScreen * s)
if (!ms)
return FALSE;
- ms->miniX = ms->miniY = ms->miniViewport = ms->showing = ms->zCam =
+ ms->moving = ms->miniX = ms->miniY = ms->miniViewport = ms->showing = ms->zCam =
ms->moveStep = 0;
ms->size = 3.0;
addScreenAction(s, &md->opt[MINIVIEW_DISPLAY_OPTION_CREATE].value.action);
@@ -335,6 +399,7 @@ static Bool miniviewInitScreen(CompPlugin * p, CompScreen * s)
WRAP(ms, s, paintScreen, miniviewPaintScreen);
WRAP(ms, s, donePaintScreen, miniviewDonePaintScreen);
WRAP(ms, s, paintTransformedScreen, miniviewPaintTransformedScreen);
+ WRAP(ms, s, preparePaintScreen, miniviewPreparePaintScreen);
s->privates[md->screenPrivateIndex].ptr = ms;
@@ -347,6 +412,7 @@ static void miniviewFiniScreen(CompPlugin * p, CompScreen * s)
UNWRAP(ms, s, paintScreen);
UNWRAP(ms, s, donePaintScreen);
UNWRAP(ms, s, paintTransformedScreen);
+ UNWRAP(ms, s, preparePaintScreen);
free(ms);
}