How to create gtk+ windows without title bar with resize and move properties working.
I checked gtk_window_set_decorated
function, but it disable resize and move features of window. I found this answer already, but I don't think it has anything to do with it.
I tried to set resizeable true after gtk_window_set_decorated but still not working
Please check code
#include <gtk/gtk.h>
int main (int argc,
char *argv[])
{
GtkWidget *window;
/* Initialize GTK+ and all of its supporting libraries. */
gtk_init (&argc, &argv);
/* Create a new window, give it a title and display it to the user. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Hello World");
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
//gtk_window_set_gravity(GTK_WINDOW (window), GDK_GRAVITY_NORTH_EAST);
//gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
gtk_widget_show (window);
/* Hand control over to the main loop. */
gtk_main ();
return 0;
}
So what I found to work is to remove the header with gtk_window_set_decorated
set to FALSE. Then manually change the cursor and call gtk_window_begin_resize_drag()
to begin a resize on mousedown.
How I implemented this was to check if the mouse was near a border on a mousemove callback and if so change the cursor with gdk_window_set_cursor()
.
On a mousedown event near a border I call gtk_window_begin_resize_drag()
with the appropriate border.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With