29 guint first_frame_cb_id;
34 data->window = GTK_WINDOW(g_object_ref(
window));
35 data->view = FL_VIEW(g_object_ref(
view));
40 g_signal_handler_disconnect(data->view, data->first_frame_cb_id);
41 g_object_unref(data->window);
42 g_object_unref(data->view);
48 gtk_window_present(data->window);
54 fl_windowing_handler_get_instance_private(
self));
57 g_hash_table_lookup(
priv->windows_by_view_id, GINT_TO_POINTER(view_id)));
61 FlWindowingHandler* handler,
63 GtkWidget*
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
64 gtk_container_add(GTK_CONTAINER(
window), GTK_WIDGET(
view));
75 FlWindowingHandler*
self = FL_WINDOWING_HANDLER(
user_data);
78 fl_windowing_handler_get_instance_private(
self));
80 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&
priv->engine));
81 if (engine ==
nullptr) {
82 return FL_METHOD_RESPONSE(
87 gtk_widget_show(GTK_WIDGET(
view));
93 "Internal error",
"Failed to create window",
nullptr));
97 if (title !=
nullptr) {
98 gtk_window_set_title(GTK_WINDOW(
window), title);
102 gtk_window_maximize(GTK_WINDOW(
window));
105 gtk_window_iconify(GTK_WINDOW(
window));
112 GdkGeometry geometry;
113 GdkWindowHints geometry_mask =
static_cast<GdkWindowHints
>(0);
114 if (min_size !=
nullptr) {
115 geometry.min_width = min_size->
width;
116 geometry.min_height = min_size->
height;
118 static_cast<GdkWindowHints
>(geometry_mask | GDK_HINT_MIN_SIZE);
120 if (max_size !=
nullptr) {
121 geometry.max_width = max_size->
width;
122 geometry.max_height = max_size->
height;
124 static_cast<GdkWindowHints
>(geometry_mask | GDK_HINT_MAX_SIZE);
126 if (geometry_mask != 0) {
127 gtk_window_set_geometry_hints(GTK_WINDOW(
window),
nullptr, &geometry,
132 data->first_frame_cb_id =
137 gtk_widget_realize(GTK_WIDGET(
view));
139 g_hash_table_insert(
priv->windows_by_view_id,
159 FlWindowingHandler*
self = FL_WINDOWING_HANDLER(
user_data);
162 if (data ==
nullptr) {
164 "Bad Arguments",
"No window with given view ID",
nullptr));
167 if (size !=
nullptr) {
168 gtk_window_resize(data->window, size->
width, size->
height);
171 if (title !=
nullptr) {
172 gtk_window_set_title(data->window, title);
175 GdkWindowState window_state;
178 if (gtk_window_is_maximized(data->window)) {
179 gtk_window_unmaximize(data->window);
182 gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(data->window)));
183 if (window_state & GDK_WINDOW_STATE_ICONIFIED) {
184 gtk_window_deiconify(data->window);
188 gtk_window_maximize(data->window);
191 gtk_window_iconify(data->window);
201 FlWindowingHandler*
self = FL_WINDOWING_HANDLER(
user_data);
204 fl_windowing_handler_get_instance_private(
self));
207 if (data ==
nullptr) {
209 "Bad Arguments",
"No window with given view ID",
nullptr));
212 gtk_widget_destroy(GTK_WIDGET(data->window));
214 g_hash_table_remove(
priv->windows_by_view_id, GINT_TO_POINTER(view_id));
220 FlWindowingHandler*
self = FL_WINDOWING_HANDLER(
object);
223 fl_windowing_handler_get_instance_private(
self));
225 g_weak_ref_clear(&
priv->engine);
226 g_clear_object(&
priv->channel);
227 g_clear_pointer(&
priv->windows_by_view_id, g_hash_table_unref);
229 G_OBJECT_CLASS(fl_windowing_handler_parent_class)->dispose(
object);
238 "create-window", fl_windowing_handler_get_type(), G_SIGNAL_RUN_LAST,
239 G_STRUCT_OFFSET(FlWindowingHandlerClass, create_window),
240 g_signal_accumulator_first_wins,
nullptr,
nullptr, GTK_TYPE_WINDOW, 1,
247 fl_windowing_handler_get_instance_private(
self));
249 priv->windows_by_view_id =
250 g_hash_table_new_full(g_direct_hash, g_direct_equal,
nullptr,
261 g_return_val_if_fail(FL_IS_ENGINE(engine),
nullptr);
263 FlWindowingHandler*
self = FL_WINDOWING_HANDLER(
264 g_object_new(fl_windowing_handler_get_type(),
nullptr));
267 fl_windowing_handler_get_instance_private(
self));
269 g_weak_ref_init(&
priv->engine, engine);