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

When used with the window_manager plugin, there is still an issue where the webview area blocks mouse and desktop interaction #2522

Open
1 of 2 tasks
gk-1213 opened this issue Feb 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@gk-1213
Copy link

gk-1213 commented Feb 6, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When used with the window_manager plugin, there is still an issue where the webview area blocks mouse and desktop interaction

Expected Behavior

The webview area does not affect the interaction between the mouse and desktop

Steps with code example to reproduce

Steps with code example to reproduce
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:test_web/window_manager.dart';
import 'package:window_manager/window_manager.dart';

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

  WindowOptions windowOptions = const WindowOptions(
    size: Size(800, 600),
    center: true,
    backgroundColor: Colors.transparent,
    skipTaskbar: false,
    titleBarStyle: TitleBarStyle.hidden,
    windowButtonVisibility: false,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ThemeMode _themeMode = ThemeMode.light;

  InAppWebViewController? webViewController;
  String url = "";
  double progress = 0;
  final urlController = TextEditingController();

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final virtualWindowFrameBuilder = VirtualWindowFrameInit();

    return MaterialApp(
        debugShowCheckedModeBanner: false,
        themeMode: _themeMode,
        builder: (context, child) {
          child = virtualWindowFrameBuilder(context, child);
          return child;
        },
        home: Scaffold(
          appBar: PreferredSize(
              preferredSize: const Size.fromHeight(40),
              child: SizedBox(
                width: 1060,
                child: Row(
                  children: [
                    const Expanded(
                      child: DragWindow(),
                    ),

                    /// 右上角按钮
                    Row(children: [
                      IconButton(
                          onPressed: () async {
                            await windowManager.minimize();
                          },
                          icon: const Icon(Icons.remove)),
                      IconButton(
                          onPressed: () async {
                            await windowManager.close();
                          },
                          icon: const Icon(Icons.close)),
                    ])
                  ],
                ),
              )),
          body: SafeArea(
              child: Column(children: <Widget>[
            TextField(
              decoration: const InputDecoration(prefixIcon: Icon(Icons.search)),
              controller: urlController,
              keyboardType: TextInputType.url,
              onSubmitted: (value) {
                var url = WebUri(value);
                if (url.scheme.isEmpty) {
                  url = WebUri("https://www.google.com/search?q=$value");
                }
                webViewController?.loadUrl(urlRequest: URLRequest(url: url));
              },
            ),
            Expanded(
              child: Stack(
                children: [
                  InAppWebView(
                    initialUrlRequest:
                        URLRequest(url: WebUri("https://inappwebview.dev/")),
                    onWebViewCreated: (controller) {
                      webViewController = controller;
                    },
                    onLoadStart: (controller, url) {
                      setState(() {
                        this.url = url.toString();
                        urlController.text = this.url;
                      });
                    },
                  ),
                  progress < 1.0
                      ? LinearProgressIndicator(value: progress)
                      : Container(),
                ],
              ),
            ),
            ButtonBar(
              alignment: MainAxisAlignment.center,
              children: <Widget>[
                ElevatedButton(
                  child: const Icon(Icons.arrow_back),
                  onPressed: () {
                    webViewController?.goBack();
                  },
                ),
                ElevatedButton(
                  child: const Icon(Icons.arrow_forward),
                  onPressed: () {
                    webViewController?.goForward();
                  },
                ),
                ElevatedButton(
                  child: const Icon(Icons.refresh),
                  onPressed: () {
                    webViewController?.reload();
                  },
                ),
              ],
            ),
          ])),
        ));
  }
}

//拖动窗口
class DragWindow extends StatelessWidget {
  const DragWindow({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      child: Listener(
        onPointerDown: (event) async {
          await windowManager.startDragging();
        },
        child: Container(
          color: Colors.transparent,
        ),
      ),
    );
  }
}

Stacktrace/Logs

Stacktrace/Logs
<Replace this line by pasting your stacktrace or logs here>

Flutter version

v3.24.3

Operating System, Device-specific and/or Tool

Windows 11

Plugin version

^6.2.0-beta.2

Additional information

window_manager: ^0.4.3

Self grab

  • I'm ready to work on this issue!
@gk-1213 gk-1213 added the bug Something isn't working label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant