-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
On Raspian Jessie mouse and keyboard clicks passed to background desktop screen #3913
Comments
Thumbs up for this issue! I'm also working with Kivy on Raspian Jessie for some time now and as far as i can say, it only works really well when you are in cli and start the app in fullscreen. When i start an app in x-session, i can't even close the application (no esc, no ctrl-c,...) - the input in textfields is working though. What i found out about that issue is, that Kivy is rendered on top of your x-session - and your mouse seems also to be still active behind your app. This also seems to be the reason, why you don't see your mouse-cursor, when you don't enable the workaround with "touchring = show_cursor=true" in your config.ini. (The thing here is, that i only see the touchring when i press my mousebutton - probably should further look into kivy's touchring module docs) Therefore, the only real way to run kivy on raspbian atm is to reboot into cli and start your app there. |
If I start the application from terminal application in x-session, ctrl-c works. But if the application is started by autorun after login, ctrl modifier does not work. Mouse-cursor is visible always and working good (except click is done on upper left corner of the touchring icon). The only solution is running in cli mode, as you have mentioned. |
Confirming this issue as well. I have opened a StackOverflow question regarding this. |
same problem here. still no soution? :/ |
RPi Kivy apps don't run within X. In order to utilize the hardware acceleration on the RPi we have to write directly to a framebuffer, which renders over whatever would otherwise be on the screen (X11 or a VT). As such, we don't do anything with X Input, so input events are still passed to X if it's running, and all RPi Kivy apps are fullscreen. |
FYI: I made a workaround. sample code: // gcc -Wall -L/usr/X11R6/lib -lX11 kivyrun.c -o kivyrun
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned long RGB(Display *disp,
unsigned char r,
unsigned char g,
unsigned char b)
{
XColor xc;
Colormap cm = DefaultColormap(disp, DefaultScreen(disp));
xc.red = 257 * r;
xc.green = 257 * g;
xc.blue = 257 * b;
XAllocColor(disp, cm, &xc);
return xc.pixel;
}
int main(int argc, char *argv[])
{
char cmdStr[1024];
Display *disp;
XWindowAttributes attr;
XSetWindowAttributes myAttr;
Window myWin, rootWin;
int screen;
GC gc;
if (argc != 2) {
fprintf(stderr, "Usage: %s SCRIPT_FILE_NAME\n", argv[0]);
exit(1);
}
disp = XOpenDisplay(":0.0");
if (disp == NULL) {
fprintf(stderr, "Cannot open display\n");
exit(1);
}
rootWin = DefaultRootWindow(disp);
screen = DefaultScreen(disp);
XGetWindowAttributes(disp, rootWin, &attr);
myAttr.override_redirect = True;
myWin = XCreateWindow(disp, RootWindow(disp, screen),
0, 0, attr.width, attr.height, 0,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect, &myAttr);
XMapWindow(disp, myWin);
gc = XCreateGC(disp, myWin, 0, 0);
XSetForeground(disp, gc, RGB(disp, 0, 0, 0));
XFillRectangle(disp, myWin, gc, 0, 0, attr.width, attr.height);
XFlush(disp);
snprintf(cmdStr, 1024, "python %s", argv[1]);
printf("%s\n", cmdStr);
system(cmdStr);
XCloseDisplay(disp);
return 0;
} Please type:
instead of
|
Thanks for posting that workaround! I've tried it out on my RPi but it throws the "Cannot open display" error, so I'm assuming something goes wrong in the XOpenDisplay. I'm new to Kivy and Python in general, and have zero experience with C so I'm at a loss as to what I'm doing wrong. Do you have any suggestions for troubleshooting steps I could take to help fix this? If it helps, I'm running Raspbian Jessie and Kivy 1.9.2. Any help would be greatly appreciated! |
dirkjan237, I think you didn't have an authorization of X-window at that time. At first, you should login to X11-desktop. If you found the error again, type 'echo $DISPLAY' on LXTerminal and compare with the parameter of XOpenDisplay(":0.0") in the source code. example1:
You have to change the parameter below:
example2:
You have to run the X11-desktop first. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Seeing the same thing on Raspbian stretch. That would be expected from the comment by kivyd above, but I wanted to remind the developers about it so that the stale bot won't close the issue. Kivy and the official touchscreen are a killer match for a lot of uses, so a fix would be nice. |
@Hayatomon 's C file helped in running the Kivy app with the X11 still open in the back. Thank You @Hayatomon |
I found a better solution if you use Xorg (= desktop screen, x-session) on HDMI-1 and a Kivy app on DSI-1. As @kived explains, a Kivy app draws directly to a framebuffer bypassing the X server. But the touchscreen itself is listed as an X input in the X server:
From Disable mouse (not touchpad!) in Xorg while idle I could disable temporarily the touchscreen in Xorg but not in the Kivy app as following:
I will check if there is something that is more persistent like How to disable touchpad completely on boot? |
I'm having the same issue with this configuration:
A fix would be nice. |
@Hayatomon 's solution still working so far, using Raspbian 9 (stretch).
|
In my application I am popping up the terminal window in front, but its popping up the window but in background. I tried using sdl2, its so slow. If anyone has found any other solution? Or if any body has tried the kivypie distribution? |
This is an issue not only with X. I am running a Kivy app using egl_rpi and No X windows, and using hidinput. All the keys are going to the shell in the backround potentially causing havoc as they run commands in that shell. The keys are also seen by Kivy of course. The X solution above won't work in this case as there is no X. I am actually quite surprised this is still an issue. |
FYI my current solution to this when running in egl_rpi (no X) is to run my kivy app in the following shell script...
This stops the echoing of the characters to the background shell, then eats up the characters before the shell can get them. |
+1, though a few years have now passed - maybe there's a proper solution? I use a barcode reader which acts as a USB HID keyboard; each scan prints the barcode's content + CR to the console even when the Kivy app is running. This leads to repeated failed logins on the terminal:
|
can't you just configure the default tty to have no console on, just like the one for X on most distribution, so the touches/keyboard events are not received by anything? (and you can still use alt-fN to switch to a different tty), this is system configuration, not something kivy can really solve in a general case. |
Absolutely, in fact I was going to do that before deployment anyway, to get a completely blank boot-screen. I just thought there might be some way in Python/Kivy to capture a particular USB device and gobble up everything it produces. |
do |
Doing this prevents the application from using the OpenGL ES broadcom driver on my raspberry pi 3. Only way to use hardware acceleration is to set the DIPLAY environment variable to nothing. Maybe I'm doing something wrong and there's another way to force SDL2 to use the hardware chip... |
I worked around my problem by disabling the xinput device at lauch in my kivy app and enabling it again just before exiting. Not a nice solution though... |
Closing as this isn't a bug in Kivy; it is a configuration issue with several workarounds given above. |
On Raspberry Pi 2 Raspian Jessie, mouse and keyboard works but on fullscreen app (could not found a way to run in a windows btw) mouse and keyboard clicks are passed to desktop screen. No problem with binding keys on keyboard, or mouse working, eg/ on settings screen, but those mouse clicks cause running some applications on the background.
The text was updated successfully, but these errors were encountered: