web stats
Featured image of post Fixing the blank context menu in Opera under Wayland on Linux

Fixing the blank context menu in Opera under Wayland on Linux

How to solve the problem of the Opera browser showing a blank context menu under Wayland by forcing the use of XWayland.

Using Opera under Linux and Wayland (in my case Fedora and Ubuntu), I encountered a rather annoying problem (another one to add to the list): when right-clicking on certain areas of the browser, especially the tab bar, the context menu appeared completely blank.

After several tests, I discovered that the problem was related to Opera’s Wayland/Ozone implementation.

The solution is to force Opera to run using XWayland, until a definitive fix is implemented.

Let’s see how to do it permanently without affecting possible upgrades that might overwrite the configuration files:

  • Create the local user applications directory if it doesn’t already exist:
1
mkdir -p ~/.local/share/applications

Copy the original Opera `.desktop file:

1
cp /usr/share/applications/opera.desktop ~/.local/share/applications/

Edit the file:

1
nano ~/.local/share/applications/opera.desktop

We need to modify all lines that begin with Exec, adding the parameter: --ozone-platform=x11

It should look something like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
❯ cat ~/.local/share/applications/opera.desktop

[Desktop Entry]
Version=1.0
Name=Opera
GenericName=Web browser
Comment=Fast and secure web browser
TryExec=opera
Exec=opera --ozone-platform=x11 %U
Terminal=false
Icon=opera
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;application/x-opera-download;
Actions=new-window;new-private-window;

[Desktop Action new-window]
Name=New Window
Exec=opera --new-window --ozone-platform=x11
TargetEnvironment=Unity

[Desktop Action new-private-window]
Name=New Private Window
Exec=opera --incognito --ozone-platform=x11
TargetEnvironment=Unity

Finally, completely close Opera:

1
pkill opera

With this, when you restart the browser, the problem should disappear completely :)

In my case, this solution worked on both Ubuntu and Fedora 44.


PD: Banner image generated with A.I.

comments powered by Disqus
Built with Hugo-Extended & theme Stack