bigboard r7410 - in trunk: . bigboard
- From: otaylor svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7410 - in trunk: . bigboard
- Date: Fri, 27 Jun 2008 20:48:37 +0000 (UTC)
Author: otaylor
Date: Fri Jun 27 20:48:37 2008
New Revision: 7410
URL: http://svn.gnome.org/viewvc/bigboard?rev=7410&view=rev
Log:
Add bignative.window_shape_set_region() to make up for missing
gdk_window_shape_combine_region(), and avoid rendering rectangles
to a big mask and then converting them back.
Modified:
trunk/bigboard/bigboard-native.c
trunk/bigboard/bigboard-native.h
trunk/bigboard/bignative.c
trunk/configure.ac
Modified: trunk/bigboard/bigboard-native.c
==============================================================================
--- trunk/bigboard/bigboard-native.c (original)
+++ trunk/bigboard/bigboard-native.c Fri Jun 27 20:48:37 2008
@@ -8,11 +8,14 @@
#include <glib.h>
+#include <X11/extensions/shape.h>
+
/* NO_IMPORT declares _PyGObject_Functions extern instead of definint them, which happens in bignative.c */
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
static PyObject *logging_cb = NULL;
@@ -168,3 +171,65 @@
return result;
}
+PyObject *
+bigboard_window_shape_set_region(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "window", "region", "kind", NULL };
+ PyGObject *py_window;
+ PyObject *py_region;
+ GdkWindow *window;
+ GdkRegion *region;
+ int kind = ShapeBounding;
+ GdkRectangle *rectangles;
+ XRectangle *xrectangles;
+ int n_rectangles;
+ int i;
+ /* Used to clamp to limits of XRectangle */
+ GdkRectangle short_rect = { -0x8000, -0x8000, 0xffff, 0xffff };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i:bigboard_window_shape_set_region", kwlist, &py_window, &py_region, kind))
+ return NULL;
+
+ if (!GDK_IS_WINDOW(py_window->obj)) {
+ PyErr_SetString(PyExc_TypeError, "window should be a GdkWindow");
+ return NULL;
+ }
+
+ window = GDK_WINDOW(py_window->obj);
+
+ if (pyg_boxed_check(py_region, g_type_from_name("GdkRegion")))
+ region = pyg_boxed_get(py_region, GdkRegion);
+ else {
+ PyErr_SetString(PyExc_TypeError, "region should be a GdkRegion");
+ return NULL;
+ }
+
+ if (kind != ShapeBounding && kind != ShapeInput) {
+ PyErr_SetString(PyExc_TypeError, "type should be 0 (ShapeBounding) or 2 (ShapeInput)");
+ return NULL;
+ }
+
+ gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
+
+ xrectangles = g_new(XRectangle, n_rectangles);
+ for (i = 0; i < n_rectangles; i++) {
+ /* Clamp to the short-int limits of XRectangle */
+ gdk_rectangle_intersect(&rectangles[i], &short_rect, &rectangles[i]);
+ xrectangles[i].x = rectangles[i].x;
+ xrectangles[i].y = rectangles[i].y;
+ xrectangles[i].width = rectangles[i].width;
+ xrectangles[i].height = rectangles[i].height;
+ }
+
+ XShapeCombineRectangles(GDK_WINDOW_XDISPLAY(window), GDK_WINDOW_XWINDOW(window),
+ kind,
+ 0, 0,
+ xrectangles, n_rectangles,
+ ShapeSet, YXBanded);
+
+ g_free(rectangles);
+ g_free(xrectangles);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
Modified: trunk/bigboard/bigboard-native.h
==============================================================================
--- trunk/bigboard/bigboard-native.h (original)
+++ trunk/bigboard/bigboard-native.h Fri Jun 27 20:48:37 2008
@@ -13,6 +13,7 @@
PyObject* bigboard_install_focus_docks_hack (PyObject *self, PyObject *args);
PyObject* bigboard_utf8_collate (PyObject *self, PyObject *args);
PyObject* bigboard_get_desktop_dir (PyObject *self, PyObject *args);
+PyObject * bigboard_window_shape_set_region (PyObject *self, PyObject *args, PyObject *kwargs);
G_END_DECLS
#endif /* __BIGBOARD_NATIVE_H__ */
Modified: trunk/bigboard/bignative.c
==============================================================================
--- trunk/bigboard/bignative.c (original)
+++ trunk/bigboard/bignative.c Fri Jun 27 20:48:37 2008
@@ -24,6 +24,8 @@
"Compare strings in lexical order."},
{"get_desktop_dir", (PyCFunction) bigboard_get_desktop_dir, METH_VARARGS,
"Get the user desktop directory."},
+ {"window_shape_set_region", (PyCFunction) bigboard_window_shape_set_region, METH_VARARGS | METH_KEYWORDS,
+ "Set the shape of a window to the given region."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Jun 27 20:48:37 2008
@@ -157,7 +157,7 @@
## it just isn't doing enough stuff to be another process
AM_CONDITIONAL(APPLET_INPROCESS, false)
-PKG_CHECK_MODULES(BIGBOARD, gtk+-2.0 >= 2.8 pygtk-2.0 >= 2.8 gnome-keyring-1)
+PKG_CHECK_MODULES(BIGBOARD, gtk+-2.0 >= 2.8 pygtk-2.0 >= 2.8 gnome-keyring-1 xext)
AC_SUBST(BIGBOARD_LIBS)
AC_SUBST(BIGBOARD_CFLAGS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]