Skip to content

Commit

Permalink
Fix(Linux): Window Size and Position on launch
Browse files Browse the repository at this point in the history
- add linux/window_configuration.cpp` and `.h`
- move the default window settings to the configuration file.
- add the `window_configuration.cpp` file to the CMAKE list.
  • Loading branch information
parodyBit committed Aug 16, 2023
1 parent 9845fc1 commit b77e85c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"window_configuration.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
apply_standard_settings(${BINARY_NAME})
Expand Down
8 changes: 5 additions & 3 deletions linux/my_application.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "my_application.h"
#include "window_configuration.h"

#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
Expand Down Expand Up @@ -40,15 +41,16 @@ static void my_application_activate(GApplication* application) {
if (use_header_bar) {
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "myWitWallet");
gtk_header_bar_set_title(header_bar, kFlutterWindowTitle);
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
}
else {
gtk_window_set_title(window, "myWitWallet");
gtk_window_set_title(window, kFlutterWindowTitle);
}

gtk_window_set_default_size(window, 1280, 720);
gtk_window_set_default_size(window, kFlutterWindowWidth, kFlutterWindowHeight);
gtk_window_set_position(window, GTK_WIN_POS_CENTER);
gtk_widget_show(GTK_WIDGET(window));

g_autoptr(FlDartProject) project = fl_dart_project_new();
Expand Down
5 changes: 5 additions & 0 deletions linux/window_configuration.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "window_configuration.h"

const char* kFlutterWindowTitle = "myWitWallet";
const unsigned int kFlutterWindowWidth = 400;
const unsigned int kFlutterWindowHeight = 700;
8 changes: 8 additions & 0 deletions linux/window_configuration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef WINDOW_CONFIGURATION_
#define WINDOW_CONFIGURATION_

extern const char* kFlutterWindowTitle;
extern const unsigned int kFlutterWindowWidth;
extern const unsigned int kFlutterWindowHeight;

#endif // WINDOW_CONFIGURATION_

0 comments on commit b77e85c

Please sign in to comment.