GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Apr 25, 2014 5:04 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Custom expose event problems
PostPosted: Tue Nov 08, 2011 4:22 pm 
Offline

Joined: Tue Nov 08, 2011 4:06 pm
Posts: 3
Hi. I'm writing an xfce panel plugin in vala to embed the famous gnome DockBarX applet. Since it provides a desktop-agnostic gtk widget, I figured that it should be doable. Except that it's in python. I couldn't just write the entire plugin in python, because the python bindings for xfce are out of date. Since I don't know of any way to do interoperability between vala and python, I decided to use plugs and sockets to get it in there. The vala plugin provides the socket, and a little python program makes the plug. It worked! Except that it had a gray background, which was jarring considering the rest of the panel has a nice fading translucent gradient. I couldn't find any way to gracefully get rid of that, so I looked around and decided to fake it with an expose event. That worked! ...almost. When I started selecting different windows, the effect for the selected window stayed on the old one, and started cropping up as I went back and forth, resulting in this:

Image

This behavior doesn't occur when I don't have the custom expose (in other words, with the gray background). I've been googling for entirely too long, and I am out of energy. I feel like I have scoured every corner of the internet for advice on what to do about this. I have no idea what to do to make this go away. Here's the python code for the plug, which does most of the work. Can anyone tell me what to do to fix this?

Code:
from dockbarx.log import *
import sys
log_to_file()
sys.stderr = StdErrWrapper()
sys.stdout = StdOutWrapper()

import pygtk
pygtk.require("2.0")
import gtk
import dockbarx.dockbar
import cairo

class DockBarXPlug(gtk.Plug):
    __gsignals__ = {"expose-event": "override"}
    def __init__(self, socket=0, panel_bg=""):
       gtk.Plug.__init__(self, socket)
       self.panel_bg = panel_bg
        self.connect("destroy",self.__destroy)
        self.set_app_paintable(1);
        gtk_screen = gtk.gdk.screen_get_default()
        colormap = gtk_screen.get_rgba_colormap()
        if colormap is None:
            colormap = gtk_screen.get_rgb_colormap()
        self.set_colormap(colormap)

        self.dockbar = dockbarx.dockbar.DockBar(parent_window=self)
        self.add(self.dockbar.container)
        self.show_all()

    def do_expose_event(self, event):
        self.window.set_back_pixmap(None, False)
        self.ctx = self.window.cairo_create()
        if self.is_composited():
            self.ctx.set_source_rgba(1, 1, 1, 0)
        else:
            self.ctx.set_source_rgb(0.8, 0.8, 0.8)
        self.ctx.set_operator(cairo.OPERATOR_SOURCE)
        self.ctx.paint()
        self.ctx.rectangle(event.area.x, event.area.y,
                           event.area.width, event.area.height)
        self.ctx.clip()
        self.ctx.set_operator(cairo.OPERATOR_OVER)
        surface = cairo.ImageSurface.create_from_png(self.panel_bg)
        pattern = cairo.SurfacePattern(surface)
        pattern.set_extend(cairo.EXTEND_REPEAT)
        self.ctx.set_source(pattern)
        self.ctx.paint()
        gtk.Plug.do_expose_event(self, event)
        if self.get_child():
            self.propagate_expose(self.get_child(), event)

    def __destroy (self,widget,data=None):
        gtk.main_quit()

    def main(self):
        gtk.main()

socket = 0
panel_bg = ""
if "--socket" in sys.argv:
    i = sys.argv.index("--socket") + 1
    try:
        socket = int(sys.argv[i])
    except:
        raise
if "--bg" in sys.argv:
    i = sys.argv.index("--bg") + 1
    try:
        panel_bg = sys.argv[i]
    except:
        raise
dockbarxplug = DockBarXPlug(socket, panel_bg)
dockbarxplug.main()


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Thu Nov 10, 2011 5:19 am 
Offline
Familiar Face

Joined: Thu Nov 10, 2011 5:07 am
Posts: 5
Hi. I'm the developer of DockbarX. I'm really glad to hear about your project and think perhaps I can help you with your problem. In line 65 (or somewhere around that line) of cairowidgets.py there's a line that says
Code:
self.area.window.clear_area(a.x, a.y, a.width, a.height)

Try replacing it with
Code:
self.area.window.clear_area_e(a.x, a.y, a.width, a.height)

and see if that helps.

