Here is some demo code which uses regions.
And i think i found a bug in the blur plugin. If i move the transparent window over a firefox window, the region suddenly doesn't work anymore and whole window becomes blurred. If i move the window to another position above the firefox window the region works again. Very strange.
Maybe it's a bug in my app, but that's unlikely
Can somebody confirm this?
- Code: Select all
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#define GRAVITY_NORTHWEST ((1 << 0) | (1 << 2))
#define BLUR_REGION TRUE
static gboolean
expose (GtkWidget *win, GdkEventExpose *eev, gpointer rect)
{
cairo_t *cr;
cr = gdk_cairo_create (win->window);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.5);
cairo_paint (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
gdk_cairo_rectangle (cr, (GdkRectangle *) rect);
cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, 0.0, 0.5, 1.0, 0.8);
cairo_stroke (cr);
cairo_destroy (cr);
return TRUE;
}
static void
set_compiz_blur (GdkWindow *window, GdkRectangle *rect)
{
Display *dpy;
long data [8];
guint n = 0;
dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default ());
data[n++] = 2;
data[n++] = 0;
if (rect) {
data[n++] = GRAVITY_NORTHWEST;
data[n++] = rect->x;
data[n++] = rect->y;
data[n++] = GRAVITY_NORTHWEST;
data[n++] = rect->x + rect->width;
data[n++] = rect->y + rect->height;
}
XChangeProperty (dpy, GDK_WINDOW_XID(window),
XInternAtom (dpy, "_COMPIZ_WM_WINDOW_BLUR", FALSE),
XA_INTEGER, 32, PropModeReplace, (guchar *)data, n);
}
int
main (int argc, char **argv)
{
GtkWidget *win;
GdkColormap *cm;
GdkRectangle rect;
gtk_init (&argc, &argv);
rect.x = 100;
rect.y = 100;
rect.width = 400;
rect.height = 200;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_app_paintable (win, TRUE);
gtk_widget_set_size_request (win, 600, 400);
cm = gdk_screen_get_rgba_colormap (gtk_widget_get_screen (win));
gtk_widget_set_colormap (win, cm);
g_object_unref (cm);
g_signal_connect (G_OBJECT(win), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect (G_OBJECT(win), "expose-event", G_CALLBACK(expose), (gpointer)&rect);
gtk_widget_show (win);
if (BLUR_REGION)
set_compiz_blur (win->window, &rect);
else
set_compiz_blur (win->window, NULL);
gtk_main ();
return 0;
}
btw, forum attachments would rock :wink: