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

Dragable borderless window #214

Closed
MostHated opened this issue Jul 30, 2019 · 17 comments
Closed

Dragable borderless window #214

MostHated opened this issue Jul 30, 2019 · 17 comments
Labels
example About an example plugin Issue about an existing or possible plugin

Comments

@MostHated
Copy link

Hey there,
I see there is a borderless window which makes an app look really nice, but then moving it around seems to be a bit difficult. Is there any sort of way built in to have an area at the top in which is still dragable that I might be missing, or is that going to have to be custom within glfw?

Thanks,
-MH

@pchampio
Copy link
Member

pchampio commented Jul 30, 2019

As always.. You just have to build a plugin!

I took this real-world problem and made a GLFW example plugin. You can find the example under the name draggable_borderless

@pchampio pchampio added the plugin Issue about an existing or possible plugin label Jul 30, 2019
@pchampio
Copy link
Member

@MostHated
Copy link
Author

This is fantastic, thank you very much! I do want to report that I have implemented it and while it does work, strangely, whenever I grab to drag it, that particular window drops to about 1 fps. Not just the output of the display of the window, but moving the window around my actual screen space.

You can see what I mean here https://i.imgur.com/cAKz1EG.gifv

From the time I opened it and first move my mouse to the top I am clicking and holding the whole time until the end. It seems that if I move it any sort of decent amount at once it will sit there and wait until I slow down then it pops to place. If I moved it slowly it sort of inches its way along.

I don't see any error messages while running the application with just hover run. I am assuming that the performance would be influenced by the complexity of my application? The application isn't really that complex yet. Perhaps I need to figure out how to somehow performance profile my application to see if that is the cause. I am still just learning, so it could very well be from misoptimization in my hierarchy.

Regardless of my personal issues, I thank you again for this. It definitely upped the "niceness" of my application. : D

@pchampio
Copy link
Member

pchampio commented Jul 30, 2019

I am assuming that the performance would be influenced by the complexity of my application?

If you are making sync platform calls, the app will stop rendering frames until the platform calls is completed.
I tried on my own with a more complicated app, I don't really have a solution for your app's sluggishness.

@MostHated
Copy link
Author

Hmm... well, technically it shouldn't be making lots of them. I just make one at the start of the app to get data to populate the list of cards on the main screen. That doesn't necessarily mean that it isn't doing more than I think it's doing. I had a pretty strong feeling that the cause was of my own doing. I attempted to introduce the Provider package into my app last night, so there is a good chance I goofed something up along the way. I will have to put a few log messages in there and see if I get repeating calls.

Thanks!

@pchampio
Copy link
Member

pchampio commented Jul 30, 2019

are you using HandleFuncSync or HandleFunc?
If you are using HandleFuncSync I strongly recommend you to switch to HandleFunc.

@MostHated
Copy link
Author

I am using this below, I believe it was just what I found in the demo plugin.

func (d *DataPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
    channel.HandleFunc(getRemotes, d.getRemotesFunc)
}

@pchampio
Copy link
Member

Your app's sluggishness doesn't comes form the platform messages.

The issue might come from the the AppBarDraggable plugin while loop, but I don't know how to solve the your particular issue.

@pchampio
Copy link
Member

pchampio commented Jul 30, 2019

Does the raw https://github.com/go-flutter-desktop/examples/tree/master/draggable_borderless example works for you? (no sluggishness)

@MostHated
Copy link
Author

MostHated commented Jul 30, 2019

Actually, I just tried it out, it does the same thing.

Here are my specs.

             /////////////                mosthated@mosthated-pc 
         /////////////////////            ---------------------- 
      ///////*767////////////////         OS: Pop!_OS 19.04 x86_64 
    //////7676767676*//////////////       Host: MS-7B79 2.0 
   /////76767//7676767//////////////      Kernel: 5.0.0-21-generic 
  /////767676///*76767///////////////     Uptime: 2 days, 9 hours, 45 mins 
 ///////767676///76767.///7676*///////    Packages: 3603 (dpkg), 13 (flatpak), 10 (snap) 
/////////767676//76767///767676////////   Shell: zsh 5.5.1 
//////////76767676767////76767/////////   Resolution: 1080x1920, 2560x1080, 1920x1080 
///////////76767676//////7676//////////   DE: GNOME 3.32.1 
////////////,7676,///////767///////////   WM: GNOME Shell 
/////////////*7676///////76////////////   WM Theme: Pop 
///////////////7676////////////////////   Theme: Pop-slim-dark [GTK2/3] 
 ///////////////7676///767////////////    Icons: Adwaita [GTK2/3] 
  //////////////////////'////////////     Terminal: java 
   //////.7676767676767676767,//////      CPU: AMD Ryzen 5 2600 (12) @ 3.400GHz 
    /////767676767676767676767/////       GPU: NVIDIA GeForce RTX 2070 
      ///////////////////////////         Memory: 16193MiB / 32175MiB 
         /////////////////////
             /////////////                                        

[✓] Flutter (Channel beta, v1.7.8+hotfix.4, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[✓] Android Studio (version 3.4)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.2)

@pchampio
Copy link
Member

pchampio commented Jul 30, 2019

I have read: https://stackoverflow.com/questions/46203809/glfw-mouse-event-lag-with-window-drag/46205940#46205940

The author experiences the same issue:

Update: I have also tried moving the glfwSetWindowPos logic into the main loop as well with no success—I still get the same shaking and stuttering.

Sorry I cannot help you. 😞

It's up to you to tweak the example to get less stuttering, GLFW how to drag undecorated window

@MostHated
Copy link
Author

I understand. I appreciate all you have done so far, it is no problem.

@pchampio pchampio added the example About an example label Aug 11, 2019
@NetFly-VPN
Copy link

when I run the example, the error is that:

2019-09-05 15:01:19.598 draggable_borderless[81306:1479963] pid(81306)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

And the demo can not draggle any more.
my env: go 1.12.9,
flutter : Flutter (Channel beta, v1.9.1+hotfix.1, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)

@pchampio
Copy link
Member

pchampio commented Sep 5, 2019

@NetFly-VPN correct, the example abuse GLFW.
In the go example code, I call p.window.GetCursorPos() and p.window.SetPos from a different thread than the main one.
I'm thinking of a fix.

pchampio added a commit to go-flutter-desktop/examples that referenced this issue Sep 7, 2019
Using HandleFuncSync instead of HandleFunc to ensure the plugin method
handler is called from the go-flutter main thread.

fixes go-flutter-desktop/go-flutter#214
@pchampio
Copy link
Member

pchampio commented Sep 7, 2019

@NetFly-VPN the draggable_borderless example is now fixed.

@goldenduo
Copy link

I can not resize the window when setting borderless.Is that possible to remove the header(close widget etc) only?

@leedstyh
Copy link

leedstyh commented Mar 9, 2021

@goldenduo have you figured out how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example About an example plugin Issue about an existing or possible plugin
Development

No branches or pull requests

5 participants