[cairo-compmgr] Re: magnifier plugin prove of concept

[ Thread Index | Date Index | More lists.tuxfamily.org/cairo-compmgr Archives ]


Sorry, I just forget to include the attachments.

2008/1/18, Carlos Diógenes <cerdiogenes@xxxxxxxxx>:
> Hi,
>
> This is a initial implementation of a magnifier plugin, just as a
> prove of concept.
>
> I'm send this because I'm having the following issues:
>
> [1] This also doens't work very well :-). The magnified screen isn't
> draw right. Sometimes a window disappear, if you move a window with
> ALT + clicking and moving a window over the top panel, the window will
> override the panel and leave thrash in the magnified window.
>
> [2] Some work in menu-animation and shadow plugins must be done so
> they play well with the magnifier plugin.
>
> I really need some feedback about [1], since I don't know what is
> causing this. I disabled all the others plugins to try catch the
> problem easily, but I don't find the problem.
>
> The problems in [2] I don't investigate much, but regarding the
> menu-animation the conflicts are in impl_ccm_window_paint, in the
> cairo_translate call, since the division make the magnifier paint in
> wrong positions and without the division the menu-animation paint in
> wrong positions.
>
> Regarding the shadow plugin I don't investigate anything, so I have no
> idea what is wrong in the intereraction.
>
> Best regards,
> Carlos.
>
diff --git a/configure.ac b/configure.ac
index 04d3734..768c4db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,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..c0f8c83 100644
--- a/plugins/shadow/ccm-shadow.c
+++ b/plugins/shadow/ccm-shadow.c
@@ -267,7 +267,7 @@ ccm_shadow_paint(CCMWindowPlugin* plugin, CCMWindow* window,
 			
 			cairo_save(context);
 			cairo_get_matrix (context, &matrix);
-			cairo_translate (context, area.x / matrix.xx, area.y / matrix.yy);
+			cairo_translate (context, area.x, area.y);
 			cairo_set_source_surface(context, self->priv->shadow_right, 
 									 area.width - border * 2, offset);
 			cairo_paint_with_alpha(context,
diff --git a/src/ccm-screen-plugin.c b/src/ccm-screen-plugin.c
index 655167d..75f6465 100644
--- a/src/ccm-screen-plugin.c
+++ b/src/ccm-screen-plugin.c
@@ -72,11 +72,11 @@ ccm_screen_plugin_load_options(CCMScreenPlugin* self, CCMScreen* screen)
   		CCM_SCREEN_PLUGIN_GET_INTERFACE (plugin)->load_options (plugin, screen);
 }
 
-void
+gboolean
 ccm_screen_plugin_paint (CCMScreenPlugin* self, CCMScreen* screen)
 {
-	g_return_if_fail (CCM_IS_SCREEN_PLUGIN (self));
-	g_return_if_fail (screen != NULL);
+	g_return_val_if_fail (CCM_IS_SCREEN_PLUGIN (self), FALSE);
+	g_return_val_if_fail (screen != NULL, FALSE);
 	
   	CCMScreenPlugin* plugin;
 	for (plugin = self; 
@@ -85,7 +85,9 @@ ccm_screen_plugin_paint (CCMScreenPlugin* self, CCMScreen* screen)
 		 plugin = CCM_SCREEN_PLUGIN_PARENT(plugin));
 	
 	if (CCM_SCREEN_PLUGIN_GET_INTERFACE (plugin)->paint)
-  		CCM_SCREEN_PLUGIN_GET_INTERFACE (plugin)->paint (plugin, screen);
+  		return CCM_SCREEN_PLUGIN_GET_INTERFACE (plugin)->paint (plugin, screen);
+	else
+		return FALSE;
 }
 
 gboolean
diff --git a/src/ccm-screen-plugin.h b/src/ccm-screen-plugin.h
index 8c63b64..49ee30d 100644
--- a/src/ccm-screen-plugin.h
+++ b/src/ccm-screen-plugin.h
@@ -44,7 +44,7 @@ struct _CCMScreenPluginClass
 	GTypeInterface    base_iface;
 	
 	void 	 (*load_options)	(CCMScreenPlugin* self, CCMScreen* screen);
-	void 	 (*paint) 			(CCMScreenPlugin* self, CCMScreen* screen);
+	gboolean (*paint) 			(CCMScreenPlugin* self, CCMScreen* screen);
 	gboolean (*add_window) 		(CCMScreenPlugin* self, CCMScreen* screen,
 								 CCMWindow* window);
 	void	 (*remove_window) 	(CCMScreenPlugin* self, CCMScreen* screen,
@@ -55,7 +55,7 @@ GType 		ccm_screen_plugin_get_type 		(void) G_GNUC_CONST;
 
 void  		ccm_screen_plugin_load_options	(CCMScreenPlugin* self, 
 										   	 CCMScreen* screen);
-void  		ccm_screen_plugin_paint	 	  	(CCMScreenPlugin* self, 
+gboolean	ccm_screen_plugin_paint	 	  	(CCMScreenPlugin* self, 
 										     CCMScreen* screen);
 gboolean 	ccm_screen_plugin_add_window  	(CCMScreenPlugin* self, 
 											 CCMScreen* screen,
diff --git a/src/ccm-screen.c b/src/ccm-screen.c
index 3d424bc..93f0607 100644
--- a/src/ccm-screen.c
+++ b/src/ccm-screen.c
@@ -92,7 +92,7 @@ struct _CCMScreenPrivate
 #define CCM_SCREEN_GET_PRIVATE(o)  \
    ((CCMScreenPrivate*)G_TYPE_INSTANCE_GET_PRIVATE ((o), CCM_TYPE_SCREEN, CCMScreenClass))
 
-static void impl_ccm_screen_paint(CCMScreenPlugin* plugin, CCMScreen* self);
+static gboolean impl_ccm_screen_paint(CCMScreenPlugin* plugin, CCMScreen* self);
 static gboolean impl_ccm_screen_add_window(CCMScreenPlugin* plugin, 
 										   CCMScreen* self, CCMWindow* window);
 static void impl_ccm_screen_remove_window(CCMScreenPlugin* plugin, 
@@ -399,10 +399,10 @@ ccm_screen_restack(CCMScreen* self, CCMWindow* above, CCMWindow* below)
 	ccm_drawable_damage (CCM_DRAWABLE(above));
 }
 
-static void 
+static gboolean
 impl_ccm_screen_paint(CCMScreenPlugin* plugin, CCMScreen* self)
 {
-	g_return_if_fail(self != NULL);
+	g_return_val_if_fail(self != NULL, FALSE);
 	
 	static gboolean have_desktop = FALSE;
 	gboolean ret = FALSE;
@@ -458,6 +458,8 @@ impl_ccm_screen_paint(CCMScreenPlugin* plugin, CCMScreen* self)
 				ccm_drawable_flush(CCM_DRAWABLE(self->priv->cow));
 		}
 	}
+
+	return ret;
 }
 
 static gboolean
@@ -959,11 +961,19 @@ _ccm_screen_use_buffered(CCMScreen* self)
 }
 
 CCMScreenPlugin*
-_ccm_screen_get_plugin(CCMScreen *self)
+_ccm_screen_get_plugin(CCMScreen *self, GType type)
 {
 	g_return_val_if_fail(self != NULL, NULL);
+
+	CCMScreenPlugin* plugin;
 	
-	return self->priv->plugin;
+	for (plugin = self->priv->plugin; plugin != (CCMScreenPlugin*)self; plugin = CCM_SCREEN_PLUGIN_PARENT(plugin))
+	{
+		if (g_type_is_a(G_OBJECT_TYPE(plugin), type))
+			return plugin;
+	}
+	
+	return NULL;
 }
 
 GSList*
diff --git a/src/ccm-screen.h b/src/ccm-screen.h
index a6af249..e8e820b 100644
--- a/src/ccm-screen.h
+++ b/src/ccm-screen.h
@@ -65,7 +65,7 @@ gboolean		 _ccm_screen_sync_with_blank 	(CCMScreen* self);
 GSList*			 _ccm_screen_get_window_plugins	(CCMScreen* self);
 gchar*			 _ccm_screen_get_window_backend	(CCMScreen* self);
 gboolean		 _ccm_screen_native_pixmap_bind (CCMScreen* self);
-CCMScreenPlugin* _ccm_screen_get_plugin			(CCMScreen *self);
+CCMScreenPlugin* _ccm_screen_get_plugin			(CCMScreen *self, GType type);
 void			 _ccm_screen_add_animation		(CCMScreen* self, 
 												 CCMAnimation* animation);
 void			 _ccm_screen_remove_animation	(CCMScreen* self, 
diff --git a/src/ccm-window.c b/src/ccm-window.c
index 675deb0..e8b6e45 100644
--- a/src/ccm-window.c
+++ b/src/ccm-window.c
@@ -608,12 +608,16 @@ impl_ccm_window_paint(CCMWindowPlugin* plugin, CCMWindow* self,
 	
 	cairo_rectangle_t geometry;
 	cairo_matrix_t matrix;
+
+	cairo_save (context);
 	
 	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, geometry.y);
 	cairo_set_source_surface(context, surface, 0.0f, 0.0f);
 	cairo_paint_with_alpha(context, self->priv->opacity);
+
+	cairo_restore (context);
 		
 	return TRUE;
 }

Attachment: magnifier.tar.bz2
Description: BZip2 compressed data



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/