losing events with popup widget



Hi,

I'm trying to write a widget that consists of a button which, when
clicked on, will popup a slider that grabs focus directly, meant for
changing volume in applications (Totem).

So for that, I've built a GtkButton-derived widget, and on
button_press_event, I popup a window containing a GtkVScale which grabs
input. If I release the mouse directly after the press ('click'), the
window stays popped up until I click outside the window. Else (so if I
press but not release within 200ms), the window will disappear as soon
as the mouse is released. This allows for press-and-slide behaviour.

My problem is that I seem to lose events. I've put my code online
(http://ronald.bitfreak.net/volume.tar.gz - two .c files, one .h file
(the widget plus the app) and a Makefile) so you can look at it.

The problem is that the code in the tarball will never 'release' the
trough (that thing that you slide up and down to change the value of the
GtkVScale) of the popped up scale-window. So if I click the mouse on the
button (press and release instantly), my slider will popup, but (without
having the mouse pressed) the trough will continue to move along with
mouse movement. This is not intended. I think this is because of the
'return TRUE;' in line 309 of button.c, which (according to the docs)
means the signal is not further propagated. However, changing that to
'return FALSE;' (although fixing it) will cause other problems: now,
when clicking the button (press and release instantly) will indeed cause
the trough to be released, but if I click outside the widget, it will
not release the grabbed input (the event never gets in the
button_release handler), requiring you to switch terminals and kill the
app to regain control over your desktop. This is obviously even worse; I
have no clue why this happens. In this second case, the grab doesn't
seem complete, since the spinbutton still receives events (although
other parts of the desktop still don't). Again, I don't understand
what's going on here. :(.

What I'd like, ideally, is that it releases grab if I click outside the
popup widget, and it releases the trough if I click (press and immediate
release) the button.

Can someone help me fix this?

thanks,
Ronald
-- 
Ronald S. Bultje <rbultje ronald bitfreak net>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]