Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux usage #43

Closed
rickbsgu opened this issue Mar 13, 2021 · 13 comments
Closed

Linux usage #43

rickbsgu opened this issue Mar 13, 2021 · 13 comments

Comments

@rickbsgu
Copy link

Please add a section in the readme for linux - particularly what needs to be modified and where in the c++ files.

Thanks

@bitsdojo
Copy link
Owner

Hi there!

Linux support is not finished yet but I will add instructions once it is ready.

@debonzi
Copy link

debonzi commented Apr 11, 2021

Hi,
I didn't test it a lot but it seems that with only this simple change the example is running just fine in Ubuntu Linux 18.04

diff --git a/linux/my_application.cc b/linux/my_application.cc
index d0094bc..e7df1dc 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -61,6 +61,9 @@ static void my_application_activate(GApplication* application) {
   fl_register_plugins(FL_PLUGIN_REGISTRY(view));
 
   gtk_widget_grab_focus(GTK_WIDGET(view));
+
+  // Window Bar will be handled by bitsdojo_window
+  gtk_window_set_decorated(window, FALSE);
 }
 
 // Implements GApplication::local_command_line.

I hope it helps.

@mneilly
Copy link

mneilly commented Apr 18, 2021

Thanks for your efforts!

Since you said you're still working on Linux support you may already be aware of these issues but in case you aren't...

