From e57bfe002ac0f19311e0b1b23d9b15e6876c5013 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Tue, 13 Dec 2022 07:09:45 +1100 Subject: [PATCH] Fix right mouse button event (#2190) --- v2/internal/frontend/desktop/linux/window.go | 12 +-- v2/internal/platform/systray/systray_linux.go | 83 +++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 v2/internal/platform/systray/systray_linux.go diff --git a/v2/internal/frontend/desktop/linux/window.go b/v2/internal/frontend/desktop/linux/window.go index 782083d9b..782325f57 100644 --- a/v2/internal/frontend/desktop/linux/window.go +++ b/v2/internal/frontend/desktop/linux/window.go @@ -165,7 +165,6 @@ float xroot = 0.0f; float yroot = 0.0f; int dragTime = -1; uint mouseButton = 0; -bool contextMenuDisabled = false; gboolean buttonPress(GtkWidget *widget, GdkEventButton *event, void* dummy) { @@ -175,8 +174,8 @@ gboolean buttonPress(GtkWidget *widget, GdkEventButton *event, void* dummy) return FALSE; } mouseButton = event->button; - if( event->button == 3 && contextMenuDisabled ) { - return TRUE; + if( event->button == 3 ) { + return FALSE; } if (event->type == GDK_BUTTON_PRESS && event->button == 1) @@ -605,12 +604,15 @@ gboolean UnFullscreen(gpointer data) { return G_SOURCE_REMOVE; } -bool disableContextMenu(GtkWindow* window) { + +// function to disable the context menu but propogate the event +gboolean disableContextMenu(GtkWidget *widget, WebKitContextMenu *context_menu, GdkEvent *event, WebKitHitTestResult *hit_test_result, gpointer data) { + // return true to disable the context menu return TRUE; } void DisableContextMenu(void* webview) { - contextMenuDisabled = TRUE; + // Disable the context menu but propogate the event g_signal_connect(WEBKIT_WEB_VIEW(webview), "context-menu", G_CALLBACK(disableContextMenu), NULL); } diff --git a/v2/internal/platform/systray/systray_linux.go b/v2/internal/platform/systray/systray_linux.go new file mode 100644 index 000000000..480955018 --- /dev/null +++ b/v2/internal/platform/systray/systray_linux.go @@ -0,0 +1,83 @@ +//go:build linux + +/* + * Based on code originally from https://github.com/tadvi/systray. Copyright (C) 2019 The Systray Authors. All Rights Reserved. + */ + +package systray + +import ( + "github.com/wailsapp/wails/v2/pkg/menu" + "github.com/wailsapp/wails/v2/pkg/options" +) + +type Systray struct { +} + +func (p *Systray) Close() { + err := p.Stop() + if err != nil { + println(err.Error()) + } +} + +func (p *Systray) Update() error { + return nil +} + +// SetTitle is unused on Windows +func (p *Systray) SetTitle(_ string) {} + +func New() (*Systray, error) { + return nil, nil +} + +func (p *Systray) SetMenu(popupMenu *menu.Menu) (err error) { + return +} + +func (p *Systray) Stop() error { + return nil +} + +func (p *Systray) OnLeftClick(fn func()) { +} + +func (p *Systray) OnRightClick(fn func()) { +} + +func (p *Systray) OnLeftDoubleClick(fn func()) { +} + +func (p *Systray) OnRightDoubleClick(fn func()) { +} + +func (p *Systray) OnMenuClose(fn func()) { +} + +func (p *Systray) OnMenuOpen(fn func()) { +} + +func (p *Systray) SetTooltip(tooltip string) error { + return nil +} + +func (p *Systray) Show() error { + return p.setVisible(true) +} + +func (p *Systray) Hide() error { + return p.setVisible(false) +} + +func (p *Systray) setVisible(visible bool) error { + return nil +} + +func (p *Systray) SetIcons(lightModeIcon, darkModeIcon *options.SystemTrayIcon) error { + return nil +} + +func (p *Systray) Run() error { + return nil +}