Dragging unadorned windows in GTK+

Back on January 21, I added the ability to use an image with transparency to define the shape of the calculator window, using call gdk_pixbuf_render_threshold_alpha() and gtk_widget_shape_combine_mask(). When this is used, there is no menu bar and gtk_window_set_decorated() is called to avoid having the usual window manager frame and decorations. Unfortunately this meant that there was no way to move the window.

I just figured out how to allow dragging the window by putting an event box inside the window, and the usual packing vbox inside that. Then a handler for a button_press_event on the event box can call gtk_window_begin_move_drag(). This works with the click anywhere except in the calculator buttons. I’m not sure whether I should make it more restrictive, so that trying to click a button and missing slightly doesn’t start a drag.

I still need to support a popup menu. Initially I think I’ll do that using a right-click in the same event box, but I probably should add KML syntax to specify coordinates of a menu button.

This entry was posted in Calculators, Nonpareil. Bookmark the permalink.

Leave a Reply