| [cairo-compmgr] magnifier plugin |
[ Thread Index | Date Index | More lists.tuxfamily.org/cairo-compmgr Archives ]
Hi, Attached is a example implementation of a magnifier plugin. It still lacks much things that a magnifier must have, like the ability to an external application, like Orca, start and finalize it (so a support to load and unload plugins on the fly is needed), but I think that how it's fit in the actual code base is fine. I also want to support the gnome-mag API[1] in this plugin, so screen readers can use it to magnify portions of the screen, so I will start to explore how to use D-BUS in ccm. Any comments on this will be very appreciated. Best regards, Carlos. [1] http://svn.gnome.org/viewvc/gnome-mag/trunk/idl/GNOME_Magnifier.idl?annotate=664
diff --git a/configure.ac b/configure.ac
index 750513b..342dca9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,7 @@ plugins/opacity/Makefile
plugins/fade/Makefile
plugins/freeze/Makefile
plugins/menu-animation/Makefile
+plugins/magnifier/Makefile
data/Makefile
data/cairo-compmgr.desktop.in
])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 75fedc5..e792782 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -4,7 +4,8 @@ SUBDIRS = \
opacity\
fade \
freeze \
- menu-animation
+ menu-animation \
+ magnifier
## File created by the gnome-build tools
diff --git a/plugins/shadow/ccm-shadow.c b/plugins/shadow/ccm-shadow.c
index e9d294e..659867d 100644
--- a/plugins/shadow/ccm-shadow.c
+++ b/plugins/shadow/ccm-shadow.c
@@ -261,13 +261,19 @@ ccm_shadow_paint(CCMWindowPlugin* plugin, CCMWindow* window,
gint nb_rects, cpt;
cairo_matrix_t matrix;
int border, offset;
+ CCMScreen *screen = ccm_drawable_get_screen (CCM_DRAWABLE (window));
+ gfloat *x_scale, *y_scale;
+
+ x_scale = g_object_get_data (G_OBJECT (screen), "x_scale");
+ y_scale = g_object_get_data (G_OBJECT (screen), "y_scale");
border = ccm_config_get_integer(self->priv->options[CCM_SHADOW_BORDER]);
offset = ccm_config_get_integer(self->priv->options[CCM_SHADOW_OFFSET]);
cairo_save(context);
cairo_get_matrix (context, &matrix);
- cairo_translate (context, area.x / matrix.xx, area.y / matrix.yy);
+ cairo_translate (context, area.x / matrix.xx * (*x_scale),
+ area.y / matrix.yy * (*y_scale));
cairo_set_source_surface(context, self->priv->shadow_right,
area.width - border * 2, offset);
cairo_paint_with_alpha(context,
@@ -281,7 +287,8 @@ ccm_shadow_paint(CCMWindowPlugin* plugin, CCMWindow* window,
ccm_region_get_rectangles (self->priv->geometry, &rects, &nb_rects);
for (cpt = 0; cpt < nb_rects; cpt++)
{
- cairo_rectangle(context, rects[cpt].x / matrix.xx, rects[cpt].y / matrix.yy,
+ cairo_rectangle(context, rects[cpt].x / matrix.xx * (*x_scale),
+ rects[cpt].y / matrix.yy * (*y_scale),
rects[cpt].width, rects[cpt].height);
}
g_free(rects);
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index d2d4e4c..b630d54 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -25,7 +25,7 @@ SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
-top_builddir = ..
+top_builddir = @top_builddir@
VPATH = @srcdir@
prefix = @prefix@
@@ -56,15 +56,19 @@ ALL_LINGUAS = @ALL_LINGUAS@
PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi)
-POFILES=$(shell if test -n "$(PO_LINGUAS)"; then LINGUAS="$(PO_LINGUAS)"; else LINGUAS="$(ALL_LINGUAS)"; fi; for lang in $$LINGUAS; do printf "$$lang.po "; done)
+USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS`" -o -n "`echo $$ALINGUAS|grep ' ?$$lang ?'`"; then printf "$$lang "; fi; done; fi)
+
+USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done)
+
+POFILES=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(POFILES)
EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
POTFILES = \
-#This Gets Replace for some reason
+# This comment gets stripped out
-CATALOGS=$(shell if test -n "$(PO_LINGUAS)"; then LINGUAS="$(PO_LINGUAS)"; else LINGUAS="$(ALL_LINGUAS)"; fi; for lang in $$LINGUAS; do printf "$$lang.gmo "; done)
+CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done)
.SUFFIXES:
.SUFFIXES: .po .pox .gmo .mo .msg .cat
@@ -98,11 +102,7 @@ install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
$(mkdir_p) $(DESTDIR)$(itlocaledir)
- if test -n "$(PO_LINGUAS)"; then \
- linguas="$(PO_LINGUAS)"; \
- else \
- linguas="$(ALL_LINGUAS)"; \
- fi; \
+ linguas="$(USE_LINGUAS)"; \
for lang in $$linguas; do \
dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \
$(mkdir_p) $$dir; \
@@ -133,20 +133,21 @@ install-data-yes: all
dvi info tags TAGS ID:
# Define this as empty until I found a useful application.
-installcheck:
+install-exec installcheck:
uninstall:
- if test -n "$(PO_LINGUAS)"; then \
- linguas="$(PO_LINGUAS)"; \
- else \
- linguas="$(ALL_LINGUAS)"; \
- fi; \
+ linguas="$(USE_LINGUAS)"; \
for lang in $$linguas; do \
rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \
done
check: all $(GETTEXT_PACKAGE).pot
+ rm -f missing notexist
+ srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m
+ if [ -r missing -o -r notexist ]; then \
+ exit 1; \
+ fi
mostlyclean:
rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
@@ -179,11 +180,7 @@ dist distdir: $(DISTFILES)
update-po: Makefile
$(MAKE) $(GETTEXT_PACKAGE).pot
tmpdir=`pwd`; \
- if test -n "$(PO_LINGUAS)"; then \
- linguas="$(PO_LINGUAS)"; \
- else \
- linguas="$(ALL_LINGUAS)"; \
- fi; \
+ linguas="$(USE_LINGUAS)"; \
for lang in $$linguas; do \
echo "$$lang:"; \
result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
@@ -211,8 +208,8 @@ Makefile POTFILES: stamp-it
$(MAKE) stamp-it; \
fi
-stamp-it: Makefile.in.in ../config.status POTFILES.in
- cd .. \
+stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in
+ cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \
$(SHELL) ./config.status
diff --git a/src/ccm-screen-plugin.h b/src/ccm-screen-plugin.h
diff --git a/src/ccm-screen.c b/src/ccm-screen.c
index d3e33b1..47a304c 100644
--- a/src/ccm-screen.c
+++ b/src/ccm-screen.c
@@ -105,6 +105,9 @@ static void on_window_damaged(CCMScreen* self, CCMRegion* area,
static void
ccm_screen_init (CCMScreen *self)
{
+ gint *magrun;
+ gfloat *x_scale, *y_scale;
+
self->priv = CCM_SCREEN_GET_PRIVATE(self);
self->priv->display = NULL;
@@ -118,6 +121,22 @@ ccm_screen_init (CCMScreen *self)
self->priv->id_paint = 0;
self->priv->plugin_loader = NULL;
self->priv->animations = NULL;
+
+ x_scale = g_object_get_data (G_OBJECT (self), "x_scale");
+ y_scale = g_object_get_data (G_OBJECT (self), "y_scale");
+ magrun = g_object_get_data (G_OBJECT (self), "mag_run");
+
+ if (!magrun) magrun = g_new (gint, 1);
+
+ if (!x_scale) x_scale = g_malloc (sizeof (gfloat));
+ if (!y_scale) y_scale = g_malloc (sizeof (gfloat));
+
+ *magrun = 0;
+ *x_scale = *y_scale = 1.0f;
+
+ g_object_set_data (G_OBJECT (self), "x_scale", x_scale);
+ g_object_set_data (G_OBJECT (self), "y_scale", y_scale);
+ g_object_set_data (G_OBJECT (self), "mag_run", magrun);
}
static void
@@ -433,8 +452,14 @@ impl_ccm_screen_paint(CCMScreenPlugin* plugin, CCMScreen* self, cairo_t* ctx)
if (!window->is_input_only)
{
- if (ccm_window_paint(window, self->priv->ctx))
- ret = TRUE;
+ gboolean *mag_run = g_object_get_data (G_OBJECT (self), "mag_run");
+ if (*mag_run) {
+ if (ccm_window_paint(window, self->priv->ctx, FALSE))
+ ret = TRUE;
+ } else {
+ if (ccm_window_paint(window, self->priv->ctx, TRUE))
+ ret = TRUE;
+ }
}
}
@@ -1173,3 +1198,19 @@ ccm_screen_damage_region(CCMScreen* self, CCMRegion* area)
}
}
}
+
+GList*
+ccm_screen_get_windows (CCMScreen *self)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+
+ return self->priv->windows;
+}
+
+CCMRegion*
+ccm_screen_get_damaged (CCMScreen *self)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+
+ return self->priv->damaged;
+}
diff --git a/src/ccm-window.c b/src/ccm-window.c
index 675deb0..5552349 100644
--- a/src/ccm-window.c
+++ b/src/ccm-window.c
@@ -608,10 +608,16 @@ impl_ccm_window_paint(CCMWindowPlugin* plugin, CCMWindow* self,
cairo_rectangle_t geometry;
cairo_matrix_t matrix;
+ CCMScreen *screen = ccm_drawable_get_screen (CCM_DRAWABLE (self));
+ gfloat *x_scale, *y_scale;
+
+ x_scale = g_object_get_data (G_OBJECT (screen), "x_scale");
+ y_scale = g_object_get_data (G_OBJECT (screen), "y_scale");
ccm_drawable_get_geometry_clipbox (CCM_DRAWABLE(self), &geometry);
cairo_get_matrix (context, &matrix);
- cairo_translate (context, geometry.x / matrix.xx, geometry.y / matrix.yy);
+ cairo_translate (context, geometry.x / matrix.xx * (*x_scale),
+ geometry.y / matrix.yy * (*y_scale));
cairo_set_source_surface(context, surface, 0.0f, 0.0f);
cairo_paint_with_alpha(context, self->priv->opacity);
@@ -1077,7 +1083,7 @@ ccm_window_set_opacity (CCMWindow* self, gfloat opacity)
}
gboolean
-ccm_window_paint (CCMWindow* self, cairo_t* context)
+ccm_window_paint (CCMWindow* self, cairo_t* context, gboolean repair)
{
g_return_val_if_fail(self != NULL, FALSE);
g_return_val_if_fail(context != NULL, FALSE);
@@ -1090,7 +1096,7 @@ ccm_window_paint (CCMWindow* self, cairo_t* context)
return ret;
cairo_save(context);
- cairo_reset_clip (context);
+ /* cairo_reset_clip (context); */
damaged = ccm_drawable_get_damage_path(CCM_DRAWABLE(self), context);
cairo_clip(context);
@@ -1119,7 +1125,8 @@ ccm_window_paint (CCMWindow* self, cairo_t* context)
}
cairo_restore(context);
- if (ret) ccm_drawable_repair(CCM_DRAWABLE(self));
+ if (ret)
+ if (repair) ccm_drawable_repair(CCM_DRAWABLE(self));
return ret;
}
diff --git a/src/ccm.h b/src/ccm.h
index 172e958..e8ae5eb 100644
--- a/src/ccm.h
+++ b/src/ccm.h
@@ -172,6 +172,7 @@ void ccm_screen_damage_region (CCMScreen* self,
void ccm_screen_restack (CCMScreen* self,
CCMWindow* above,
CCMWindow* below);
+GList* ccm_screen_get_windows (CCMScreen *self);
/******************************************************************************/
/****************************** Drawable **************************************/
@@ -219,7 +220,7 @@ CCMPixmap* ccm_window_get_pixmap (CCMWindow* self);
cairo_format_t ccm_window_get_format (CCMWindow* self);
guint ccm_window_get_depth (CCMWindow* self);
gboolean ccm_window_paint (CCMWindow* self,
- cairo_t* ctx);
+ cairo_t* ctx, gboolean repair);
void ccm_window_map (CCMWindow* self);
void ccm_window_unmap (CCMWindow* self);
void ccm_window_query_opacity (CCMWindow* self);
Attachment:
magnifier.tar.bz2
Description: BZip2 compressed data
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |