xlib

Window position in Xlib

亡梦爱人 提交于 2019-12-03 16:51:14
How to get top-level window position relative to root window (i.e. whole screen) using plain ol' xlib (or brand new XCB)? 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 xwa; XTranslateCoordinates( display, window, root_window, 0, 0, &x, &y, &child ); XGetWindowAttributes(

Load image onto a window using xlib

隐身守侯 提交于 2019-12-03 16:18: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? 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, values) Draw the XImage to the Pixmap XPutImage(display, pixmap, gc, image, src_x, src_y, dest_x, dest_y,

What do I need to do to link with xlib?

早过忘川 提交于 2019-12-03 14:56:48
问题 I am using GCC, what switches do I need to add to link with Xlib? After searching, all I could find was -lX11 , but that gave me ld: library not found for -lX11 I am using a mac (10.6), but I would not like anything that is Mac specific. 回答1: You can usually use pkg-config to determine the flags you need to pass: gcc my-program.c $(pkg-config --cflags --libs x11) -o my-program 回答2: $ locate libX11 /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libX11.6.2.dylib /Developer/SDKs/MacOSX10.4u.sdk

globally capture, ignore and send keyevents with python xlib, recognize fake input

不羁的心 提交于 2019-12-03 13:36:26
问题 i want to implement key chording on a normal keyboard and i thought i use python xlib. for this to work the program has to globally swallow all keyevents and only later allow them to go through. my current test just grabs the "1" key. if this key is pressed it calls a handler which sends "x" to the focused window via xtest.fake_input. because im only grabbing the "1"-key, there shouldn't be a problem, right? but somehow the handler gets called again, because "x" was pressed. in fact, the

Listening to keyboard events without trapping them?

≯℡__Kan透↙ 提交于 2019-12-03 11:43:21
问题 I'm writing an command-line application which listens for Control key release events in X Windows and alerts another process when it detects them. Being new to GNU/Linux, I'd prefer avoiding to fumble with GCC and therefore I'm looking for a scripting-based solution. Since I know a bit of Python, it seemed natural to go for a Python-based solution, and after scavenging the Internet for examples and reading Python Xlib docs, I've put together this programs which works, but with a caveat: it

Where are some good Xlib programming guides?

 ̄綄美尐妖づ 提交于 2019-12-03 07:52:58
问题 I'm a little confused on Xlib programming now. I started to use dwm (a lightweight window manager) a few weeks ago, and I'd like to pickup some Xlib programming books or online resource to customize the dwm. However, after Googling around the web, I don't see much new articles talking about Xlib?? The newest programming guide for X window system on Amazon is in 1994!? Is no new articles of Xlib because the old book are sufficient, or because there are some new technology that I'm not aware of

X11: How to delay repainting until all events are processed?

家住魔仙堡 提交于 2019-12-02 11:54:27
问题 I'm writing a program that has an X11/Xlib interface, and my event processing loop looks like this: while (XNextEvent(display, &ev) >= 0) { switch (ev.type) { // Process events } } The problem is when the window is resized, I get a bunch of Expose events telling me which parts of the window to redraw. If I redraw them in direct response to the events, the redraw operation lags terribly because it is so slow (after resizing I get to see all the newly invalidated rectangles refresh one by one.)

pointer motion. why are numbers so high? why does it print info in blocks not a constant stream?

馋奶兔 提交于 2019-12-02 06:11:45
Hi! I am trying to write a program where I need to report the position of every mouse motion. I have called the XSelectInput() function with a PointerMotionMask mask. Everything seems to work alright but the numbers after printing don't appear after every movement, they appear in blocks and also the numbers in event.xmotion.x and event.xmotion.y are very high, in the hundred thousands. What is causing these large numbers? Also is my program getting every number and reporting it immediately or is it being stored in a queue and sent in blocks to the terminal? Thanks Here's my event loop: while(1

Fatal IO error 0 (Success) on X server

守給你的承諾、 提交于 2019-12-01 19:02:46
问题 What does the error "Fatal IO error 0 (Success) on X server" mean? The error is produced when an X client tries to call XvCreateImage(), and it results in the client terminating. X.0.log shows the following version information: X.Org X Server 1.6.4 Release Date: 2009-9-27 X Protocol Version 11, Revision 0 Build Operating System: Linux 2.6.24-23-server i686 Ubuntu Current Operating System: Linux ori-laptop 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 16:20:31 UTC 2009 i686 Kernel command line:

simple window without titlebar

▼魔方 西西 提交于 2019-12-01 11:25:18
Good afternoon everyone! I have been working on a project that requires a basic window without a titlebar. After browsing a bit on the web I came across this post create window without titlebar with a reply mentioning the use of the "_NET_WM_WINDOW_TYPE_DOCK" atom. I attempted to create one in my project using the following code: Display* d = fl_display; XWindow w = XCreateSimpleWindow(d, RootWindow(d, fl_screen), 0, 0, 400, 100, 0, 0x000000, 0x000000); Atom window_type = XInternAtom(d, "_NET_WM_WINDOW_TYPE", False); long value = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);