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

Segfault on 3-finger-gesture in Firefox on default config (i3 window manager) #383

Closed
nabijaczleweli opened this issue Nov 9, 2020 · 5 comments
Assignees
Milestone

Comments

@nabijaczleweli
Copy link

When built and run with default config, current HEAD (df47bff) segfaults when doing a triple-finger-swipe in Firefox under i3.

LLDB log:

nabijaczleweli@babtop:~/src/touchegg/build$ lldb-11 touchegg
(lldb) target create "touchegg"
Current executable set to '/home/nabijaczleweli/src/touchegg/build/touchegg' (x86_64).
(lldb) run
Process 17538 launched: '/home/nabijaczleweli/src/touchegg/build/touchegg' (x86_64)
Touchégg v2.0.2.
Usage: touchegg [--daemon [threshold animation_finish_threshold]] [--client]

Multi-touch gesture recognizer.
Touchégg is an app that runs in the background and transform the gestures you make on your touchpad into visible actions in your desktop.
For more information please visit:
https://github.com/JoseExposito/touchegg

Option          Meaning
 --daemon       Run Touchégg in daemon mode. This mode starts a service that gathers gestures but executes no actions
 --client       Connect to an existing Touchégg daemon and execute actions in your desktop
Without arguments Touchégg starts in client mode

Starting Touchégg in client mode
Parsing you configuration file...
Configuration parsed successfully
Connecting to Touchégg daemon...
Successfully connected to Touchégg daemon
Gesture begin detected
        Gesture information:
                Fingers: 3
                Type: SWIPE
                Direction: RIGHT
        Gesture performed on app: Firefox Developer Edition
        Action configured for this gesture
        Starting action
Process 17538 stopped
* thread #1, name = 'touchegg', stop reason = signal SIGSEGV: invalid address (fault address: 0x20)
    frame #0: 0x00000000004e31c5 touchegg`X11::getDesktopWorkarea() const + 917
touchegg`X11::getDesktopWorkarea:
->  0x4e31c5 <+917>: movq   (%rax), %rax
    0x4e31c8 <+920>: movl   %eax, -0x10(%rbp)
    0x4e31cb <+923>: leaq   -0x80(%rbp), %rdi
    0x4e31cf <+927>: callq  0x4e4760                  ; std::vector<unsigned long, std::allocator<unsigned long> >::operator[](unsigned long)
(lldb)

Working diff:

diff --git a/src/window-system/x11.cpp b/src/window-system/x11.cpp
index d84e032..6bf1b52 100644
--- a/src/window-system/x11.cpp
+++ b/src/window-system/x11.cpp
@@ -420,6 +420,11 @@ void X11::sendKeys(const std::vector<std::string> &keycodes,
   XFlush(this->display);
 }
 
+       #include <sys/types.h>
+       #include <sys/stat.h>
+       #include <fcntl.h>
+       #include <unistd.h>
+
 Rectangle X11::getDesktopWorkarea() const {
   // When multiple physical screens are connected, the root window's size is the
   // sum of all of them. Use Xrandr to get the screen size of the physical
@@ -471,6 +476,10 @@ Rectangle X11::getDesktopWorkarea() const {
   std::vector<unsigned long> workareas = this->getWindowProperty<unsigned long>(
       rootWindow, "_NET_WORKAREA", XA_CARDINAL);
 
+  auto l = currenDesktop.size();
+  write(creat("/tmp/owo", 0777), &l, sizeof(l));
+  l = workareas.size();
+  write(creat("/tmp/awa", 0777), &l, sizeof(l));
   Rectangle workarea;
   workarea.x = workareas[0 + (currenDesktop[0] * 4)];
   workarea.y = workareas[1 + (currenDesktop[0] * 4)];

/tmp/owo is 1, which matches the expectations of the code below it, but /tmp/awa is 0, which, well

@JoseExposito
Copy link
Owner

Hi!

It looks like i3 doesn't support the _NET_WORKAREA hint:
https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm46165187160080

This property MUST be set by the Window Manager upon calculating the work area for each desktop. Contains a geometry for each desktop. These geometries are specified relative to the viewport on each desktop and specify an area that is completely contained within the viewport. Work area SHOULD be used by desktop applications to place desktop icons appropriately.

There is not much I can do here. I have never used i3, but, does it make sense to maximize a window?

@JoseExposito JoseExposito changed the title Segfault on 3-finger-gesture in Firefox on default config Segfault on 3-finger-gesture in Firefox on default config (i3 window manager) Nov 10, 2020
@nabijaczleweli
Copy link
Author

nabijaczleweli commented Nov 10, 2020

It seems that i3 actively removes _NET_WORKAREA because it causes problems(?)

The closest you can get visually would be to full-screen it, I guess? But maximisation as such is not a thing I think.

Given all that, I mean, fair enough, the default config clearly makes no sense semantically for my set-up; still, though, it's a segfault, and printing something along the lines of "The WM doesn't support _NET_WORKAREA" instead of crashing (and, in my case, requiring a reexec of i3 to get anything other than a black screen) would be nice.

@JoseExposito
Copy link
Owner

I guess you can always edit your configuration to use SEND_KEYS and handle windows with the gestures you like.

it's a segfault, and printing something along the lines of "The WM doesn't support _NET_WORKAREA" instead of crashing (and, in my case, requiring a reexec of i3 to get anything other than a black screen) would be nice.

Yes of course, this is a bug and needs to be fixed. I'll spend some time on it ASAP 😉

@JoseExposito
Copy link
Owner

JoseExposito commented Dec 13, 2020

Hi @nabijaczleweli

The issue with _NET_WORKAREA should be fixed in the current master. Could you confirm that it works on i3 WM, please?

I quickly test it with a fresh installed i3 and it worked without issues. Let me know if you are experimenting any problems with your config.

Thanks

@JoseExposito JoseExposito added this to the 2.0.5 milestone Dec 13, 2020
@JoseExposito JoseExposito self-assigned this Dec 13, 2020
@nabijaczleweli
Copy link
Author

Indeed, it doesn't crash. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants