summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/screenshot.c
diff options
context:
space:
mode:
authormaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-07 08:25:24 +0000
committermaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-07 08:25:24 +0000
commitc91f93e407cbbc6205a4fe16ec97bf3348fd9b71 (patch)
tree285dff1e4ca112897d3da3e30058f75ec079783e /beryl-plugins/src/screenshot.c
parent355fd997ddf9a048149cf26661aa1b656c638378 (diff)
downloadmarex-dev-c91f93e407cbbc6205a4fe16ec97bf3348fd9b71.tar.gz
marex-dev-c91f93e407cbbc6205a4fe16ec97bf3348fd9b71.tar.bz2
screenshot plugin: fixed multiscreen and transparent cube drawing (closes #1214)
git-svn-id: file:///beryl/trunk@3758 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/screenshot.c')
-rw-r--r--beryl-plugins/src/screenshot.c107
1 files changed, 80 insertions, 27 deletions
diff --git a/beryl-plugins/src/screenshot.c b/beryl-plugins/src/screenshot.c
index 3f36ca6..e26f5b4 100644
--- a/beryl-plugins/src/screenshot.c
+++ b/beryl-plugins/src/screenshot.c
@@ -51,8 +51,12 @@ typedef struct _ShotDisplay
typedef struct _ShotScreen
{
PaintScreenProc paintScreen;
+ PaintTransformedScreenProc paintTransformedScreen;
int grabIndex;
+ Bool painted;
+ int x, y;
+
int x1, y1, x2, y2;
Bool grab;
} ShotScreen;
@@ -174,6 +178,52 @@ static int shotSort(const void *_a, const void *_b)
return al - bl;
}
+static void
+shotPaintOutline(CompScreen * s, const ScreenPaintAttrib * sa,
+ int output, Bool transformed)
+{
+ int x1 = 0, x2 = 0, y1 = 0, y2 = 0;
+
+ SHOT_SCREEN(s);
+
+ x1 = MIN(ss->x1, ss->x2);
+ y1 = MIN(ss->y1, ss->y2);
+ x2 = MAX(ss->x1, ss->x2);
+ y2 = MAX(ss->y1, ss->y2);
+
+ glPushMatrix();
+
+ if (transformed)
+ {
+ glLoadIdentity();
+ (s->applyScreenTransform) (s, sa, output);
+ }
+
+ prepareXCoords(s, output,
+ transformed ? -sa->zTranslate : -DEFAULT_Z_CAMERA);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnable(GL_BLEND);
+
+ glColor4us(0x2fff, 0x2fff, 0x4fff, 0x4fff);
+ glRecti(x1, y2, x2, y1);
+
+ /* This section draws the outline */
+ glColor4us(0x2fff, 0x2fff, 0x4fff, 0x9fff);
+ glLineWidth(2.0);
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(x1, y1);
+ glVertex2i(x2, y1);
+ glVertex2i(x2, y2);
+ glVertex2i(x1, y2);
+ glEnd();
+
+ /* Clean up */
+ glColor4usv(defaultColor);
+ glDisable(GL_BLEND);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glPopMatrix();
+}
+
static Bool
shotPaintScreen(CompScreen * s,
const ScreenPaintAttrib * sAttrib,
@@ -183,43 +233,29 @@ shotPaintScreen(CompScreen * s,
SHOT_SCREEN(s);
+ ss->painted = FALSE;
+ ss->x = s->x;
+ ss->y = s->y;
+
UNWRAP(ss, s, paintScreen);
status = (*s->paintScreen) (s, sAttrib, region, output, mask);
WRAP(ss, s, paintScreen, shotPaintScreen);
- if (status && ss->grab)
+ if (status && ss->grab && !ss->painted)
{
- int x1, x2, y1, y2;
-
- x1 = MIN(ss->x1, ss->x2);
- y1 = MIN(ss->y1, ss->y2);
- x2 = MAX(ss->x1, ss->x2);
- y2 = MAX(ss->y1, ss->y2);
-
if (ss->grabIndex)
{
- glPushMatrix();
-
- prepareXCoords(s, output, -DEFAULT_Z_CAMERA);
-
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_BLEND);
- glColor4us(0x2fff, 0x2fff, 0x4fff, 0x4fff);
- glRecti(x1, y2, x2, y1);
- glColor4us(0x2fff, 0x2fff, 0x4fff, 0x9fff);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x1, y1);
- glVertex2i(x2, y1);
- glVertex2i(x2, y2);
- glVertex2i(x1, y2);
- glEnd();
- glColor4usv(defaultColor);
- glDisable(GL_BLEND);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glPopMatrix();
+ shotPaintOutline(s, sAttrib, output, FALSE);
}
else
{
+ int x1, x2, y1, y2;
+
+ x1 = MIN(ss->x1, ss->x2);
+ y1 = MIN(ss->y1, ss->y2);
+ x2 = MAX(ss->x1, ss->x2);
+ y2 = MAX(ss->y1, ss->y2);
+
int w = x2 - x1;
int h = y2 - y1;
@@ -280,6 +316,21 @@ shotPaintScreen(CompScreen * s,
return status;
}
+static void
+shotPaintTransformedScreen(CompScreen * s, const ScreenPaintAttrib * sa,
+ Region region, int output, unsigned int mask)
+{
+ SHOT_SCREEN(s);
+
+ UNWRAP(ss, s, paintTransformedScreen);
+ (*s->paintTransformedScreen) (s, sa, region, output, mask);
+ WRAP(ss, s, paintTransformedScreen, shotPaintTransformedScreen);
+
+ if (ss->grab && ss->grabIndex && (ss->x == s->x) && (ss->y == s->y)) {
+ ss->painted = TRUE;
+ shotPaintOutline(s, sa, output, TRUE);
+ }
+}
static void shotHandleMotionEvent(CompScreen * s, int xRoot, int yRoot)
{
@@ -477,6 +528,7 @@ static Bool shotInitScreen(CompPlugin * p, CompScreen * s)
addScreenAction(s, &sd->opt[SHOT_DISPLAY_OPTION_INITIATE].value.action);
WRAP(ss, s, paintScreen, shotPaintScreen);
+ WRAP(ss, s, paintTransformedScreen, shotPaintTransformedScreen);
s->privates[sd->screenPrivateIndex].ptr = ss;
@@ -489,6 +541,7 @@ static void shotFiniScreen(CompPlugin * p, CompScreen * s)
SHOT_DISPLAY(s->display);
UNWRAP(ss, s, paintScreen);
+ UNWRAP(ss, s, paintTransformedScreen);
removeScreenAction(s,
&sd->opt[SHOT_DISPLAY_OPTION_INITIATE].value.action);