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

Describe difference to the official window_size plugin #17

Closed
cbenhagen opened this issue Jan 3, 2021 · 3 comments
Closed

Describe difference to the official window_size plugin #17

cbenhagen opened this issue Jan 3, 2021 · 3 comments

Comments

@cbenhagen
Copy link

There is a (semi-) official plugin with very similar functionality at https://github.com/google/flutter-desktop-embedding/tree/master/plugins/window_size. It would be nice to describe what sets this plugin apart. Maybe the two could be merged?

@esDotDev
Copy link
Contributor

esDotDev commented Jan 16, 2021

On this topic, I recently got a pretty solid "universal" drag going, using the window_size plugin (which supports all 3 desktop platforms).

This is some ugly code, and it's not quite perfect (dragging is not 1:1, more like 1:0.99), but it's really close:

onPointerMove: (d) async {
  if (_ignoreNext) {
    // Have to skip each 2nd event, cause flutter generates one when we move
    _ignoreNext = false;
    return;
  }
  _windowPos += d.delta * 2; // Note sure why we need to double this, but it gets us real close
  Window.setWindowFrame(_windowPos & _windowSize);
  _ignoreNext = true;
},

// Also called on each build:
void _updateWindowSize() async => _windowSize = (await Window.getWindowInfo()).frame.size;

Seems like there might be some opportunity to build on the base API's from WindowSize, and just add on what is really unique to this package (prefab'd Windows btns, maximize/minimize methods, and ability to hide native title bar). Though I think max/min probably best belong in the core as well, maybe we can try and land a PR for that.

We had to remove BitDojo for now just cause it prevents us from building on Web, but luckily this works ok across all platforms.

@cbenhagen
Copy link
Author

cbenhagen commented Jan 16, 2021

Haven't had the chance to test this on a non-retina screen but I guess you'd might want to do:

_windowPos += d.delta * MediaQuery.of(context).devicePixelRatio;

Related issue: flutter/flutter#71680

@geocine
Copy link

geocine commented Mar 12, 2021

With regards to dragging, isn't the MoveWindow widget enough for your use case @esDotDev ?

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

4 participants