I have been trying to set a widget’s window to fullscreen.
I tried getting the root window of the widget using gtk_widget_get_root(_window) and then using gtk_window_fullscreen() to set it to fullscreen, but the documentation says that gtk_widget_get_root_window() and gtk_widget_get_parent_window() (which I tried too) return a GdkWindow *, not a GtkWindow * as needed.
I tried casting GdkWindow* to GtkWindow* but it gives me this error:
Gtk-CRITICAL **: IA__gtk_window_fullscreen: assertion `GTK_IS_WINDOW
(window)’ failed
The code would look like this:
gtk_window_fullscreen (GTK_WINDOW(gtk_widget_get_root_window (widget)));
I’ve also noticed that a widget has a field “window” but it is also GdkWindow * type.
I don’t have the window widget in the function where I want to set it fullscreen…
GtkWindowandGdkWindoware totally different things.When we think about “window”, we usually mean a graphical component – the toplevel, resizable “box” with minimize/maximize buttons etc. This is what is represented by
GtkWindow.GDK however has another meaning for “window”. The
GdkWindowis not a graphical component, but an abstract resource inside GDK representing some rectangular region on the screen. It is probably closely related to some low-level resource inside Xorg/Win32 etc.If you want to obtain the toplevel
GtkWindowcontaining a given widget, you could probably use gtk_widget_get_toplevel or gtk_widget_get_ancestor