summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--beryl-core/include/beryl-decoration.h11
-rw-r--r--beryl-core/libberyldecoration/main.c44
-rw-r--r--beryl-plugins/configure.ac1
-rw-r--r--beryl-plugins/src/Makefile.am3
-rw-r--r--beryl-plugins/src/decoration.c277
-rw-r--r--distro-specific-build-files/beryl-plugins/debian/control2
-rw-r--r--distro-specific-build-files/emerald/debian/control2
-rw-r--r--emerald/configure.ac2
-rw-r--r--emerald/include/emerald.h52
-rw-r--r--emerald/src/Makefile.am2
-rw-r--r--emerald/src/main.c364
11 files changed, 179 insertions, 581 deletions
diff --git a/beryl-core/include/beryl-decoration.h b/beryl-core/include/beryl-decoration.h
index 4772175..c1ad6b8 100644
--- a/beryl-core/include/beryl-decoration.h
+++ b/beryl-core/include/beryl-decoration.h
@@ -26,7 +26,7 @@
#ifndef _DECORATION_H
#define _DECORATION_H
-#define DECOR_INTERFACE_VERSION 0
+#define DECOR_INTERFACE_VERSION 20061011
#include <string.h>
#include <limits.h>
@@ -179,6 +179,15 @@ decor_property_to_quads (long *data,
int *min_height,
decor_quad_t *quad);
+void
+decor_apply_gravity (int gravity,
+ int x,
+ int y,
+ int width,
+ int height,
+ int *return_x,
+ int *return_y);
+
int
decor_set_vert_quad_row (decor_quad_t *q,
int top,
diff --git a/beryl-core/libberyldecoration/main.c b/beryl-core/libberyldecoration/main.c
index 47956c0..d9e507d 100644
--- a/beryl-core/libberyldecoration/main.c
+++ b/beryl-core/libberyldecoration/main.c
@@ -202,6 +202,50 @@ decor_property_to_quads (long *data,
return n;
}
+void
+decor_apply_gravity (int gravity,
+ int x,
+ int y,
+ int width,
+ int height,
+ int *return_x,
+ int *return_y)
+{
+ if (gravity & GRAVITY_EAST)
+ {
+ x += width;
+ *return_x = MAX (0, x);
+ }
+ else if (gravity & GRAVITY_WEST)
+ {
+ *return_x = MIN (width, x);
+ }
+ else
+ {
+ x += width / 2;
+ x = MAX (0, x);
+ x = MIN (width, x);
+ *return_x = x;
+ }
+
+ if (gravity & GRAVITY_SOUTH)
+ {
+ y += height;
+ *return_y = MAX (0, y);
+ }
+ else if (gravity & GRAVITY_NORTH)
+ {
+ *return_y = MIN (height, y);
+ }
+ else
+ {
+ y += height / 2;
+ y = MAX (0, y);
+ y = MIN (height, y);
+ *return_y = y;
+ }
+}
+
int
decor_set_vert_quad_row (decor_quad_t *q,
int top,
diff --git a/beryl-plugins/configure.ac b/beryl-plugins/configure.ac
index 9de116b..8b3ac6b 100644
--- a/beryl-plugins/configure.ac
+++ b/beryl-plugins/configure.ac
@@ -93,6 +93,7 @@ AC_MSG_NOTICE([Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH])
PKG_CHECK_MODULES(BERYL, beryl)
PKG_CHECK_MODULES(BERYLSETTINGS, berylsettings)
+PKG_CHECK_MODULES(LIBBERYLDECORATION, libberyldecoration)
AC_MSG_CHECKING(for GL_CFLAGS)
AC_ARG_WITH(gl-cflags, [ --with-gl-cflags=CFLAGS ],
diff --git a/beryl-plugins/src/Makefile.am b/beryl-plugins/src/Makefile.am
index 0b98f78..b457c2f 100644
--- a/beryl-plugins/src/Makefile.am
+++ b/beryl-plugins/src/Makefile.am
@@ -20,7 +20,6 @@ libpng_la_SOURCES = png.c
libsvg_la_LDFLAGS = $(PFLAGS)
libsvg_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@ @LIBRSVG_LIBS@
libsvg_la_SOURCES = svg.c
-
if JPEG_PLUGIN
libimgjpeg_la_LDFLAGS = $(PFLAGS)
@@ -122,7 +121,7 @@ libresize_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@
libresize_la_SOURCES = resize.c
libdecoration_la_LDFLAGS = $(PFLAGS)
-libdecoration_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@
+libdecoration_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@ @LIBBERYLDECORATION_LIBS@
libdecoration_la_SOURCES = decoration.c
libswitcher_la_LDFLAGS = $(PFLAGS)
diff --git a/beryl-plugins/src/decoration.c b/beryl-plugins/src/decoration.c
index e578e00..d3bbbcf 100644
--- a/beryl-plugins/src/decoration.c
+++ b/beryl-plugins/src/decoration.c
@@ -33,34 +33,10 @@
#include <X11/extensions/shape.h>
#include <beryl.h>
+#include <beryl-decoration.h>
#define BERYL_ADVANCED_DECORATION_VERSION 10121980
-#define GRAVITY_WEST (1 << 0)
-#define GRAVITY_EAST (1 << 1)
-#define GRAVITY_NORTH (1 << 2)
-#define GRAVITY_SOUTH (1 << 3)
-
-#define ALIGN_LEFT (0)
-#define ALIGN_RIGHT (1 << 0)
-#define ALIGN_TOP (0)
-#define ALIGN_BOTTOM (1 << 1)
-
-#define CLAMP_HORZ (1 << 0)
-#define CLAMP_VERT (1 << 1)
-
-#define XX_MASK (1 << 12)
-#define XY_MASK (1 << 13)
-#define YX_MASK (1 << 14)
-#define YY_MASK (1 << 15)
-
-typedef struct _Point
-{
- int x;
- int y;
- int gravity;
-} Point;
-
typedef struct _Vector
{
int dx;
@@ -69,17 +45,6 @@ typedef struct _Vector
int y0;
} Vector;
-typedef struct _Quad
-{
- Point p1;
- Point p2;
- int maxWidth;
- int maxHeight;
- int align;
- int clamp;
- CompMatrix m;
-} Quad;
-
#define DECOR_BARE 0
#define DECOR_NORMAL 1
#define DECOR_ACTIVE 2
@@ -103,10 +68,8 @@ typedef struct _Decoration
CompWindowExtents maxInput;
int minWidth;
int minHeight;
- unsigned short activeOpacity;
- unsigned short inactiveOpacity;
long flags;
- Quad *quad;
+ decor_quad_t *quad;
int nQuad;
} Decoration;
@@ -350,10 +313,6 @@ decorSetDisplayOption(CompDisplay * display,
return FALSE;
}
-static void setDecorationMatrices(CompWindow * w);
-static void destroyWindowDecoration(CompScreen * screen,
- WindowDecoration * wd);
-
static Bool
decorDrawWindow(CompWindow * w,
const WindowPaintAttrib * attrib,
@@ -409,14 +368,6 @@ decorDrawWindow(CompWindow * w,
sAttrib.brightness = BRIGHT;
}
- int opacity = sAttrib.opacity;
-
- opacity *= (w->screen->display->activeWindow == w->id) ?
- wd->decor->activeOpacity : wd->decor->inactiveOpacity;
- opacity /= 0xffff;
-
- sAttrib.opacity = opacity;
-
if (w->vCount)
{
(*w->screen->drawWindowTexture) (w,
@@ -530,47 +481,7 @@ static void decorReleaseTexture(CompScreen * screen, DecorTexture * texture)
}
static void
-applyGravity(int gravity,
- int x,
- int y, int width, int height, int *return_x, int *return_y)
-{
- if (gravity & GRAVITY_EAST)
- {
- x += width;
- *return_x = MAX(0, x);
- }
- else if (gravity & GRAVITY_WEST)
- {
- *return_x = MIN(width, x);
- }
- else
- {
- x += width / 2;
- x = MAX(0, x);
- x = MIN(width, x);
- *return_x = x;
- }
-
- if (gravity & GRAVITY_SOUTH)
- {
- y += height;
- *return_y = MAX(0, y);
- }
- else if (gravity & GRAVITY_NORTH)
- {
- *return_y = MIN(height, y);
- }
- else
- {
- y += height / 2;
- y = MAX(0, y);
- y = MIN(height, y);
- *return_y = y;
- }
-}
-
-static void
-computeQuadBox(Quad * q,
+computeQuadBox(decor_quad_t * q,
int width,
int height,
int *return_x1,
@@ -584,14 +495,14 @@ computeQuadBox(Quad * q,
sx = 1;
sy = 1;
- applyGravity(q->p1.gravity, q->p1.x, q->p1.y, width, height, &x1, &y1);
- applyGravity(q->p2.gravity, q->p2.x, q->p2.y, width, height, &x2, &y2);
+ decor_apply_gravity(q->p1.gravity, q->p1.x, q->p1.y, width, height, &x1, &y1);
+ decor_apply_gravity(q->p2.gravity, q->p2.x, q->p2.y, width, height, &x2, &y2);
if (q->clamp & CLAMP_HORZ)
{
if (x2 - x1 > 0 && (q->clamp & CLAMP_VERT) &&
q->p1.x == 0 && q->p2.x == 0)
- sx = (double)q->maxWidth / ((double)x2 - (double)x1);
+ sx = (double)q->max_width / ((double)x2 - (double)x1);
if ((q->p1.x == 0 && q->p2.x == 0) || !(q->clamp & CLAMP_VERT))
{
if (x1 < 0)
@@ -605,7 +516,7 @@ computeQuadBox(Quad * q,
{
if (y2 - y1 > 0 && (q->clamp & CLAMP_HORZ) &&
q->p1.y == 0 && q->p2.y == 0)
- sy = (double)q->maxHeight / ((double)y2 - (double)y1);
+ sy = (double)q->max_height / ((double)y2 - (double)y1);
if ((q->p1.y == 0 && q->p2.y == 0) || !(q->clamp & CLAMP_HORZ))
{
if (y1 < 0)
@@ -615,22 +526,22 @@ computeQuadBox(Quad * q,
}
}
- if (q->maxWidth < x2 - x1
+ if (q->max_width < x2 - x1
&& !(q->clamp & CLAMP_VERT && q->clamp & CLAMP_HORZ))
{
if (q->align & ALIGN_RIGHT)
- x1 = x2 - q->maxWidth;
+ x1 = x2 - q->max_width;
else
- x2 = x1 + q->maxWidth;
+ x2 = x1 + q->max_width;
}
- if (q->maxHeight < y2 - y1
+ if (q->max_height < y2 - y1
&& !(q->clamp & CLAMP_VERT && q->clamp & CLAMP_HORZ))
{
if (q->align & ALIGN_BOTTOM)
- y1 = y2 - q->maxHeight;
+ y1 = y2 - q->max_height;
else
- y2 = y1 + q->maxHeight;
+ y2 = y1 + q->max_height;
}
*return_x1 = x1;
@@ -643,49 +554,6 @@ computeQuadBox(Quad * q,
*return_sy = sy;
}
-/*
- decoration property
- -------------------
-
- data[0] = version
-
- data[1] = pixmap
-
- data[2] = input left
- data[3] = input right
- data[4] = input top
- data[5] = input bottom
-
- data[6] = input left when maximized
- data[7] = input right when maximized
- data[8] = input top when maximized
- data[9] = input bottom when maximized
-
- data[10] = min width
- data[11] = min height
-
- BERYL_ADVANCED_DECORATION_VERSION
-
- data[12] = differnt features flags
- data[13] = active opacity
- data[14] = inactive opacity
-
- flags
-
- 1st to 4nd bit p1 gravity, 5rd to 8th bit p2 gravity,
- 9rd and 10th bit alignment, 11rd and 12th bit clamp,
- 13th bit XX, 14th bit XY, 15th bit YX, 16th bit YY.
-
- data[11 + n * 9 + 1] = flags
- data[11 + n * 9 + 2] = p1 x
- data[11 + n * 9 + 3] = p1 y
- data[11 + n * 9 + 4] = p2 x
- data[11 + n * 9 + 5] = p2 y
- data[11 + n * 9 + 6] = widthMax
- data[11 + n * 9 + 7] = heightMax
- data[11 + n * 9 + 8] = x0
- data[11 + n * 9 + 9] = y0
- */
static Decoration *decorCreateDecoration(CompScreen * screen, Window id,
Atom decorAtom)
{
@@ -696,12 +564,14 @@ static Decoration *decorCreateDecoration(CompScreen * screen, Window id,
unsigned char *data;
long *prop;
Pixmap pixmap;
- Quad *quad;
- int nQuad, head;
+ decor_extents_t input;
+ decor_extents_t maxInput;
+ decor_quad_t *quad;
+ int nQuad;
+ int minWidth, minHeight;
int left, right, top, bottom;
int x1, y1, x2, y2;
- int flags;
- long version;
+ double sx, sy;
result = XGetWindowProperty(screen->display->display, id,
decorAtom, 0L, 1024L, FALSE,
@@ -711,71 +581,56 @@ static Decoration *decorCreateDecoration(CompScreen * screen, Window id,
if (result != Success || !n || !data)
return NULL;
- if (n < 12 + 9)
+ prop = (long*) data;
+
+ if (decor_property_get_version(prop) != decor_version())
{
+ fprintf (stderr, "%s: decoration: property ignored because "
+ "version is %d and decoration plugin version is %d\n",
+ getProgramName(), decor_property_get_version (prop),
+ decor_version ());
+
XFree(data);
return NULL;
}
- decoration = malloc(sizeof(Decoration));
- if (!decoration)
+ nQuad = (n - BASE_PROP_SIZE) / QUAD_PROP_SIZE;
+
+ quad = malloc(sizeof(decor_quad_t) * nQuad);
+ if (!quad)
{
XFree(data);
return NULL;
}
- prop = (long *)data;
- version = *prop++;
+ nQuad = decor_property_to_quads(prop, n, &pixmap, &input, &maxInput,
+ &minWidth, &minHeight, quad);
- memcpy(&pixmap, prop++, sizeof(Pixmap));
-
- decoration->input.left = *prop++;
- decoration->input.right = *prop++;
- decoration->input.top = *prop++;
- decoration->input.bottom = *prop++;
-
- decoration->maxInput.left = *prop++;
- decoration->maxInput.right = *prop++;
- decoration->maxInput.top = *prop++;
- decoration->maxInput.bottom = *prop++;
-
- decoration->minWidth = *prop++;
- decoration->minHeight = *prop++;
+ XFree(data);
- if (version == BERYL_ADVANCED_DECORATION_VERSION)
- {
- decoration->flags = *prop++;
- decoration->activeOpacity = *prop++;
- decoration->inactiveOpacity = *prop++;
- head = 15;
- }
- else
+ if (!nQuad)
{
- decoration->flags = 0;
- decoration->activeOpacity = 0xffff;
- decoration->inactiveOpacity = 0xffff;
- head = 12;
+ free(quad);
+ return NULL;
}
- decoration->texture = decorGetTexture(screen, pixmap);
- if (!decoration->texture)
+ decoration = malloc(sizeof(Decoration));
+ if (!decoration)
{
- free(decoration);
- XFree(data);
+ free(quad);
return NULL;
}
- nQuad = (n - head) / 9;
-
- quad = malloc(sizeof(Quad) * nQuad);
- if (!quad)
+ decoration->texture = decorGetTexture(screen, pixmap);
+ if (!decoration->texture)
{
- decorReleaseTexture(screen, decoration->texture);
free(decoration);
- XFree(data);
+ free(quad);
return NULL;
}
+ decoration->minWidth = minWidth;
+ decoration->minHeight = minHeight;
decoration->quad = quad;
decoration->nQuad = nQuad;
@@ -786,32 +641,7 @@ static Decoration *decorCreateDecoration(CompScreen * screen, Window id,
while (nQuad--)
{
- flags = *prop++;
-
- quad->p1.gravity = (flags >> 0) & 0xf;
- quad->p2.gravity = (flags >> 4) & 0xf;
-
- quad->align = (flags >> 8) & 0x3;
- quad->clamp = (flags >> 10) & 0x3;
-
- quad->m.xx = (flags & XX_MASK) ? 1.0f : 0.0f;
- quad->m.xy = (flags & XY_MASK) ? 1.0f : 0.0f;
- quad->m.yx = (flags & YX_MASK) ? 1.0f : 0.0f;
- quad->m.yy = (flags & YY_MASK) ? 1.0f : 0.0f;
-
- quad->p1.x = *prop++;
- quad->p1.y = *prop++;
- quad->p2.x = *prop++;
- quad->p2.y = *prop++;
-
- quad->maxWidth = *prop++;
- quad->maxHeight = *prop++;
-
- quad->m.x0 = *prop++;
- quad->m.y0 = *prop++;
-
- computeQuadBox(quad, decoration->minWidth, decoration->minHeight,
- &x1, &y1, &x2, &y2, NULL, NULL);
+ computeQuadBox(quad, minWidth, minHeight, &x1, &y1, &x2, &y2, &sx, &sy);
if (x1 < left)
left = x1;
@@ -825,7 +655,15 @@ static Decoration *decorCreateDecoration(CompScreen * screen, Window id,
quad++;
}
- XFree(data);
+ decoration->input.left = input.left;
+ decoration->input.right = input.right;
+ decoration->input.top = input.top;
+ decoration->input.bottom = input.bottom;
+
+ decoration->maxInput.left = maxInput.left;
+ decoration->maxInput.right = maxInput.right;
+ decoration->maxInput.top = maxInput.top;
+ decoration->maxInput.bottom = maxInput.bottom;
decoration->output.left = -left;
decoration->output.right = right - decoration->minWidth;
@@ -904,15 +742,16 @@ static void setDecorationMatrices(CompWindow * w)
for (i = 0; i < wd->nQuad; i++)
{
- CompMatrix a, b;
+ decor_matrix_t a;
+ CompMatrix b;
wd->quad[i].matrix = wd->decor->texture->texture.matrix;
x0 = wd->decor->quad[i].m.x0;
y0 = wd->decor->quad[i].m.y0;
- b = wd->quad[i].matrix;
a = wd->decor->quad[i].m;
+ b = wd->quad[i].matrix;
wd->quad[i].matrix.xx = a.xx * b.xx + a.yx * b.xy;
wd->quad[i].matrix.yx = a.xx * b.yx + a.yx * b.yy;
diff --git a/distro-specific-build-files/beryl-plugins/debian/control b/distro-specific-build-files/beryl-plugins/debian/control
index 8827652..ea841fa 100644
--- a/distro-specific-build-files/beryl-plugins/debian/control
+++ b/distro-specific-build-files/beryl-plugins/debian/control
@@ -8,7 +8,7 @@ Standards-Version: 3.7.2
Package: beryl-plugins
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, beryl-plugins-data, beryl-core
+Depends: ${shlibs:Depends}, ${misc:Depends}, beryl-plugins-data, beryl-core, libberyldecoration0
Recommends: beryl-settings
Description: Collection of plugins for Beryl
The Beryl Project brings 3D desktop visual effects that improve
diff --git a/distro-specific-build-files/emerald/debian/control b/distro-specific-build-files/emerald/debian/control
index 07beedb..8c48dd8 100644
--- a/distro-specific-build-files/emerald/debian/control
+++ b/distro-specific-build-files/emerald/debian/control
@@ -8,7 +8,7 @@ Standards-Version: 3.7.2
Package: emerald
Architecture: any
-Depends: beryl-plugins, libemeraldengine0
+Depends: beryl-plugins, libemeraldengine0, libberyldecoration0
Conflicts: gcompizthemer, cgwd
Replaces: gcompizthemer, cgwd
Provides: gcompizthemer, cgwd
diff --git a/emerald/configure.ac b/emerald/configure.ac
index 830c2f1..057de7f 100644
--- a/emerald/configure.ac
+++ b/emerald/configure.ac
@@ -41,6 +41,8 @@ AC_SUBST(PKG_CONFIG_PATH)
AC_MSG_NOTICE([Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH])
PKG_CHECK_MODULES(EMERALD, $EMERALD_REQUIRES)
+PKG_CHECK_MODULES(LIBBERYLDECORATION, libberyldecoration)
+
AC_SUBST(EMERALD_REQUIRES)
CFLAGS="$CFLAGS $EMERALD_CFLAGS"
LIBS="$LIBS $EMERALD_LIBS"
diff --git a/emerald/include/emerald.h b/emerald/include/emerald.h
index c827e25..f749ea8 100644
--- a/emerald/include/emerald.h
+++ b/emerald/include/emerald.h
@@ -4,6 +4,8 @@
#include <config.h>
#endif
+#include <beryl/beryl-decoration.h>
+
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
@@ -57,34 +59,8 @@
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
-
-typedef struct _extents {
- gint left;
- gint right;
- gint top;
- gint bottom;
-} extents;
-
#define FAKE_WINDOW_ACTION_HELP (1 << 20)
-#define GRAVITY_WEST (1 << 0)
-#define GRAVITY_EAST (1 << 1)
-#define GRAVITY_NORTH (1 << 2)
-#define GRAVITY_SOUTH (1 << 3)
-
-#define ALIGN_LEFT (0)
-#define ALIGN_RIGHT (1 << 0)
-#define ALIGN_TOP (0)
-#define ALIGN_BOTTOM (1 << 1)
-
-#define CLAMP_HORZ (1 << 0)
-#define CLAMP_VERT (1 << 1)
-
-#define XX_MASK (1 << 12)
-#define XY_MASK (1 << 13)
-#define YX_MASK (1 << 14)
-#define YY_MASK (1 << 15)
-
#define WM_MOVERESIZE_SIZE_TOPLEFT 0
#define WM_MOVERESIZE_SIZE_TOP 1
#define WM_MOVERESIZE_SIZE_TOPRIGHT 2
@@ -105,24 +81,6 @@ typedef struct _extents {
#define SHADOW_OFFSET_X 1
#define SHADOW_OFFSET_Y 1
-#define N_QUADS_MAX 24
-
-typedef struct _point {
- gint x;
- gint y;
- gint gravity;
-} point;
-
-typedef struct _quad {
- point p1;
- point p2;
- gint max_width;
- gint max_height;
- gint align;
- gint clamp;
- cairo_matrix_t m;
-} quad;
-
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_DECOR_ALL (1L << 0)
@@ -215,8 +173,8 @@ typedef struct _window_settings
gint shadow_color[3];
gint shadow_offset_x;
gint shadow_offset_y;
- extents shadow_extents;// = { 0, 0, 0, 0 };
- extents win_extents;// = { 6, 6, 4, 6 };
+ decor_extents_t shadow_extents;// = { 0, 0, 0, 0 };
+ decor_extents_t win_extents;// = { 6, 6, 4, 6 };
pos_t pos[3][3];
gint left_space;// = 6;
gint right_space;// = 6;
@@ -255,7 +213,7 @@ typedef struct _window_settings
PangoFontDescription *font_desc;
PangoContext * pango_context;
- extents switcher_extents;// = { 0, 0, 0, 0 };
+ decor_extents_t switcher_extents;// = { 0, 0, 0, 0 };
GdkPixmap *switcher_pixmap;// = NULL;
GdkPixmap *switcher_buffer_pixmap;// = NULL;
gint switcher_width;
diff --git a/emerald/src/Makefile.am b/emerald/src/Makefile.am
index cfb7c36..cb3286b 100644
--- a/emerald/src/Makefile.am
+++ b/emerald/src/Makefile.am
@@ -1,5 +1,5 @@
## Process this file with automake to produce Makefile.in
-emerald_LDADD = @EMERALD_LIBS@ $(top_builddir)/libengine/libemeraldengine.la
+emerald_LDADD = @EMERALD_LIBS@ @LIBBERYLDECORATION_LIBS@ $(top_builddir)/libengine/libemeraldengine.la
emerald_SOURCES = main.c \
engine_loader.c
emerald_program = emerald
diff --git a/emerald/src/main.c b/emerald/src/main.c
index 0143d46..77fb0a5 100644
--- a/emerald/src/main.c
+++ b/emerald/src/main.c
@@ -143,44 +143,6 @@ static guint draw_idle_id = 0;
static gboolean enable_tooltips = TRUE;
static gchar *engine = NULL;
-/*
- decoration property
- -------------------
-
- data[0] = version
-
- data[1] = pixmap
-
- data[2] = input left
- data[3] = input right
- data[4] = input top
- data[5] = input bottom
-
- data[6] = input left when maximized
- data[7] = input right when maximized
- data[8] = input top when maximized
- data[9] = input bottom when maximized
-
- data[10] = min width
- data[11] = min height
-
- flags
-
- 1st to 4nd bit p1 gravity, 5rd to 8th bit p2 gravity,
- 9rd and 10th bit alignment, 11rd and 12th bit clamp,
- 13th bit XX, 14th bit XY, 15th bit YX, 16th bit YY.
-
- data[11 + n * 9 + 1] = flags
- data[11 + n * 9 + 2] = p1 x
- data[11 + n * 9 + 3] = p1 y
- data[11 + n * 9 + 4] = p2 x
- data[11 + n * 9 + 5] = p2 y
- data[11 + n * 9 + 6] = widthMax
- data[11 + n * 9 + 7] = heightMax
- data[11 + n * 9 + 8] = x0
- data[11 + n * 9 + 9] = y0
- */
-
static gint get_b_offset(gint b_t)
{
static int boffset[B_COUNT];
@@ -283,197 +245,8 @@ static void update_window_extents(window_settings * ws)
};
memcpy(ws->pos, newpos, sizeof(pos_t) * 9);
}
-static void
-decoration_to_property(long *data,
- Pixmap pixmap,
- extents * input,
- extents * maxinput,
- int min_width, int min_height, quad * quad, int nQuad)
-{
- *data++ = DECOR_INTERFACE_VERSION;
-
- memcpy(data++, &pixmap, sizeof(Pixmap));
-
- *data++ = input->left;
- *data++ = input->right;
- *data++ = input->top;
- *data++ = input->bottom;
-
- *data++ = maxinput->left;
- *data++ = maxinput->right;
- *data++ = maxinput->top;
- *data++ = maxinput->bottom;
-
- *data++ = min_width;
- *data++ = min_height;
-
- while (nQuad--)
- {
- *data++ =
- (quad->p1.gravity << 0) |
- (quad->p2.gravity << 4) |
- (quad->align << 8) |
- (quad->clamp << 10) |
- (quad->m.xx ? XX_MASK : 0) |
- (quad->m.xy ? XY_MASK : 0) |
- (quad->m.yx ? YX_MASK : 0) | (quad->m.yy ? YY_MASK : 0);
-
- *data++ = quad->p1.x;
- *data++ = quad->p1.y;
- *data++ = quad->p2.x;
- *data++ = quad->p2.y;
- *data++ = quad->max_width;
- *data++ = quad->max_height;
- *data++ = quad->m.x0;
- *data++ = quad->m.y0;
-
- quad++;
- }
-}
-
-static gint
-set_horz_quad_line(quad * q,
- int left,
- int left_corner,
- int right,
- int right_corner,
- int top,
- int bottom, int gravity, int width, double x0, double y0)
-{
- gint dx;
-
- dx = (left_corner - right_corner) >> 1;
-
- q->p1.x = -left;
- q->p1.y = top; // opt: never changes
- q->p1.gravity = gravity | GRAVITY_WEST;
- q->p2.x = dx;
- q->p2.y = bottom; // opt: never changes
- q->p2.gravity = gravity;
- q->max_width = left + left_corner;
- q->max_height = SHRT_MAX; // opt: never changes
- q->align = ALIGN_LEFT;
- q->clamp = 0; // opt: never changes
- q->m.xx = 1.0;
- q->m.xy = 0.0; // opt: never changes
- q->m.yx = 0.0; // opt: never changes
- q->m.yy = 1.0; // opt: never changes
- q->m.x0 = x0;
- q->m.y0 = y0; // opt: never changes
-
- q++;
-
- q->p1.x = left_corner;
- q->p1.y = top;
- q->p1.gravity = gravity | GRAVITY_WEST;
- q->p2.x = -right_corner;
- q->p2.y = bottom;
- q->p2.gravity = gravity | GRAVITY_EAST;
- q->max_width = SHRT_MAX;
- q->max_height = SHRT_MAX;
- q->align = 0;
- q->clamp = 0;
- q->m.xx = 0.0;
- q->m.xy = 0.0;
- q->m.yx = 0.0;
- q->m.yy = 1.0;
- q->m.x0 = x0 + left + left_corner;
- q->m.y0 = y0;
-
- q++;
-
- q->p1.x = dx;
- q->p1.y = top;
- q->p1.gravity = gravity;
- q->p2.x = right;
- q->p2.y = bottom;
- q->p2.gravity = gravity | GRAVITY_EAST;
- q->max_width = right_corner + right;
- q->max_height = SHRT_MAX;
- q->align = ALIGN_RIGHT;
- q->clamp = 0;
- q->m.xx = 1.0;
- q->m.xy = 0.0;
- q->m.yx = 0.0;
- q->m.yy = 1.0;
- q->m.x0 = x0 + width;
- q->m.y0 = y0;
-
- return 3;
-}
-
-static gint
-set_vert_quad_row(quad * q,
- int top,
- int top_corner,
- int bottom,
- int bottom_corner,
- int left,
- int right, int gravity, int height, double x0, double y0)
-{
- gint dy;
-
- dy = (top_corner - bottom_corner) >> 1;
-
- q->p1.x = left; // opt: never changes
- q->p1.y = -top;
- q->p1.gravity = gravity | GRAVITY_NORTH;
- q->p2.x = right; // opt: never changes
- q->p2.y = dy;
- q->p2.gravity = gravity;
- q->max_width = SHRT_MAX; // opt: never changes
- q->max_height = top + top_corner;
- q->align = ALIGN_TOP;
- q->clamp = CLAMP_VERT; // opt: never changes
- q->m.xx = 1.0; // opt: never changes
- q->m.xy = 0.0; // opt: never changes
- q->m.yx = 0.0; // opt: never changes
- q->m.yy = 1.0;
- q->m.x0 = x0; // opt: never changes
- q->m.y0 = y0;
-
- q++;
-
- q->p1.x = left;
- q->p1.y = top_corner;
- q->p1.gravity = gravity | GRAVITY_NORTH;
- q->p2.x = right;
- q->p2.y = -bottom_corner;
- q->p2.gravity = gravity | GRAVITY_SOUTH;
- q->max_width = SHRT_MAX;
- q->max_height = SHRT_MAX;
- q->align = 0;
- q->clamp = CLAMP_VERT;
- q->m.xx = 1.0;
- q->m.xy = 0.0;
- q->m.yx = 0.0;
- q->m.yy = 0.0;
- q->m.x0 = x0;
- q->m.y0 = y0 + top + top_corner;
-
- q++;
-
- q->p1.x = left;
- q->p1.y = dy;
- q->p1.gravity = gravity;
- q->p2.x = right;
- q->p2.y = bottom;
- q->p2.gravity = gravity | GRAVITY_SOUTH;
- q->max_width = SHRT_MAX;
- q->max_height = bottom_corner + bottom;
- q->align = ALIGN_BOTTOM;
- q->clamp = CLAMP_VERT;
- q->m.xx = 1.0;
- q->m.xy = 0.0;
- q->m.yx = 0.0;
- q->m.yy = 1.0;
- q->m.x0 = x0;
- q->m.y0 = y0 + height;
-
- return 3;
-}
-static int my_add_quad_row(quad * q,
+static int my_add_quad_row(decor_quad_t * q,
int width,
int left,
int right, int ypush, int vgrav, int x0, int y0)
@@ -540,7 +313,7 @@ static int my_add_quad_row(quad * q,
return 3;
}
-static int my_add_quad_col(quad * q,
+static int my_add_quad_col(decor_quad_t * q,
int height, int xpush, int hgrav, int x0, int y0)
{
int p1x = (hgrav == GRAVITY_WEST) ? -xpush : 0;
@@ -566,7 +339,7 @@ static int my_add_quad_col(quad * q,
return 1;
}
static int
-my_set_window_quads(quad * q,
+my_set_window_quads(decor_quad_t * q,
int width,
int height,
window_settings * ws,
@@ -676,10 +449,10 @@ static void decor_update_window_property(decor_t * d)
long data[256];
Display *xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
window_settings *ws = d->fs->ws;
- extents maxextents;
- extents extents = ws->win_extents;
+ decor_extents_t maxextents;
+ decor_extents_t extents = ws->win_extents;
gint nQuad;
- quad quads[N_QUADS_MAX];
+ decor_quad_t quads[N_QUADS_MAX];
gboolean hm = False;
gboolean vm = False;
@@ -699,7 +472,7 @@ static void decor_update_window_property(decor_t * d)
else
maxextents = extents;
- decoration_to_property(data, GDK_PIXMAP_XID(d->pixmap),
+ decor_quads_to_property(data, GDK_PIXMAP_XID(d->pixmap),
&extents, &maxextents, 0, 0, quads, nQuad);
gdk_error_trap_push();
@@ -713,7 +486,7 @@ static void decor_update_window_property(decor_t * d)
}
static int
-set_switcher_quads(quad * q, int width, int height, window_settings * ws)
+set_switcher_quads(decor_quad_t * q, int width, int height, window_settings * ws)
{
gint n, nQuad = 0;
@@ -739,33 +512,23 @@ set_switcher_quads(quad * q, int width, int height, window_settings * ws)
nQuad++;
/* left quads */
- n = set_vert_quad_row(q,
- 0,
- ws->switcher_top_corner_space,
- 0,
- ws->bottom_corner_space,
- -ws->left_space,
- 0,
- GRAVITY_WEST,
- height - ws->top_space - ws->titlebar_height -
- ws->bottom_space, 0.0,
- ws->top_space + SWITCHER_TOP_EXTRA);
+ n = decor_set_vert_quad_row(q,
+ 0, ws->switcher_top_corner_space, 0, ws->bottom_corner_space,
+ -ws->left_space, 0, GRAVITY_WEST,
+ height - ws->top_space - ws->titlebar_height - ws->bottom_space,
+ (ws->switcher_top_corner_space - ws->switcher_bottom_corner_space) >> 1,
+ 0, 0.0, ws->top_space + SWITCHER_TOP_EXTRA, FALSE);
q += n;
nQuad += n;
/* right quads */
- n = set_vert_quad_row(q,
- 0,
- ws->switcher_top_corner_space,
- 0,
- ws->switcher_bottom_corner_space,
- 0,
- ws->right_space,
- GRAVITY_EAST,
- height - ws->top_space - ws->titlebar_height -
- ws->bottom_space, width - ws->right_space,
- ws->top_space + SWITCHER_TOP_EXTRA);
+ n = decor_set_vert_quad_row(q,
+ 0, ws->switcher_top_corner_space, 0, ws->switcher_bottom_corner_space,
+ 0, ws->right_space, GRAVITY_EAST,
+ height - ws->top_space - ws->titlebar_height - ws->bottom_space,
+ (ws->switcher_top_corner_space - ws->switcher_bottom_corner_space) >> 1,
+ 0, width - ws->right_space, ws->top_space + SWITCHER_TOP_EXTRA, FALSE);
q += n;
nQuad += n;
@@ -798,13 +561,13 @@ static void decor_update_switcher_property(decor_t * d)
long data[256];
Display *xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
gint nQuad;
- quad quads[N_QUADS_MAX];
+ decor_quad_t quads[N_QUADS_MAX];
window_settings *ws = d->fs->ws;
- extents extents = ws->switcher_extents;
+ decor_extents_t extents = ws->switcher_extents;
nQuad = set_switcher_quads(quads, d->width, d->height, ws);
- decoration_to_property(data, GDK_PIXMAP_XID(d->pixmap),
+ decor_quads_to_property(data, GDK_PIXMAP_XID(d->pixmap),
&extents, &extents, 0, 0, quads, nQuad);
gdk_error_trap_push();
@@ -818,68 +581,51 @@ static void decor_update_switcher_property(decor_t * d)
}
static int
-set_shadow_quads(quad * q, gint width, gint height, window_settings * ws)
+set_shadow_quads(decor_quad_t * q, gint width, gint height, window_settings * ws)
{
gint n, nQuad = 0;
/* top quads */
- n = set_horz_quad_line(q,
- ws->shadow_left_space,
- ws->shadow_left_corner_space,
- ws->shadow_right_space,
- ws->shadow_right_corner_space,
- -ws->shadow_top_space,
- 0, GRAVITY_NORTH, width, 0.0, 0.0);
+ n = decor_set_horz_quad_line(q,
+ ws->shadow_left_space, ws->shadow_left_corner_space,
+ ws->shadow_right_space, ws->shadow_right_corner_space,
+ -ws->shadow_top_space, 0, GRAVITY_NORTH, width,
+ (ws->shadow_left_corner_space - ws->shadow_right_corner_space) >> 1,
+ 0, 0.0, 0.0);
q += n;
nQuad += n;
/* left quads */
- n = set_vert_quad_row(q,
- 0,
- ws->shadow_top_corner_space,
- 0,
- ws->shadow_bottom_corner_space,
- -ws->shadow_left_space,
- 0,
- GRAVITY_WEST,
- height - ws->shadow_top_space -
- ws->shadow_bottom_space, 0.0, ws->shadow_top_space);
+ n = decor_set_vert_quad_row(q,
+ 0, ws->shadow_top_corner_space, 0, ws->shadow_bottom_corner_space,
+ -ws->shadow_left_space, 0, GRAVITY_WEST,
+ (ws->shadow_top_corner_space - ws->shadow_bottom_corner_space) >> 1,
+ 0, height - ws->shadow_top_space - ws->shadow_bottom_space,
+ 0.0, ws->shadow_top_space, FALSE);
q += n;
nQuad += n;
/* right quads */
- n = set_vert_quad_row(q,
- 0,
- ws->shadow_top_corner_space,
- 0,
- ws->shadow_bottom_corner_space,
- 0,
- ws->shadow_right_space,
- GRAVITY_EAST,
- height - ws->shadow_top_space -
- ws->shadow_bottom_space,
- width - ws->shadow_right_space,
- ws->shadow_top_space);
+ n = decor_set_vert_quad_row(q,
+ 0, ws->shadow_top_corner_space, 0, ws->shadow_bottom_corner_space, 0,
+ ws->shadow_right_space, GRAVITY_EAST,
+ (ws->shadow_top_corner_space - ws->shadow_bottom_corner_space) >> 1,
+ 0, height - ws->shadow_top_space - ws->shadow_bottom_space,
+ width - ws->shadow_right_space, ws->shadow_top_space, FALSE);
q += n;
nQuad += n;
/* bottom quads */
- n = set_horz_quad_line(q,
- ws->shadow_left_space,
- ws->shadow_left_corner_space,
- ws->shadow_right_space,
- ws->shadow_right_corner_space,
- 0,
- ws->shadow_bottom_space,
- GRAVITY_SOUTH,
- width,
- 0.0,
- ws->shadow_top_space +
- ws->shadow_top_corner_space +
- ws->shadow_bottom_corner_space + 1.0);
+ n = decor_set_horz_quad_line(q,
+ ws->shadow_left_space, ws->shadow_left_corner_space,
+ ws->shadow_right_space, ws->shadow_right_corner_space, 0,
+ ws->shadow_bottom_space, GRAVITY_SOUTH, width,
+ (ws->shadow_left_corner_space - ws->shadow_right_corner_space) >> 1,
+ 0, 0.0, ws->shadow_top_space + ws->shadow_top_corner_space +
+ ws->shadow_bottom_corner_space + 1.0);
nQuad += n;
@@ -2562,9 +2308,9 @@ update_default_decorations(GdkScreen * screen, frame_settings * fs_act,
Atom bareAtom, normalAtom, activeAtom;
decor_t d;
gint nQuad;
- quad quads[N_QUADS_MAX];
+ decor_quad_t quads[N_QUADS_MAX];
window_settings *ws = fs_act->ws; // hackish, I know, FIXME
- extents extents = ws->win_extents;
+ decor_extents_t extents = ws->win_extents;
bzero(&d, sizeof(decor_t));
@@ -2582,8 +2328,8 @@ update_default_decorations(GdkScreen * screen, frame_settings * fs_act,
nQuad = set_shadow_quads(quads, width, height, ws);
- decoration_to_property(data, GDK_PIXMAP_XID(ws->shadow_pixmap),
- &ws->shadow_extents, &ws->shadow_extents, 0, 0,
+ decor_quads_to_property(data, GDK_PIXMAP_XID(ws->shadow_pixmap),
+ &ws->shadow_extents, &ws->shadow_extents, 0, 0,
quads, nQuad);
XChangeProperty(xdisplay, xroot,
@@ -2640,7 +2386,7 @@ update_default_decorations(GdkScreen * screen, frame_settings * fs_act,
(*d.draw) (&d);
- decoration_to_property(data, GDK_PIXMAP_XID(d.p_inactive),
+ decor_quads_to_property(data, GDK_PIXMAP_XID(d.p_inactive),
&extents, &extents, 0, 0, quads, nQuad);
XChangeProperty(xdisplay, xroot,
@@ -2649,7 +2395,7 @@ update_default_decorations(GdkScreen * screen, frame_settings * fs_act,
32, PropModeReplace, (guchar *) data,
BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
- decoration_to_property(data, GDK_PIXMAP_XID(d.p_active),
+ decor_quads_to_property(data, GDK_PIXMAP_XID(d.p_active),
&extents, &extents, 0, 0, quads, nQuad);
XChangeProperty(xdisplay, xroot,