14 "AppLifecycleState.resumed";
16 "AppLifecycleState.inactive";
18 "AppLifecycleState.hidden";
36 G_DEFINE_TYPE(FlWindowStateMonitor, fl_window_state_monitor, G_TYPE_OBJECT);
39 const gchar* lifecycle_state) {
42 g_autoptr(GError)
error =
nullptr;
43 g_autoptr(GBytes) message =
45 if (message ==
nullptr) {
46 g_warning(
"Failed to encoding lifecycle state message: %s",
error->message);
51 message,
nullptr,
nullptr,
nullptr);
55 return (
state & GDK_WINDOW_STATE_WITHDRAWN) ||
56 (
state & GDK_WINDOW_STATE_ICONIFIED);
62 GdkWindowState
state =
event->window_state.new_window_state;
63 GdkWindowState previous_state =
self->window_state;
64 self->window_state =
state;
65 bool was_visible = !
is_hidden(previous_state);
67 bool was_focused = (previous_state & GDK_WINDOW_STATE_FOCUSED);
68 bool is_focused = (
state & GDK_WINDOW_STATE_FOCUSED);
70 if (was_visible != is_visible || was_focused != is_focused) {
71 const gchar* lifecycle_state;
86 FlWindowStateMonitor*
self = FL_WINDOW_STATE_MONITOR(
object);
88 g_clear_object(&self->messenger);
89 if (self->window_state_event_cb_id != 0) {
90 g_signal_handler_disconnect(self->window, self->window_state_event_cb_id);
91 self->window_state_event_cb_id = 0;
94 G_OBJECT_CLASS(fl_window_state_monitor_parent_class)->dispose(
object);
98 FlWindowStateMonitorClass* klass) {
106 FlWindowStateMonitor*
self = FL_WINDOW_STATE_MONITOR(
107 g_object_new(fl_window_state_monitor_get_type(),
nullptr));
108 self->messenger = FL_BINARY_MESSENGER(g_object_ref(messenger));
109 self->window = window;
112 self->window_state_event_cb_id =
113 g_signal_connect_swapped(self->window,
"window-state-event",
116 gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(self->window)));