Stop GTK from dragging the window when grabbed by background - gtk

I'm using GTK on Linux. (Both GTK2 and GTK3 exhibit this behavior.)
When you grab the window on some free space or menubar, the window itself gets dragged.
I'm using the window as a giant OpenGL canvas, and this prevents the primary mouse button presses from ever reaching the window. Double-clicks and secondary button presses arrive just fine.
How do I disable or work around this behavior? I've also tried adding a GtkDrawingArea to the window, but it still gets dragged.

This is not possible. GTK overrides the function of primary mouse button unconditionally. However, simply adding an empty GtkLabel to the window worked just well for me.
Edit: eventually I just used a GtkDrawingArea, because I also wanted a scroll/menubar. That works just as well.

Gtk does grab unconditionally, but you have full control of what that specific "click" will do.
Returning True from any "button-xxx" method will stop further processing from Gtk. See "Return type" here.

Related

Widget sensitive/gray look change with window focus causes too much delay

I like to adjust or disable a feature of gtk3 (or gnome-shell?) because it causes a delay or at least need to remove the delay when bringing a window in/out of focus. My multi window application suffers from this delay:
I see is that all widgets like buttons, entries, etc. are set to in-sensitive/gray look at time the window they are contained is loosing focus and they return to normal when the window focus returns. I tried to turn off animations, but that does not disable this behavior.
My old program version based on gtk2 based does not have this feature (same gnome shell). So I conclude gtk3 is some how managing this.
I so far was not able to find out how to disable this.
This is part of the default (Adwaita) desktop theme, and as such you can't disable it for one application. Each window's widgets get the :backdrop CSS pseudo-class when it is not the active window, and the Adwaita theme styles them that way.
Your best bet is to pick another desktop theme.

GTK3 ComboboxText on touchscreen

I have a problem with above mentioned widget on touchscreen (Elo). List of options is visible only while widget is pressed. This is different behavior to that one with mouse as pointer. After mouse left click list of options appears and waits for user choice.
I`m using Perl 5.22, and GTK3 (3.18.2) and Perl Gtk3 wrapper library (0.025).
I think this is likely due to this bug (which has not yet been fixed) in GTK3:
https://bugzilla.gnome.org/show_bug.cgi?id=333470
It seems that if you move the mouse pointer at all after pressing on the combo box (which is likely to happen on a touchscreen) it will be interpreted as a selection, instead of keeping the options open for selection.

Undecorated window loses native events

I use Decorated = false to make a frameless, borderless window with gtk#. This means adding my own drag logic and events for minimizing and closing the window, fine. However in Windows (at least), the window loses its native minimize/restore/close animations and I'm unable to minimize the window by clicking in the taskbar as you usually can.
Is there a way to have an undecorated window in gtk and still get the native minimize/restore animations or at least being able to minimize it from the taskbar?
I've experienced this as well. It is my understanding (maybe incorrect) that such features are a part of the windowing for the application. With it undecorated they simply don't exist in the taskbar. You might be able to create "Tasks" that are available when you right-click on the taskbar icon, but I have no experience with doing so. I believe those are technically called "JumpLists" or something like that.

gtk2 and gtk3 : how do you apply a style onto the default button?

In gtk2 (.rc) and GTk3 (.css) how do you theme the default button in a dialog ?
(The one that will be activated when hitting enter)
In Lubuntu 12.10, the default theme (/usr/share/themes/Lubuntu-default) has a file in the gtk-2.0 folder called button.rc. There are five "states" listed: normal, prelight, insensitive, active, and focus. It is my impression (from a bit of fiddling), that the "focus" state represents the one you are interested in. In other words, if a window with a few buttons is present, it is the button in the focus state that will be "pressed" or "clicked" by hitting enter.
In Lubuntu 12.10, the screen that appears when you click "Logout" from the main menu (or run lubuntu-logout from a terminal) illustrates this well. Of the seven "buttons" that appear, the topmost one, Shutdown, is shaded slightly differently (or has a focus ring) whereas the other six are similar to each other except for the text. Hitting "enter" without doing anything else is equivalent to clicking the "Shutdown" button.
I too am trying to figure out how to make the button in focus, if we call it that, a bit more contrasty.
For the gtk2 side of things, if you're happy with making the focus ring more obvious (but a bit more ugly), editing the theme's gtkrc may be one way. Look for a section captioned style "default" and then for a line that has something like
GtkWidget ::focus-line-width = 1
Changing 1 to 2 or 3 will make the focus ring more obvious.
(I haven't got round to looking at gtk3 apps.)

GTK window hints

I'm trying to get a window to cover the whole screen. Its positioning and dimensions is fine but it gets covered by the Gnome panel. To complicate things I have two monitors and this app needs to support people with multiple screens.
WINDOW_TYPE_HINT_SPLASHSCREEN is a good start. It covers both screens but not the panel. It's still there, just behind the panel.
WINDOW_TYPE_HINT_DOCK looked ideal but I need this window to take focus to listen to a keyboard event. _DOCK seems like it purposely ignores keyboard events (which kind of makes sense). Can I force it to take keyboard focus?
Is there some way I can force a hinted window to cover the panel?
There's window.fullscreen() which you can call on a normal "un-hinted" window. I assume this lets the window manager decide whether the window should cover the panel or not.
If you use the WINDOW_TYPE_HINT_MENU, you can give the focus to the window by calling the gtk_window_present() function.
However, I don't know if you will be able to cover the panel.
Another hint: the panel probably change its _NET_WM_STRUT property so that other windows cannot cover it. Maybe you will have to play with this property (or another) in your window.