Following the tut from the video (https://youtu.be/bee2AHQpGK4) and making the change suggested by @debonzi generally worked for me but...

If I click the minimize button first the window either hangs or crashes with:

Launching lib/main.dart on Linux in debug mode...
Building Linux application...
Debug service listening on ws://127.0.0.1:45103/4guDepD3iG0=/ws
Syncing files to device Linux...
[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
try_bitsdojo_window: ../../src/xcb_io.c:643: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Lost connection to device.

If I first click maximize, minimize seems to work fine after that point.

Also, I can click to move the window but only every other click works. Click move. Click no mode. Click move. Click no move and so on.

bitsdojo_window.mp4

@tomassasovsky
Copy link

Hi! I'm getting pretty much the same error:

Launching lib/main.dart on Linux in debug mode...
lib/main.dart:1
Connecting to VM Service at ws://127.0.0.1:39025/c-3J3cL4VPA=/ws
(example:49968): Gdk-CRITICAL **: 11:25:53.580: gdk_window_get_origin: assertion 'GDK_IS_WINDOW (window)' failed
(example:49968): Gdk-CRITICAL **: 11:25:53.581: gdk_window_get_origin: assertion 'GDK_IS_WINDOW (window)' failed
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
example: ../../src/xcb_io.c:269: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Lost connection to device.
Exited (sigterm)

I'm running the example code on Ubuntu 21.04 with GNOME 40.

@wolfenrain
Copy link

I tried to use the given patch from this issue but was having the same above mentioned errors. So I looked at the PR that implemented the Linux support and was able to create the following patch:

diff --git a/linux/my_application.cc b/linux/my_application.cc
index 75ee004..1e49f19 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -27,7 +27,7 @@ static void my_application_activate(GApplication* application) {
   // in case the window manager does more exotic layout, e.g. tiling.
   // If running on Wayland assume the header bar will work (may need changing
   // if future cases occur).
-  gboolean use_header_bar = TRUE;
+  gboolean use_header_bar = FALSE;
 #ifdef GDK_WINDOWING_X11
   GdkScreen *screen = gtk_window_get_screen(window);
   if (GDK_IS_X11_SCREEN(screen)) {
@@ -45,6 +45,9 @@ static void my_application_activate(GApplication* application) {
     gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
   }
   else {
+  	// Use an empty header bar so that gtk doesn't show the title bar but still retains window resize controls
+    GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());   
+    gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
     gtk_window_set_title(window, "example");
   }
 
@@ -61,9 +64,6 @@ static void my_application_activate(GApplication* application) {
   fl_register_plugins(FL_PLUGIN_REGISTRY(view));
 
   gtk_widget_grab_focus(GTK_WIDGET(view));
-
-  // Window Bar will be handled by bitsdojo_window
-  gtk_window_set_decorated(window, FALSE);
 }
 
 // Implements GApplication::local_command_line.
@@ -103,5 +103,6 @@ static void my_application_init(MyApplication* self) {}
 MyApplication* my_application_new() {
   return MY_APPLICATION(g_object_new(my_application_get_type(),
                                      "application-id", APPLICATION_ID,
+                                     "flags", G_APPLICATION_NON_UNIQUE,
                                      nullptr));
 }

The amount of crashes decreased. But I still had them.. The only way to prevent them was to remove calling doWhenWindowReady. Thought I shared my findings, your result may vary of course.

@bitsdojo
Copy link
Owner

bitsdojo commented Apr 20, 2021

Thanks everyone for your comments. Planned to push out a new version with improved Linux support today but had to visit the hospital instead.

Fortunately the doctors have a fix for me and although I can't type at full speed due to a hand injury, I will do my best to release the new version soon.

Just wanted to let everyone know that I am working on it.

@blemelin
Copy link

blemelin commented May 15, 2021

Also, I can click to move the window but only every other click works. Click move. Click no mode. Click move. Click no move and so on.

I'm not an expert, but I think it is related to this other issue : flutter/flutter#74939

See this method and the call to gtk_window_begin_move_drag at line 55 :

static FlMethodResponse* start_window_drag_at_position(FlBitsdojoWindowPlugin *self, FlValue *args) {
auto window = get_window(self);
auto screen = gtk_window_get_screen(window);
auto display = gdk_screen_get_display(screen);
auto seat = gdk_display_get_default_seat(display);
auto device = gdk_seat_get_pointer(seat);
gint x, y;
gdk_device_get_position(device, nullptr, &x, &y);
gtk_window_begin_move_drag(window,
1,
x, y,
(guint32)g_get_monotonic_time()
);
gtk_widget_grab_focus(GTK_WIDGET(fl_plugin_registrar_get_view(self->registrar)));
return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
}

EDIT : Oups...its seems you already know that.

@kartikeyshaurya
Copy link

did anybody got the support for linux

@bitsdojo
Copy link
Owner

bitsdojo commented Jun 1, 2021

An update is coming tomorrow. Stay tuned.

@kartikeyshaurya
Copy link

gtk_window_set_decorated(window, FALSE);

Hi,
I didn't test it a lot but it seems that with only this simple change the example is running just fine in Ubuntu Linux 18.04

diff --git a/linux/my_application.cc b/linux/my_application.cc
index d0094bc..e7df1dc 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -61,6 +61,9 @@ static void my_application_activate(GApplication* application) {
   fl_register_plugins(FL_PLUGIN_REGISTRY(view));
 
   gtk_widget_grab_focus(GTK_WIDGET(view));
+
+  // Window Bar will be handled by bitsdojo_window
+  gtk_window_set_decorated(window, FALSE);
 }
 
 // Implements GApplication::local_command_line.

it worked thanks for posting here man @debonzi

@renejk
Copy link

renejk commented Jun 4, 2021

no instructions to use on linux yet?

@bitsdojo
Copy link
Owner

bitsdojo commented Jun 9, 2021

no instructions to use on linux yet?

Just pushed 0.1.1 with improved Linux support. Please test it and report any issues you encounter.

Also added basic instructions for Linux here: https://github.com/bitsdojo/bitsdojo_window#for-linux-apps

@bitsdojo bitsdojo mentioned this issue Jun 9, 2021
@bitsdojo
Copy link
Owner

bitsdojo commented Jun 9, 2021

As Linux instructions are now available in README.MD I will close this.

Feel free to open other issues if you encounter any problems with the Linux package.

@bitsdojo bitsdojo closed this as completed Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants