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

Proposal: system menu #141

Closed
jpnurmi opened this issue May 5, 2022 · 6 comments
Closed

Proposal: system menu #141

jpnurmi opened this issue May 5, 2022 · 6 comments

Comments

@jpnurmi
Copy link
Contributor

jpnurmi commented May 5, 2022

Could there be API to show the window system menu on Linux and Windows?

image

@lijy91
Copy link
Member

lijy91 commented May 5, 2022

I tried adding this functionality for the windows platform, but it doesn't seem to display the state of the menu items correctly

@jpnurmi
Copy link
Contributor Author

jpnurmi commented May 5, 2022

Strange, the docs claim that it should be automatically taken care of. Which state is wrong?

The system automatically grays items on the standard window menu, depending on the situation. The application can perform its own checking or graying by responding to the WM_INITMENU message that is sent before any menu is displayed.

@lijy91
Copy link
Member

lijy91 commented May 8, 2022

I've added a popUpWindowMenu method for windows and linux platforms, but I can't fix this incorrect state on Windows for now.

@jpnurmi
Copy link
Contributor Author

jpnurmi commented May 9, 2022

Awesome, thanks!

I gave it a very quick try with minimal test app:

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();

  runApp(
    MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('window_manager')),
        body: GestureDetector(
          onSecondaryTapDown: (details) {
            // print(details.globalPosition);
            windowManager.popUpWindowMenu();
          },
        ),
      ),
    ),
  );
}

On Ubuntu 22.04 + Wayland, the menu appears but some assertions fail:

(flutter_application_13:343404): GLib-GObject-CRITICAL **: 13:58:06.740: g_object_get: assertion 'G_IS_OBJECT (object)' failed
(flutter_application_13:343404): Gdk-CRITICAL **: 13:58:06.740: gdk_device_get_seat: assertion 'GDK_IS_DEVICE (device)' failed
(flutter_application_13:343404): Gdk-CRITICAL **: 13:58:06.740: gdk_seat_ungrab: assertion 'GDK_IS_SEAT (seat)' failed

@lijy91
Copy link
Member

lijy91 commented May 9, 2022

I'm not very familiar with linux, do you know what causes these to appear?

@jpnurmi
Copy link
Contributor Author

jpnurmi commented May 9, 2022

Interesting, the warnings were actually from the X11 backend because VS Code sets GDK_BACKEND=x11. The Wayland backend would crash due to missing device, but both are fixed by #145.

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

2 participants