xlib

Any efficient way of converting XImage data to pixel map (e.g. array of RGB quads)?

末鹿安然 提交于 2019-12-05 03:55:52
问题 I'm trying to capture images with XGetImage. Everything fine but I need to send the data to a module which expects an array of RGB quads. Calling XGetPixel for every pixel in the image is very slow (0.5 seconds on a i5 for 1440x900 resolution). I've looked up the XGetPixel source code in xlib and the reason is obvious, a lot of computations are done for each pixel. Is there any efficient (or maybe completely different) way of doing this? 回答1: With the MIT Shared Memory Extension you can store

Load image onto a window using xlib

≯℡__Kan透↙ 提交于 2019-12-05 01:20:40
问题 I've created window class and i want to insert an image as a background of that window. File formats need to be png. I used XImage of magick++ to load an image. but don't know how to make its as a background of my window. Any idea how to do it? 回答1: Create an Pixmap using Pixmap XCreatePixmap(display, d, width, height, depth) Display *display; // The display Drawable d; // The Window for which to set the background Create a Graphics Context for the Pixmap GC XCreateGC(display, d, valuemask,

Window position in Xlib

痴心易碎 提交于 2019-12-05 00:35:51
问题 How to get top-level window position relative to root window (i.e. whole screen) using plain ol' xlib (or brand new XCB)? 回答1: The x,y components of the structure returned by XGetWindowAttributes are relative to the origin of the window's parent. That's not the same as relative to the top left of the screen. Calling XTranslateCoordinates passing the root window and 0,0 gives coordinates of the window relative to the screen. I found that if I write: int x, y; Window child; XWindowAttributes

XLib Window Name Problems

风流意气都作罢 提交于 2019-12-04 14:51:33
since 4 days, I try to see how XLib works, and I have finally understood that. Si I tried to make a short program wich retrieve open window's name. For that, I created 2 functions : Window *list (Display *disp, unsigned long *len) { Atom prop = XInternAtom(disp,"_NET_CLIENT_LIST",False), type; int form; unsigned long remain; unsigned char *list; if (XGetWindowProperty(disp,XDefaultRootWindow(disp),prop,0,1024,False,XA_WINDOW, &type,&form,len,&remain,&list) != Success) { return 0; } return (Window*)list; } So, this first function return a window object of all the windows. Then, I created a

What is the fastest way to display an image in QT on X11 without OpenGL?

与世无争的帅哥 提交于 2019-12-04 11:11:42
问题 I need to display a raw image in a QT widget. I'm running X11 on a framebuffer, so OpenGL is not available. Both the image and the framebuffer are in the same format - RGB565, but I can change it to any other format if needed. I don't need blending or scaling. I just need to display pixels as is. I'm using QPainter::drawImage, but it converts QImage to QPixmap and this conversion seems to be very slow. Also it is backed by Xrender and I think there is unnecessary overhead required to support

Excluding some keys from XGrabKeyboard

旧城冷巷雨未停 提交于 2019-12-04 07:10:30
Consider an application where it's desirable to grab the keyboard when focused in order to capture all window manager commands (Alt+F4 and whatnot) for processing. Now, this has the downside that the user has no way of switching to another application or virtual desktop via the keyboard when the keyboard is grabbed. I'd like to have a user-defined whitelist of key combination (say, the key combinations for switching virtual desktops) that are excluded from the grab. I can think of two possible approaches. When a whitelisted key event arrives, either Somehow tell X to continue processing it as

drop/rewrite/generate keyboard events under Linux

隐身守侯 提交于 2019-12-04 04:51:23
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 intercept/generate). or they use passive/active grabs in X (read more on that below). A Small DSL I explain

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

元气小坏坏 提交于 2019-12-03 21:33:51
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 found are using root.change_attributes(event_mask=X.ButtonPressMask | X.ButtonReleaseMask) Which does

Any efficient way of converting XImage data to pixel map (e.g. array of RGB quads)?

ⅰ亾dé卋堺 提交于 2019-12-03 21:13:44
I'm trying to capture images with XGetImage. Everything fine but I need to send the data to a module which expects an array of RGB quads. Calling XGetPixel for every pixel in the image is very slow (0.5 seconds on a i5 for 1440x900 resolution). I've looked up the XGetPixel source code in xlib and the reason is obvious, a lot of computations are done for each pixel. Is there any efficient (or maybe completely different) way of doing this? With the MIT Shared Memory Extension you can store an image in a shared memory area. This way you avoid going through the Xlib IPC channel when processing the

Why I set xlib window background transparent failed?

拈花ヽ惹草 提交于 2019-12-03 17:16:56
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(display), vinfo.visual, AllocNone); attr.border_pixel = 0; attr.background_pixel = 0; Window win =