xlib

drop/rewrite/generate keyboard events under Linux

别来无恙 提交于 2019-12-05 22:28:21
问题 I would like to hook into, intercept, and generate keyboard (make/break) events under Linux before they get delivered to any application. More precisely, I want to detect patterns in the key event stream and be able to discard/insert events into the stream depending on the detected patterns. I've seen some related questions on SO, but: either they only deal with how to get at the key events (key loggers etc.), and not how to manipulate the propagation of them (they only listen, but don't

Embedding QWidget into X11 Window

旧时模样 提交于 2019-12-05 22:00:12
问题 I want to embed two QWidgets into a window created using XLib. I have written this code: // Assume all the necessary headers included int main(int argc, char *argv[]) { QApplication app(argc, argv); // Create widget 1 QWidget widget1 ; widget1.setGeometry(44,44,666,666); widget1.show(); // Create widget 2 QWidget widget2 ; widget2.setGeometry(144,144,666,666); widget2.show(); Display *display = XOpenDisplay( 0 ); // 0 parameter for default values if ( display != NULL ) { // Create the x11

XSelectInput is not working for ButtonPressEvents,how to do it?

眉间皱痕 提交于 2019-12-05 20:20:01
I am writing a simple programmes in C where i want to capture all the mouse and Keyboard events that are taking place. I tried to use "XGrabPointer" but it results in locking the screen and i can not go to other applications. I tried with "XSelectInput()" and now i am receiving the keyboard events successfully but i am not getting any mouse click events. Any idea how can i do it? The code snippet is as follows: #include <stdio.h> #include <stdlib.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> int main(int argc, char **argv) { Display *dpy; Window root; unsigned long

Create a click through window for Linux

ぃ、小莉子 提交于 2019-12-05 18:34:50
I want to make a click through window. A window which I click but the click pass to the window below it. I've found this two solutions for windows: How to make click-through windows PyQt I have a form that can "click through", i.e. direct clicks to the window below. How can I undo my changes after the event? But I want it to work in linux. I study the xlib mechanisms but cannot understand how the window stack works. Actually I can get all the windows with XQueryTree() and found the ones under my window. But I don't know witch one are above. 来源: https://stackoverflow.com/questions/30670032

grabbing keyboard doesnt allow changing focus

自古美人都是妖i 提交于 2019-12-05 18:29:15
as soon as i use display.grab_keyboard, no other window seems to know of its own focus. with the keyboardgrab running i can select other windows and even send keyevents to them, but if this window is a text input there will be no blinking cursor. i read something about grab_keyboard generating focusevents, but that doesnt mean it blocks all focus events, does it? what am i not getting here? from Xlib import X,XK from Xlib.display import Display import signal,sys root = None display = None def main(): # current display global display,root display = Display() root = display.screen().root root

Draw on top of the screen using xlib

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 10:54:21
I want to draw some primitives on top of all windows on the screen. I've found some code in C and tried to port it to use python's xlib: from Xlib.display import Display from Xlib import X from Xlib import protocol display = Display(':0') root = display.screen().root gc = root.create_gc() root.fill_rectangle(gc, 100, 100, 500, 500) But nothing appears on the screen (however, the root window is assigned: grabbing keyboard after it works). How to do this correctly? Andrey Sidorov You can draw on root window - your code probably works, but root window may be obscured by some kind of desktop

How can I monitor mouse events with Python Xlib instead of capture them?

好久不见. 提交于 2019-12-05 07:26:46
问题 I need to monitor and filter mouse events with Xlib in Python. So far I have found out that this code receives events, but does not pass them on, so I can't actually do anything with the mouse anymore. from Xlib.display import Display from Xlib import X display = Display(':0') root = display.screen().root root.grab_pointer(True, X.ButtonPressMask | X.ButtonReleaseMask, X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime) while True: print "Event:" print display.next_event() Alternatives I

Why I set xlib window background transparent failed?

£可爱£侵袭症+ 提交于 2019-12-05 06:37:43
问题 I use the following code to get a transparent window, but it returns black.What's wrong with me? And, can anybody give me a simple example to create a window with transparent background?THANKS! #include <X11/Xlib.h> #include <X11/Xutil.h> int main(int argc, char* argv[]) { Display* display = XOpenDisplay(NULL); XVisualInfo vinfo; XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo); XSetWindowAttributes attr; attr.colormap = XCreateColormap(display, DefaultRootWindow

How to set Xlib window background transparent?

蹲街弑〆低调 提交于 2019-12-05 06:34:58
问题 I want to create a window that has transparent background. How to do it? I use XSetBackground(display, gc, 0) , the background is black . I change the depth of the screen to 32 . The result is still black. Here is my code: display = XOpenDisplay(getenv("DISPALY")); screen = DefaultScreen(display); depth = DefaultDepth(display,screen); printf("depth: %d\n", depth); rootwindow = RootWindow(display,screen); XVisualInfo vinfo; XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor,

How do we simulate a mouse click with Xlib / C?

…衆ロ難τιáo~ 提交于 2019-12-05 04:14:32
I want to find C / Xorg code to 'enter' a left mouse button click. I'd expect a single line of code but the only things I've found written in C are about two dozen lines long and they don't work anyway :( It seems it can be done in Windows, but I'm in Linux. The reason for the question is that I've written a utility that lets me move my mouse pointer between several screens using the keyboard. The only problem is that if I move to a location where window abc used to be but another window xyz has been loaded on top of that same location, the mouse pointer moves to xyz just fine, but xyz doesn't