If I understood correctly the clear_area command doesn't work when
Code:
self.window.set_back_pixmap(None, False)

is used and you use that in your do_expose function.

Do you have your code available anywhere? I'd like to include it in the next version (and perhaps use it to make a similar plug for the lxde panel) if that's ok with you.


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Thu Nov 10, 2011 6:16 pm 
Offline

Joined: Tue Nov 08, 2011 4:06 pm
Posts: 3
Oh, hi there! It's me, the guy who ported Namebar to xfce4/vala. I was thinking about doing the same for DockBarX, but I really wanted the functionality ASAP, and it's waaay too big to consider porting while I'm both in school and working. So I decided to find a way to shove DockBarX into a plugin as-is. It's good to see you giving me a helping hand yet again! :D

I had actually found a way to get this working before you posted: by creating the dockbar with run_as_dock=True and adding the add_window and remove_window methods that it wanted in order to run that way. I didn't know why it worked that way at the time, but it did with the gotchas that I needed those two functions, and when I changed the theme, it wouldn't refresh. I probably needed to add more stuff to make the plug pretend to be dockx.

However, I like your way better, even though it requires modifying dockbarx code. When I went to make the change you suggested, I noticed that the reason my first solution worked is because when run_as_dock is True, it ends up using that function that you mentioned. Why isn't that used in all cases, if you don't mind me asking?

As for the availability of my code, not just yet. I still need to add some bits to get the plug to fake integration with the rest of the panel. Right now, it only loads my panel background and mine only. As soon as it's ready though, you'll definitely be the first to know, and I would be honored to have you include it. :D The only catch is that it needs the vala code that goes with it. I'd have just done it in python, but there are no updated bindings, and the ones in git only do 4.6 plugin emulation... which is basicallly plugs and sockets. The exact same thing I'm doing. Since vala bindings are more readily available and up-to-date, I decided to bridge the two.

I also updated xfce4-namebar-plugin to XFCE 4.8, though to be honest, I'd like to host it on Google Code instead of your Launchpad. The only reason why is because I don't like bzr at all. I prefer svn.


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Sat Nov 12, 2011 6:48 am 
Offline
Familiar Face

Joined: Thu Nov 10, 2011 5:07 am
Posts: 5
The reason clera_area is used instead of clear_area_e is that clear_area_e does some extra redrawing that isn't needed for the applet. I tried using clear_area_e for the gnome applet when making dockx but I either it was slower or showed some flicker, can't remember exactly what it was but I decided it was a bad idea to use it.

By the way did you ever try to set the background as the back_pixmap instead of using a do_expose function? I think that would be a more elegant solution if it works.


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Sun Nov 13, 2011 2:10 pm 
Offline

Joined: Sun Nov 13, 2011 2:06 pm
Posts: 1
TiZ, glad your initiative. I look forward to working plug-in, ready to help in testing. Thank you for the right job, it's probably the only way to include great dockbarx in xfce-panel.


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Mon Dec 05, 2011 5:15 pm 
Offline
Familiar Face

Joined: Thu Nov 10, 2011 5:07 am
Posts: 5
Any progress?


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Mon Dec 05, 2011 5:27 pm 
Offline

Joined: Tue Nov 08, 2011 4:06 pm
Posts: 3
Yes, actually. It's mostly done, but I've just been really busy as of late, so I haven't been able to tweak on it and fix one of the last bugs left. It's not working quite right in non-composited environments at the moment, but once I get into finals week, I'll release this and the new xfce4-namebar-plugin with it.

Sorry for the lull.


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Mon Jan 09, 2012 12:20 pm 
Offline

Joined: Mon Jan 09, 2012 12:15 pm
Posts: 1
(Translated from french by Google Translate ... Sorry. ^^')

Hi TiZ! :)
Have you heard about the progress of these projects?


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Tue Jan 24, 2012 8:48 pm 
Offline
Familiar Face

Joined: Thu Nov 10, 2011 5:07 am
Posts: 5
Any further progress?


Top
 Profile  
 
 Post subject: Re: Custom expose event problems
PostPosted: Tue Mar 20, 2012 7:26 am 
Offline
Familiar Face

Joined: Thu Nov 10, 2011 5:07 am
Posts: 5
Are you still working on this? Releasing half-finished code would be better than nothing... This is _the_ feature I would like to have in the next DockbarX release, which has been postponed for far too long now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group