Enabling window dragging on specific elements in GTK 4

How I can specify that certain parts of the application should be allowed to start a window dragging operation (when such an operation is supported by the windowing manager)? The -GtkWidget-window-dragging CSS attribute seems to no longer be supported in GTK4 and I don’t know how to proceed without it.

You can put your widgets inside a GtkWindowHandle widget. That should do it if I understand your question correctly.


1 Like

Thank you, I wasn’t aware of that widget and it will help in some cases. Could you perhaps explain how I could use that to make a message dialog draggable? I don’t know how to put the dialog inside a widget, as the dialog window is at the root of its own hierarchy. (The message dialog doesn’t have a header bar of its own.)

You might use gdk_window_begin_move_drag (GTK3) or gdk_toplevel_begin_move (GTK4).

Thanks, gdk_toplevel_begin_move looks useful here, I’ll give it a try.

You don’t, but that may make sense to do upstream instead? Having message dialogs be only draggable by a tiny header was never great.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.