Skip to content

Commit

Permalink
Linux: remove misleading C++-style default values (#253)
Browse files Browse the repository at this point in the history
Even if `window_manager_plugin.cc` is compiled as C++, C++-style inline
initialization of struct members doesn't work for `_WindowManagerPlugin`
because the instance is not created by the C++ operator new but alloc'd
and zero-filled by the GObject type system.

> GObject explicitly guarantees that all class and instance members
> (except the fields pointing to the parents) to be set to zero.

https://docs.gtk.org/gobject/concepts.html#object-instantiation

Initial values can be set in `window_manager_plugin_init()` if needed.

Co-authored-by: LiJianying <lijy91@foxmail.com>
  • Loading branch information
jpnurmi and lijy91 committed Dec 11, 2022
1 parent 524bf2a commit f1fb25a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions linux/window_manager_plugin.cc
Expand Up @@ -18,17 +18,18 @@ struct _WindowManagerPlugin {
FlPluginRegistrar* registrar;
FlMethodChannel* channel;
GdkGeometry window_geometry;
GtkWidget* _event_box = nullptr;
bool _is_prevent_close = false;
bool _is_maximized = false;
bool _is_minimized = false;
bool _is_fullscreen = false;
bool _is_always_on_top = false;
bool _is_always_on_bottom = false;
bool _is_dragging = false;
bool _is_resizing = false;
gchar* title_bar_style_ = strdup("normal");
GdkEventButton _event_button = GdkEventButton{};
GtkWidget* _event_box;
bool _is_prevent_close;
bool _is_frameless;
bool _is_maximized;
bool _is_minimized;
bool _is_fullscreen;
bool _is_always_on_top;
bool _is_always_on_bottom;
bool _is_dragging;
bool _is_resizing;
gchar* title_bar_style_;
GdkEventButton _event_button;
GdkDevice* grab_pointer;
GtkCssProvider* css_provider;
};
Expand Down

0 comments on commit f1fb25a

Please sign in to comment.