summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-03-10 23:42:24 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-03-10 23:42:24 +0800
commit5eabaf50f1c98fb1bcdf8e453be3a2743f465f2b (patch)
tree45212d79c48e20f83872e3b0445f005d4af11fbb
parentfb5f161977b99b4f672c610b190e4f1af747fabd (diff)
downloadgtk-window-decorator-2d-testing-5eabaf50f1c98fb1bcdf8e453be3a2743f465f2b.tar.gz
gtk-window-decorator-2d-testing-5eabaf50f1c98fb1bcdf8e453be3a2743f465f2b.tar.bz2
Added metacity mode. broken in terms of drawing on the edges, but hey it still works after that!
-rw-r--r--window-decorator/gtk-window-decorator.c858
1 files changed, 420 insertions, 438 deletions
diff --git a/window-decorator/gtk-window-decorator.c b/window-decorator/gtk-window-decorator.c
index 261707e..ff3a542 100644
--- a/window-decorator/gtk-window-decorator.c
+++ b/window-decorator/gtk-window-decorator.c
@@ -242,9 +242,9 @@ static double decoration_alpha = 0.5;
#define SWITCHER_SPACE 40
static decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
-static decor_extents_t _win_extents = { 6, 6, 4, 6 };
+static decor_extents_t _win_extents = { 6, 6, 6, 6 };
static decor_extents_t _max_win_extents = { 6, 6, 4, 6 };
-static decor_extents_t _default_win_extents = { 6, 6, 4, 6 };
+static decor_extents_t _default_win_extents = { 6, 6, 6, 6 };
static decor_extents_t _switcher_extents = { 6, 6, 6, 6 + SWITCHER_SPACE };
static int titlebar_height = 17;
@@ -415,6 +415,7 @@ typedef struct _decor {
WnckWindowActions actions;
XID prop_xid;
GtkWidget *force_quit_dialog;
+ Bool created;
void (*draw) (struct _decor *d);
} decor_t;
@@ -466,7 +467,8 @@ typedef void (*event_callback) (WnckWindow *win, GTKWDButtonEvent *bevent, GTKWD
static char *program_name;
-static GtkWidget *style_window;
+static GtkWidget *style_window32;
+static GtkWidget *style_window24;
static GtkWidget *switcher_label;
static GHashTable *frame_table;
@@ -501,7 +503,8 @@ static gint switcher_width;
static gint switcher_height;
static Window switcher_selected_window = None;
-static XRenderPictFormat *xformat;
+static XRenderPictFormat *xformat32;
+static XRenderPictFormat *xformat24;
static void
decor_update_blur_property (decor_t *d,
@@ -679,9 +682,6 @@ create_gdk_window (Window xframe)
GdkWindow *window = gdk_window_foreign_new (xframe);
GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen);
-
- //fprintf (stderr, "Creating window %i %i\n", cmap->visual->depth,
- // gdk_drawable_get_depth (GDK_DRAWABLE (window)));
gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap);
return window;
@@ -695,7 +695,7 @@ create_pixmap (int w,
if (w == 0 || h ==0)
abort ();
- return gdk_pixmap_new (GDK_DRAWABLE (style_window->window), w, h, depth);
+ return gdk_pixmap_new (GDK_DRAWABLE (style_window32->window), w, h, depth);
}
#define CORNER_TOPLEFT (1 << 0)
@@ -972,44 +972,6 @@ button_state_paint (cairo_t *cr,
}
}
-/* Cut and paste from GDK */
-static GdkGC *
-get_bg_gc (GdkWindow *window, int x_offset, int y_offset)
-{
- GdkWindowObject *private = (GdkWindowObject *)window;
- guint gc_mask = 0;
- GdkGCValues gc_values;
-
- if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG && private->parent)
- {
- return get_bg_gc (GDK_WINDOW (private->parent),
- x_offset + private->x,
- y_offset + private->y);
- }
- else if (private->bg_pixmap &&
- private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
- private->bg_pixmap != GDK_NO_BG)
- {
- gc_values.fill = GDK_TILED;
- gc_values.tile = private->bg_pixmap;
- gc_values.ts_x_origin = x_offset;
- gc_values.ts_y_origin = y_offset;
-
- gc_mask = GDK_GC_FILL | GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN;
-
- return gdk_gc_new_with_values (window, &gc_values, gc_mask);
- }
- else
- {
- GdkGC *gc = gdk_gc_new (window);
-
- gdk_gc_set_foreground (gc, &(private->bg_color));
-
- return gc;
- }
-}
-
-
static void
draw_window_decoration (decor_t *d)
{
@@ -1026,7 +988,7 @@ draw_window_decoration (decor_t *d)
if (!d->pixmap)
return;
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY |
@@ -1047,9 +1009,6 @@ draw_window_decoration (decor_t *d)
else
cmap = gdk_screen_get_rgb_colormap (screen);
- //fprintf (stderr, "setting colormap %i %i\n", cmap->visual->depth,
- //gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)));
-
gdk_drawable_set_colormap (GDK_DRAWABLE (d->pixmap), cmap);
gdk_drawable_set_colormap (GDK_DRAWABLE (d->buffer_pixmap), cmap);
@@ -1073,8 +1032,6 @@ draw_window_decoration (decor_t *d)
y1 = d->context->top_space - _win_extents.top - titlebar_height;
x2 = d->width - d->context->right_space + _win_extents.right;
y2 = d->height - d->context->bottom_space + _win_extents.bottom;
-
- //fprintf (stderr, "x1 %f x2 %f y1 %f y2 %f\n", x1, x2, y1, y2);
h = d->height - d->context->top_space - d->context->bottom_space;
@@ -1296,7 +1253,6 @@ draw_window_decoration (decor_t *d)
gdk_cairo_set_source_color_alpha (cr,
&style->fg[GTK_STATE_NORMAL],
alpha * 0.75);
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
cairo_move_to (cr, x, y);
draw_close_button (d, cr, 3.0);
@@ -1335,7 +1291,7 @@ draw_window_decoration (decor_t *d)
{
gdk_cairo_set_source_color_alpha (cr,
&style->fg[GTK_STATE_NORMAL],
- alpha * 0.75);gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ alpha * 0.75);
cairo_move_to (cr, x, y);
@@ -1414,7 +1370,6 @@ draw_window_decoration (decor_t *d)
if (d->icon)
{
- //fprintf (stderr, "drawing icon\n");
cairo_translate (cr, d->context->left_space + 1,
y1 - 5.0 + titlebar_height / 2);
cairo_set_source (cr, d->icon);
@@ -1443,76 +1398,7 @@ draw_window_decoration (decor_t *d)
if (d->frame_window)
{
gtk_image_set_from_pixmap (GTK_IMAGE (d->decor_image), d->pixmap, NULL);
- gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height);
- fprintf (stderr, "set image \n");
- //Pixmap pix = gdk_x11_drawable_get_id (d->pixmap);,
- //XGCValues gcv;
- //Window winner = GDK_WINDOW_XID (d->frame_window);
-
- //gcv.foreground = BlackPixelOfScreen (GDK_SCREEN (gdk_display_get_default_screen (gdk_display_get_default ())));
-
- //GC wingc = XCreateGC (GDK_DISPLAY (),
- // GDK_SCREEN (gdk_display_get_default_screen (gdk_display_get_default ())),
- // GCForeground, &gcv));
- fprintf (stderr, "set back pixmap\n");
- //XDrawRectangle (GDK_DISPLAY (gdk_display_get_default ()), winner, wingc, 0, 0, d->width, d->height);
- //gdk_window_set_back_pixmap (d->frame_window, d->pixmap, FALSE);
- //gdk_window_clear (d->frame_window);
- //gdk_window_clear (d->frame_window);
-
- //GtkImage *image = gtk_image_new_from_file ("/home/smspillaz/photo.jpg");
-
-
-
- //GdkPixmap *gpixmaptest;
- //GError *error = NULL;
- //char buf_p[256];
- //char buf_w[256];
- //char buf_tp[256];
- //file_inc++;
- //sprintf (buf_p, "/home/smspillaz/test%i.png", file_inc);
- //sprintf (buf_w, "/home/smspillaz/test_w%i.png", file_inc);
- //cairo_surface_t *png = cairo_image_surface_create_from_png ("/home/smspillaz/test.png");
- //GdkPixbuf *pixbufImg = gdk_pixbuf_get_from_drawable (NULL, d->pixmap, NULL, 0, 0, 0, 0, d->width, d->height);
-
- //gdk_pixbuf_save (pixbufImg, buf_p, "png", &error, NULL);
- //error = NULL;
- //Pixmap pix;
- //Pixmap mask_return;
- //int alpha_threshold;
- //gdk_pixbuf_xlib_render_pixmap_and_mask (pixbufImg,
- // &pix,
- // &mask_return,
- // 1.0);
- //sprintf (buf_tp, "/home/smspillaz/test%i.png", file_inc);
- //gpixmaptest = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (),
- // pix);
- //pixbufImg = gdk_pixbuf_get_from_drawable (NULL, gpixmaptest, NULL, 0, 0, 0, 0, d->width, d->height);
- //gdk_pixbuf_save (pixbufImg, buf_tp, "png", &error, NULL);
- //error = NULL;
- //
- //pixbufImg = gdk_pixbuf_get_from_drawable (NULL, d->frame_window, NULL, 0, 0, 0, 0, d->width, d->height);
- //gdk_pixbuf_save (pixbufImg, buf_w, "png", &error, NULL);
- //gdk_draw_pixbuf (GDK_DRAWABLE (d->frame_window),
- // NULL,
- // pixbufImg,
- // 0, 0,
- // 0, 0,
- // d->width,
- // d->height,
- // GDK_RGB_DITHER_NONE,
- // 0,
- // 0);
- //pixbufImg = gdk_pixbuf_get_from_drawable (NULL, d->frame_window, NULL, 0, 0, 0, 0, d->width, d->height);
- //gdk_pixbuf_save (pixbufImg, buf_w, "png", &error, NULL);
- //fprintf (stderr, "drawed deco\n");
- //XClearWindow (xdisplay, GDK_WINDOW_XID (d->frame_window));
-
- //GdkGC *gc = get_bg_gc (d->frame_window, 0, 0);
-
- //gdk_window_set_back_pixmap (d->frame_window, d->pixmap, FALSE);
-
-
+ gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height);
}
if (d->prop_xid)
@@ -2059,6 +1945,7 @@ meta_draw_window_decoration (decor_t *d)
gboolean shade_alpha = (d->active) ? meta_active_shade_opacity :
meta_shade_opacity;
MetaFrameStyle *frame_style;
+ GtkWidget *style_window;
GdkColor bg_color;
double bg_alpha;
@@ -2075,9 +1962,6 @@ meta_draw_window_decoration (decor_t *d)
else
cmap = gdk_screen_get_rgb_colormap (screen);
- //fprintf (stderr, "setting colormap %i %i\n", cmap->visual->depth,
- // gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)));
-
gdk_drawable_set_colormap (GDK_DRAWABLE (d->pixmap), cmap);
gdk_drawable_set_colormap (GDK_DRAWABLE (d->buffer_pixmap), cmap);
}
@@ -2085,7 +1969,16 @@ meta_draw_window_decoration (decor_t *d)
if (decoration_alpha == 1.0)
alpha = 1.0;
- style = gtk_widget_get_style (style_window);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
+ {
+ style = gtk_widget_get_style (style_window32);
+ style_window = style_window32;
+ }
+ else
+ {
+ style = gtk_widget_get_style (style_window24);
+ style_window = style_window24;
+ }
drawable = d->buffer_pixmap ? d->buffer_pixmap : d->pixmap;
@@ -2135,7 +2028,19 @@ meta_draw_window_decoration (decor_t *d)
if (rect.width && size)
{
if (d->frame_window)
+ {
pixmap = create_pixmap (rect.width, size, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
+
+ GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
+ GdkColormap *cmap;
+
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
+ cmap = gdk_screen_get_rgba_colormap (screen);
+ else
+ cmap = gdk_screen_get_rgb_colormap (screen);
+
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
+ }
else
pixmap = create_pixmap (rect.width, size, 32);
@@ -2143,9 +2048,15 @@ meta_draw_window_decoration (decor_t *d)
gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- src = XRenderCreatePicture (xdisplay,
- GDK_PIXMAP_XID (pixmap),
- xformat, 0, NULL);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (pixmap)) == 32 ||
+ !d->frame_window)
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat32, 0, NULL);
+ else
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat24, 0, NULL);
if (fgeom.top_height)
{
@@ -2240,17 +2151,35 @@ meta_draw_window_decoration (decor_t *d)
if (size && rect.height)
{
if (d->frame_window)
- pixmap = create_pixmap (size, rect.height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
+ {
+ pixmap = create_pixmap (rect.width, size, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
+
+ GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
+ GdkColormap *cmap;
+
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
+ cmap = gdk_screen_get_rgba_colormap (screen);
+ else
+ cmap = gdk_screen_get_rgb_colormap (screen);
+
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
+ }
else
- pixmap = create_pixmap (size, rect.height, 32);
+ pixmap = create_pixmap (rect.width, size, 32);
cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- src = XRenderCreatePicture (xdisplay,
- GDK_PIXMAP_XID (pixmap),
- xformat, 0, NULL);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (pixmap)) == 32 ||
+ !d->frame_window)
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat32, 0, NULL);
+ else
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat24, 0, NULL);
if (fgeom.left_width)
{
@@ -2351,15 +2280,10 @@ meta_draw_window_decoration (decor_t *d)
d->height);
if (d->frame_window)
- gdk_draw_drawable (d->frame_window,
- d->gc,
- d->pixmap,
- 0,
- 0,
- 0,
- 0,
- -1,
- -1);
+ {
+ gtk_image_set_from_pixmap (GTK_IMAGE (d->decor_image), d->pixmap, NULL);
+ gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height);
+ }
if (d->prop_xid)
{
@@ -2414,7 +2338,7 @@ decor_update_switcher_property (decor_t *d)
&_switcher_extents, &_switcher_extents,
0, 0, quads, nQuad);
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
fgColor[0] = style->fg[GTK_STATE_NORMAL].red;
fgColor[1] = style->fg[GTK_STATE_NORMAL].green;
@@ -2449,7 +2373,7 @@ draw_switcher_background (decor_t *d)
if (!d->buffer_pixmap)
return;
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
color.r = style->bg[GTK_STATE_NORMAL].red / 65535.0;
color.g = style->bg[GTK_STATE_NORMAL].green / 65535.0;
@@ -2648,7 +2572,7 @@ draw_switcher_foreground (decor_t *d)
if (!d->pixmap || !d->buffer_pixmap)
return;
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
cr = gdk_cairo_create (GDK_DRAWABLE (d->buffer_pixmap));
@@ -2738,6 +2662,13 @@ queue_decor_draw (decor_t *d)
draw_idle_id = g_idle_add (draw_decor_list, NULL);
}
+/*static void
+queue_add_frame_window (WnckWindow *win,
+ Window frame,
+ Bool mode)
+{
+ if (g_s
+*/
static GdkPixmap *
pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, Bool alpha)
{
@@ -2856,7 +2787,7 @@ update_default_decorations (GdkScreen *screen)
d.active = FALSE;
d.picture = XRenderCreatePicture (xdisplay,
GDK_PIXMAP_XID (d.pixmap),
- xformat, 0, NULL);
+ xformat32, 0, NULL);
(*d.draw) (&d);
@@ -2883,7 +2814,7 @@ update_default_decorations (GdkScreen *screen)
d.active = TRUE;
d.picture = XRenderCreatePicture (xdisplay,
GDK_PIXMAP_XID (d.pixmap),
- xformat, 0, NULL);
+ xformat32, 0, NULL);
(*d.draw) (&d);
@@ -3370,8 +3301,6 @@ update_event_windows (WnckWindow *win)
d->event_window_pos[i][j].x2 = x + w;
d->event_window_pos[i][j].y1 = y;
d->event_window_pos[i][j].y2 = y + h;
-
- fprintf (stderr, "new event window pos x1 %i x2 %i y1 %i y2 %i\n", x, x + w, y, y + h);
}
else if (!d->frame_window && w != 0 && h != 0)
{
@@ -3437,8 +3366,6 @@ update_event_windows (WnckWindow *win)
d->button_window_pos[i].y1 = y;
d->button_window_pos[i].x2 = x + w;
d->button_window_pos[i].y2 = y + h;
-
- fprintf (stderr, "set button window position to %i %i %i %i\n", x, x + w, y, y + h);
}
else if (!d->frame_window &&
(*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h))
@@ -3686,9 +3613,6 @@ calc_decoration_size (decor_t *d,
decor_get_default_layout (&window_context, top_width, 1, &layout);
- //if (d->context)
- // fprintf (stderr, "d->context is non null\n");
-
if (TRUE)
{
*width = d->client_width + _win_extents.left + _win_extents.right + 2;
@@ -3698,8 +3622,6 @@ calc_decoration_size (decor_t *d,
d->context = &window_context;
d->shadow = border_shadow;
- //fprintf (stderr, "calculated width and height are %i %i\n", *width, *height);
-
return TRUE;
}
}
@@ -3816,47 +3738,64 @@ update_window_decoration_size (WnckWindow *win)
gint w, h, name_width;
gint x, y;
Display *xdisplay;
+
+ if (d->pixmap)
+ fprintf (stderr, "pixmap exists\n");
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
wnck_window_get_client_window_geometry (win, &x, &y, &w, &h);
name_width = max_window_name_width (win);
-
- //fprintf (stderr, "got update size\n");
if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height))
{
update_window_decoration_name (win);
- //fprintf (stderr, "returning because calc_deco_size returned false\n");
return FALSE;
}
+ gdk_error_trap_push ();
+
+
if (d->frame_window)
pixmap = create_pixmap (width, height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
else
pixmap = create_pixmap (width, height, 32);
- if (!pixmap)
+ gdk_flush ();
+
+ if (!pixmap || gdk_error_trap_pop ())
{
- //fprintf (stderr, "returning because pixmap is null\n");
+ memset (pixmap, 0, sizeof (pixmap));
return FALSE;
}
+ gdk_error_trap_push ();
+
if (d->frame_window)
buffer_pixmap = create_pixmap (width, height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
else
buffer_pixmap = create_pixmap (width, height, 32);
- if (!buffer_pixmap)
+ gdk_flush ();
+
+ if (!buffer_pixmap || gdk_error_trap_pop ())
{
- //fprintf (stderr, "returning because no buffer pixmap\n");
+ memset (buffer_pixmap, 0, sizeof (buffer_pixmap));
g_object_unref (G_OBJECT (pixmap));
return FALSE;
}
- picture = XRenderCreatePicture (xdisplay, GDK_PIXMAP_XID (buffer_pixmap),
- xformat, 0, NULL);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (buffer_pixmap)) == 32 ||
+ !d->frame_window)
+ picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat32, 0, NULL);
+ else
+ picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat24, 0, NULL);
+
if (d->pixmap)
g_object_unref (G_OBJECT (d->pixmap));
@@ -3870,6 +3809,7 @@ update_window_decoration_size (WnckWindow *win)
if (d->picture)
XRenderFreePicture (xdisplay, d->picture);
+
d->pixmap = pixmap;
d->buffer_pixmap = buffer_pixmap;
d->gc = gdk_gc_new (pixmap);
@@ -3881,14 +3821,6 @@ update_window_decoration_size (WnckWindow *win)
d->prop_xid = wnck_window_get_xid (win);
- if (d->frame_window && width != 0 && height != 0)
- {
- }
- else if (d->frame_window)
- {
- gdk_window_hide (d->frame_window);
- }
-
update_window_decoration_name (win);
queue_decor_draw (d);
@@ -4198,23 +4130,19 @@ common_button_event (WnckWindow *win,
d->button_states[button] &= ~PRESSED_EVENT_WINDOW;
break;
case GEnterNotify:
- fprintf (stderr, "I haz enter notify\n");
+ //fprintf (stderr, "I haz enter notify\n");
d->button_states[button] |= IN_EVENT_WINDOW;
break;
case GLeaveNotify:
- fprintf (stderr, "I haz leave notify\n");
+ //fprintf (stderr, "I haz leave notify\n");
d->button_states[button] &= ~IN_EVENT_WINDOW;
break;
default:
break;
}
-
- if (d->button_states[button] & PRESSED_EVENT_WINDOW)
- fprintf (stderr, "event window is depressed\n");
if (state != d->button_states[button])
{
- fprintf (stderr, "added to redraw queue\n");
queue_decor_draw (d);
}
}
@@ -4232,24 +4160,17 @@ close_button_event (WnckWindow *win,
common_button_event (win, bevent, gType,
BUTTON_CLOSE, 1, _("Close Window"));
- fprintf (stderr, "got close button event, gType is %i\n", gType);
-
switch (gType) {
case GButtonRelease:
-
- fprintf (stderr, "button release event\n");
if (bevent->button == 1)
{
- fprintf (stderr, "button release with button 1\n");
if (state == BUTTON_EVENT_ACTION_STATE)
{
- fprintf (stderr, "going to close window\n");
wnck_window_close (win, bevent->time);
}
}
break;
default:
- fprintf (stderr, "some other event\n");
break;
}
}
@@ -4862,6 +4783,7 @@ frame_handle_button_press (GtkWidget *widget,
int i, j;
Bool found = FALSE;
Bool event_area = FALSE;
+ Bool exit = FALSE;
for (i = 0; i < BUTTON_NUM; i++)
{
@@ -4873,8 +4795,6 @@ frame_handle_button_press (GtkWidget *widget,
{
found = TRUE;
- fprintf (stderr, "got button_press in button %i\n", i);
-
break;
}
}
@@ -4883,7 +4803,7 @@ frame_handle_button_press (GtkWidget *widget,
{
for (i = 0; i < 3; i++)
{
- for (j = 0; i < 3; i++)
+ for (j = 0; j < 3; j++)
{
if (event->x >= d->event_window_pos[i][j].x1 &&
event->x <= d->event_window_pos[i][j].x2 &&
@@ -4892,12 +4812,15 @@ frame_handle_button_press (GtkWidget *widget,
{
found = TRUE;
event_area = TRUE;
-
- fprintf (stderr, "got button_press in event area %i\n", i);
-
+
+ exit = TRUE;
+
break;
}
}
+
+ if (exit)
+ break;
}
}
@@ -4937,7 +4860,7 @@ frame_handle_button_press (GtkWidget *widget,
bevent.time = event->time;
if (event_area)
- (*callback[i][j]) (d->win, &bevent, gType);
+ (*(callback[i][j])) (d->win, &bevent, gType);
else
(*button_callback[i]) (d->win, &bevent, gType);
}
@@ -4961,6 +4884,7 @@ frame_handle_button_release (GtkWidget *widget,
int i, j;
Bool found = FALSE;
Bool event_area = FALSE;
+ Bool exit = FALSE;
for (i = 0; i < BUTTON_NUM; i++)
{
@@ -4972,8 +4896,6 @@ frame_handle_button_release (GtkWidget *widget,
{
found = TRUE;
- fprintf (stderr, "got button_press in button %i\n", i);
-
break;
}
}
@@ -4982,7 +4904,7 @@ frame_handle_button_release (GtkWidget *widget,
{
for (i = 0; i < 3; i++)
{
- for (j = 0; i < 3; i++)
+ for (j = 0; j < 3; j++)
{
if (event->x >= d->event_window_pos[i][j].x1 &&
event->x <= d->event_window_pos[i][j].x2 &&
@@ -4992,11 +4914,15 @@ frame_handle_button_release (GtkWidget *widget,
found = TRUE;
event_area = TRUE;
- fprintf (stderr, "got button_press in event area %i\n", i);
+ exit = TRUE;
break;
}
}
+
+ if (exit)
+ break;
+
}
}
@@ -5034,8 +4960,6 @@ frame_handle_button_release (GtkWidget *widget,
bevent.x_root = event->x_root;
bevent.y_root = event->y_root;
bevent.time = event->time;
-
- fprintf (stderr, "gType is %i\n", gType);
if (event_area)
(*callback[i][j]) (d->win, &bevent, gType);
@@ -5044,7 +4968,6 @@ frame_handle_button_release (GtkWidget *widget,
}
}
}
- fprintf (stderr, "got button release event\n");
}
static void
@@ -5083,6 +5006,7 @@ frame_handle_motion (GtkWidget *widget,
Bool event_area = FALSE;
Bool send_enter = FALSE;
Bool send_leave = FALSE;
+ Bool exit = FALSE;
/* Check buttons */
@@ -5096,29 +5020,35 @@ frame_handle_motion (GtkWidget *widget,
{
found = TRUE;
- fprintf (stderr, "pointer is in %i\n", i);
+ //fprintf (stderr, "pointer is in %i\n", i);
if (d->last_pos_entered != &(d->button_window_pos[i]))
{
- fprintf (stderr, "newly entered area\n");
+ //printf (stderr, "newly entered area\n");
send_enter = TRUE;
+ if (d->last_pos_entered)
+ {
+ send_leave = TRUE;
+ }
}
- if (d->last_pos_entered)
- {
- send_leave = TRUE;
- }
+
break;
}
}
/* Check event windows */
+
+ exit = FALSE;
if (!found)
{
for (i = 0; i < 3; i++)
{
- for (j = 0; i < 3; i++)
+ for (j = 0; j < 3; j++)
{
+
+ //fprintf (stderr, "event is %f %f pos is %i %i %i %i\n", event->x_root, event->y_root, d->event_window_pos[i][j].x1, d->event_window_pos[i][j].x2, d->event_window_pos[i][j].y1, d->event_window_pos[i][j].y2);
+
if (event->x >= d->event_window_pos[i][j].x1 &&
event->x <= d->event_window_pos[i][j].x2 &&
event->y >= d->event_window_pos[i][j].y1 &&
@@ -5127,21 +5057,26 @@ frame_handle_motion (GtkWidget *widget,
found = TRUE;
event_area = TRUE;
- fprintf (stderr, "pointer is in %i\n", i);
+ //fprintf (stderr, "pointer is in %i\n", i);
- if (d->last_pos_entered != &(d->button_window_pos[i]))
+ if (d->last_pos_entered != &(d->event_window_pos[i][j]))
{
- fprintf (stderr, "newly entered area\n");
+ //fprintf (stderr, "newly entered area\n");
send_enter = TRUE;
+ if (d->last_pos_entered)
+ {
+ send_leave = TRUE;
+ }
}
- if (d->last_pos_entered)
- {
- send_leave = TRUE;
- }
+
+ exit = TRUE;
break;
}
}
+
+ if (exit)
+ break;
}
}
@@ -5163,7 +5098,9 @@ frame_handle_motion (GtkWidget *widget,
{
gType = GEnterNotify;
- fprintf (stderr, "sending enter notify\n");
+ //fprintf (stderr, "sending enter notify\n");
+
+ //fprintf (stderr, "i and j are %i %i\n", i, j);
if (event_area)
(*callback[i][j]) (d->win, &bevent, gType);
@@ -5180,21 +5117,40 @@ frame_handle_motion (GtkWidget *widget,
gType = GLeaveNotify;
- fprintf (stderr, "sending leave notify\n");
+ //fprintf (stderr, "sending leave notify\n");
for (k = 0; k < 3; k++)
- for (l = 0; l < 3; l++)
- if (d->last_pos_entered == &(d->event_window_pos[k][l]))
- {
- l_found = TRUE;
- l_event_area = TRUE;
- }
-
- for (k = 0; k < 3; k++)
+ {
if (d->last_pos_entered == &(d->button_window_pos[k]))
{
l_found = TRUE;
+ break;
+ }
+ }
+
+ exit = FALSE;
+
+ if (!l_found)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ for (l = 0; l < 3; l++)
+ {
+ if (d->last_pos_entered == &(d->event_window_pos[k][l]))
+ {
+ l_found = TRUE;
+ l_event_area = TRUE;
+
+ exit = TRUE;
+
+ break;
+ }
+
+ if (exit)
+ break;
+ }
}
+ }
if (l_found)
{
@@ -5237,21 +5193,38 @@ frame_handle_motion (GtkWidget *widget,
gType = GLeaveNotify;
- fprintf (stderr, "sending leave notify\n");
-
- for (k = 0; k < 3; k++)
- for (l = 0; l < 3; l++)
- if (d->last_pos_entered == &(d->event_window_pos[k][l]))
- {
- l_found = TRUE;
- l_event_area = TRUE;
- }
-
for (k = 0; k < 3; k++)
+ {
if (d->last_pos_entered == &(d->button_window_pos[k]))
{
l_found = TRUE;
+ break;
}
+ }
+
+ exit = FALSE;
+
+ if (!l_found)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ for (l = 0; l < 3; l++)
+ {
+ if (d->last_pos_entered == &(d->event_window_pos[k][l]))
+ {
+ l_found = TRUE;
+ l_event_area = TRUE;
+
+ exit = TRUE;
+
+ break;
+ }
+
+ if (exit)
+ break;
+ }
+ }
+ }
if (l_found)
{
@@ -5265,87 +5238,104 @@ frame_handle_motion (GtkWidget *widget,
}
}
- fprintf (stderr, "got mption notify\n");
}
-#if 0
static void
-frame_handle_button_press (GtkWidget *widget,
- GtkEventButton *event,
- gpointer user_data)
+window_name_changed (WnckWindow *win)
{
- decor_t *d = (decor_t *) user_data;
-
- if (d)
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
{
- /* Check to see where the event happened and fill out an appropriate
- * struct
-
- int i, j;
- Bool found = FALSE;
- Bool event_area = FALSE;
-
- for (i = 0; i < BUTTON_NUM; i++)
- {
- /* Hit */
- if (XPointInRegion (d->button_window_pos[i], event->x,
- event->y))
- {
- found = TRUE;
- break;
- }
+ if (!update_window_decoration_size (win))
+ queue_decor_draw (d);
+ }
+}
- if (!found)
+static void
+window_geometry_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ int width, height;
+
+ wnck_window_get_client_window_geometry (win, NULL, NULL, &width,
+ &height);
+
+ if (width != d->client_width || height != d->client_height)
{
- for (i = 0; i < 3; i++)
- {
- for (j = 0; i < 3; i++)
- {
- if (XPointInRegion (d->event_window_pos[i], event->x,
- event->y))
- {
- found = TRUE;
- event_area = TRUE;
- break;
- }
- }
- }
- }
-
- if (found)
- {/*
- static event_callback callback[3][3] = {
- { top_left_event, top_event, top_right_event },
- { left_event, title_event, right_event },
- { bottom_left_event, bottom_event, bottom_right_event }
- };
- static event_callback button_callback[BUTTON_NUM] = {
- close_button_event,
- max_button_event,
- min_button_event,
- menu_button_event,
- shade_button_event,
- above_button_event,
- stick_button_event,
- unshade_button_event,
- unabove_button_event,
- unstick_button_event
- };
+ d->client_width = width;
+ d->client_height = height;
- if (d->decorated)
- {
- if (event_area)
- (*callback[i][j]) (); // TODO
- else
- (*button_callback[i]) (); // TODO
- }
- */
+ update_window_decoration_size (win);
+ update_event_windows (win);
}
}
}
-#endif
+static void
+window_icon_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ update_window_decoration_icon (win);
+ queue_decor_draw (d);
+ }
+}
+
+static void
+window_state_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ update_window_decoration_state (win);
+ if (!update_window_decoration_size (win))
+ queue_decor_draw (d);
+
+ update_event_windows (win);
+ }
+}
+
+static void
+window_actions_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ update_window_decoration_actions (win);
+ if (!update_window_decoration_size (win))
+ queue_decor_draw (d);
+ update_event_windows (win);
+ }
+}
+
+static void
+connect_window (WnckWindow *win)
+{
+ g_signal_connect_object (win, "name_changed",
+ G_CALLBACK (window_name_changed),
+ 0, 0);
+ g_signal_connect_object (win, "geometry_changed",
+ G_CALLBACK (window_geometry_changed),
+ 0, 0);
+ g_signal_connect_object (win, "icon_changed",
+ G_CALLBACK (window_icon_changed),
+ 0, 0);
+ g_signal_connect_object (win, "state_changed",
+ G_CALLBACK (window_state_changed),
+ 0, 0);
+ g_signal_connect_object (win, "actions_changed",
+ G_CALLBACK (window_actions_changed),
+ 0, 0);
+}
static void
add_frame_window (WnckWindow *win,
@@ -5360,6 +5350,26 @@ add_frame_window (WnckWindow *win,
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ /* If we have already done this, there is no need to do it again, except
+ * if the property changed.
+ *
+ * The reason this check is here is because sometimes the PropertyNotify X
+ * event can come a bit after the property on the window is actually set
+ * which might result in this function being called twice - once by
+ * wnck through window_opened and once through our X event handler
+ * event_filter_func
+ */
+
+ if (d->created)
+ {
+ fprintf (stderr, "we are already created\n");
+ if ((mode && d->frame_window) || (!mode && !d->frame_window))
+ {
+ fprintf (stderr, "returning\n");
+ return;
+ }
+ }
+
d->active = wnck_window_is_active (win);
d->win = win;
d->last_pos_entered = NULL;
@@ -5369,13 +5379,11 @@ add_frame_window (WnckWindow *win,
attr.override_redirect = TRUE;
gdk_error_trap_push ();
+
+ fprintf (stderr, "mode is %i\n", mode);
if (mode)
- {
- //d->pixmap = create_pixmap (d->width, d->height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
- //printf ("d->width is %i d->height is %i\n", d->client_width, d->client_height);
- //fprintf (stderr, "window id is %x\n", frame);
-
+ {
GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
GdkColormap *colormap;
@@ -5498,6 +5506,8 @@ add_frame_window (WnckWindow *win,
{
memset (d->event_windows, 0, sizeof (d->event_windows));
}
+
+ d->created = TRUE;
}
static gboolean
@@ -5525,6 +5535,7 @@ update_switcher_window (WnckWindow *win,
if (!d->pixmap && switcher_pixmap)
{
g_object_ref (G_OBJECT (switcher_pixmap));
+
d->pixmap = switcher_pixmap;
}
@@ -5617,11 +5628,17 @@ update_switcher_window (WnckWindow *win,
d->gc = gdk_gc_new (d->pixmap);
if (!d->picture)
- d->picture =
- XRenderCreatePicture (xdisplay,
- GDK_PIXMAP_XID (d->buffer_pixmap),
- xformat, 0, NULL);
-
+ {
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->buffer_pixmap)) == 32 ||
+ !d->frame_window)
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat32, 0, NULL);
+ else
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat24, 0, NULL);
+ }
queue_decor_draw (d);
return FALSE;
}
@@ -5668,8 +5685,15 @@ update_switcher_window (WnckWindow *win,
d->buffer_pixmap = buffer_pixmap;
d->gc = gdk_gc_new (pixmap);
- d->picture = XRenderCreatePicture (xdisplay, GDK_PIXMAP_XID (buffer_pixmap),
- xformat, 0, NULL);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->buffer_pixmap)) == 32 ||
+ !d->frame_window)
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat32, 0, NULL);
+ else
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat24, 0, NULL);
d->width = width;
d->height = height;
@@ -5753,10 +5777,29 @@ remove_frame_window (WnckWindow *win)
if (d->frame_window)
{
- g_object_unref (G_OBJECT (d->frame_window));
gdk_window_destroy (d->frame_window);
d->frame_window = NULL;
}
+
+ if (d->decor_image)
+ {
+ g_object_unref (d->decor_window);
+ d->decor_image = NULL;
+ }
+
+ if (d->decor_event_box)
+ {
+ g_object_unref (d->decor_event_box);
+ d->decor_event_box = NULL;
+ }
+
+ if (d->decor_window)
+ {
+ g_object_unref (d->decor_window);
+ d->decor_window = NULL;
+ }
+
+
d->width = 0;
d->height = 0;
@@ -5773,106 +5816,6 @@ remove_frame_window (WnckWindow *win)
}
static void
-window_name_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- if (!update_window_decoration_size (win))
- queue_decor_draw (d);
- }
-}
-
-static void
-window_geometry_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- int width, height;
-
- wnck_window_get_client_window_geometry (win, NULL, NULL, &width,
- &height);
-
- if (width != d->client_width || height != d->client_height)
- {
- d->client_width = width;
- d->client_height = height;
-
- update_window_decoration_size (win);
- update_event_windows (win);
-
- //if (!d->frame_window)
- //queue_decor_draw (d);
- }
- }
-}
-
-static void
-window_icon_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- update_window_decoration_icon (win);
- queue_decor_draw (d);
- }
-}
-
-static void
-window_state_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- update_window_decoration_state (win);
- if (!update_window_decoration_size (win))
- queue_decor_draw (d);
-
- update_event_windows (win);
- }
-}
-
-static void
-window_actions_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- update_window_decoration_actions (win);
- if (!update_window_decoration_size (win))
- queue_decor_draw (d);
-
- update_event_windows (win);
- }
-}
-
-static void
-connect_window (WnckWindow *win)
-{
- g_signal_connect_object (win, "name_changed",
- G_CALLBACK (window_name_changed),
- 0, 0);
- g_signal_connect_object (win, "geometry_changed",
- G_CALLBACK (window_geometry_changed),
- 0, 0);
- g_signal_connect_object (win, "icon_changed",
- G_CALLBACK (window_icon_changed),
- 0, 0);
- g_signal_connect_object (win, "state_changed",
- G_CALLBACK (window_state_changed),
- 0, 0);
- g_signal_connect_object (win, "actions_changed",
- G_CALLBACK (window_actions_changed),
- 0, 0);
-}
-
-static void
active_window_changed (WnckScreen *screen)
{
WnckWindow *win;
@@ -5918,14 +5861,25 @@ window_opened (WnckScreen *screen,
&d->client_height);
d->draw = theme_draw_window_decoration;
+
+ /* Prevent double pixmap freeing */
+
+ d->created = FALSE;
+ d->pixmap = NULL;
+ d->gc = NULL;
+ d->buffer_pixmap = NULL;
+ d->picture = None;
+
+ connect_window (win);
+
+ fprintf (stderr, "made a windopw\n");
+
+ if (d->pixmap)
+ fprintf (stderr, "after connnection, d->pixmap exists\n");
g_object_set_data (G_OBJECT (win), "decor", d);
- connect_window (win);
-
xid = wnck_window_get_xid (win);
-
- //fprintf (stderr, "add_frame_window called\n");
if (get_window_prop (xid, select_window_atom, &window))
{
@@ -7925,34 +7879,63 @@ init_settings (WnckScreen *screen)
}
#endif
- style_window = gtk_window_new (GTK_WINDOW_POPUP);
+ style_window32 = gtk_window_new (GTK_WINDOW_POPUP);
gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
colormap = gdk_screen_get_rgba_colormap (gdkscreen);
if (colormap)
- gtk_widget_set_colormap (style_window, colormap);
+ gtk_widget_set_colormap (style_window32, colormap);
+
+ gtk_widget_realize (style_window32);
+
+ switcher_label = gtk_label_new ("");
+ switcher_label_obj = gtk_widget_get_accessible (switcher_label);
+ atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
+ gtk_container_add (GTK_CONTAINER (style_window32), switcher_label);
+
+ gtk_widget_set_size_request (style_window32, 0, 0);
+ gtk_window_move (GTK_WINDOW (style_window32), -100, -100);
+ gtk_widget_show_all (style_window32);
+
+ g_signal_connect_object (style_window32, "style-set",
+ G_CALLBACK (style_changed),
+ 0, 0);
+
+ settings = gtk_widget_get_settings (style_window32);
+
+ g_object_get (G_OBJECT (settings), "gtk-double-click-time",
+ &double_click_timeout, NULL);
+
+ pango_context = gtk_widget_create_pango_context (style_window32);
+
+ style_window24 = gtk_window_new (GTK_WINDOW_POPUP);
+
+ gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
+ colormap = gdk_screen_get_rgb_colormap (gdkscreen);
+ if (colormap)
+ gtk_widget_set_colormap (style_window24, colormap);
- gtk_widget_realize (style_window);
+ gtk_widget_realize (style_window24);
switcher_label = gtk_label_new ("");
switcher_label_obj = gtk_widget_get_accessible (switcher_label);
atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
- gtk_container_add (GTK_CONTAINER (style_window), switcher_label);
+ gtk_container_add (GTK_CONTAINER (style_window24), switcher_label);
- gtk_widget_set_size_request (style_window, 0, 0);
- gtk_window_move (GTK_WINDOW (style_window), -100, -100);
- gtk_widget_show_all (style_window);
+ gtk_widget_set_size_request (style_window24, 0, 0);
+ gtk_window_move (GTK_WINDOW (style_window24), -100, -100);
+ gtk_widget_show_all (style_window24);
- g_signal_connect_object (style_window, "style-set",
+ g_signal_connect_object (style_window24, "style-set",
G_CALLBACK (style_changed),
0, 0);
- settings = gtk_widget_get_settings (style_window);
+ settings = gtk_widget_get_settings (style_window24);
g_object_get (G_OBJECT (settings), "gtk-double-click-time",
&double_click_timeout, NULL);
- pango_context = gtk_widget_create_pango_context (style_window);
+ pango_context = gtk_widget_create_pango_context (style_window24);
#ifdef USE_GCONF
use_system_font = gconf_client_get_bool (gconf,
@@ -7963,8 +7946,8 @@ init_settings (WnckScreen *screen)
button_layout_changed (gconf);
#endif
- update_style (style_window);
-
+ update_style (style_window32);
+ update_style (style_window24);
#ifdef USE_GCONF
titlebar_font_changed (gconf);
#endif
@@ -8114,8 +8097,6 @@ main (int argc, char *argv[])
}
#endif
- fprintf (stderr, "starting decor\n");
-
gdkdisplay = gdk_display_get_default ();
xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);
gdkscreen = gdk_display_get_default_screen (gdkdisplay);
@@ -8178,7 +8159,8 @@ main (int argc, char *argv[])
}
}
- xformat = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
+ xformat32 = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
+ xformat24 = XRenderFindStandardFormat (xdisplay, PictStandardRGB24);
frame_table = g_hash_table_new (NULL, NULL);
//rame_window_table = g_hash_table_new (NULL, NULL);