Reputation: 21
I want to maximize my Widget and then make it non-resizable. I can maximize the Widget with:
gtk_window_maximize(GTK_WINDOW(window));
But when I try to make it non-resizable with:
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
The window lost its maximized state; it returned to its original size.
Why? How can a Widget be maximized and made non-resizable?
Upvotes: 2
Views: 357
Reputation: 2702
Disclaimer: This answer is proposed as a workaround only, and does not actually solve the problem.
After following @ptomato's link, this is the closest thing I got:
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(win);
GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(win));
GdkRectangle rect;
gdk_screen_get_monitor_workarea(screen, 0, &rect);
gtk_window_move(GTK_WINDOW(win), rect.x, rect.y);
gtk_widget_set_size_request(win, rect.width, rect.height);
gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
gtk_main();
return 0;
}
However, this is still not perfect, and differs from a maximised window in the following ways (tested using the default Ubuntu 14.04 theme):
The width and height of the window is very slightly larger (by a few pixels) than the monitor size minus the title bar and the launch bar.
In addition to the system title bar the window also has its own title bar.
You can move the window around, while you shouldn't be able to if it is maximised.
Upvotes: 2