|
|
Subscribe / Log in / New account

Timer slack for slacker developers

Timer slack for slacker developers

Posted Oct 18, 2011 14:40 UTC (Tue) by mjthayer (guest, #39183)
In reply to: Timer slack for slacker developers by neilbrown
Parent article: Timer slack for slacker developers

> The application is oblivious of the fact that the label never actually makes it to the display. It just keeps on wasting power generating labels that are never seen.
>
> It could find out though. It could connect to the "expose" event and only continue updating while the expose events are coming in.
>
> Getting this smooth and jitter free might be tricky.

Actually this isn't as bad as it sounds. The application can query the visibility state of the widget's window (and get notified when it changes), so it just has to keep a binary "on/off" state for updates. (I can't remember without checking whether there is a simple way to get information about which parts of a partially visible window are shown, but that would be much less important.)


to post comments

Timer slack for slacker developers

Posted Oct 18, 2011 21:25 UTC (Tue) by neilbrown (subscriber, #359) [Link] (1 responses)

It probably isn't as bad as I made it sound.

I don't think the 'visibility state' (notified by "mapped" and "unmapped" events) is really enough because it doesn't tell you when a window is fully obscured by another window.

However it wouldn't be too hard to synthesis a simple binary state for the whole window by watching expose events.

And you don't really need to put up a "waiting" image like I suggested - just do what firefox does and leave the contents of the screen like they were before - firefox window decorations wrapped around 2 xterms and an xclock which isn't ticking any more :-)

To play with mapped events, try:

#!/usr/bin/env python

import gtk

w = gtk.Window()
w.show()

def mapped(w,ev):
    print "mapped"

def unmapped(w, ev):
    print "unmapped"

w.connect('map-event',mapped)
w.connect('unmap-event',unmapped)
w.connect('destroy', lambda x:gtk.mainquit())

gtk.mainloop()

Timer slack for slacker developers

Posted Oct 19, 2011 8:03 UTC (Wed) by mjthayer (guest, #39183) [Link]

> I don't think the 'visibility state' (notified by "mapped" and "unmapped" events) is really enough because it doesn't tell you when a window is fully obscured by another window.

Actually I thought it did:

"When the window changes state [...] to viewable and fully obscured, the X server generates [a VisibilityNotify event] with the state member of the XVisibilityEvent structure set to VisibilityFullyObscured." [1]

(Hope I'm not getting too boring here!)

[1] http://tronche.com/gui/x/xlib/events/window-state-change/...


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds