xlib

Detect window focus changes with XCB

无人久伴 提交于 2021-02-19 06:10:14
问题 I'm writing a program with XCB that needs to detect whenever a window gains or loses focus. So far I have this but it just hangs on the xcb_wait_for_event call, never entering the loop. What am I missing here to grab root events? Or am I just going about this totally wrong and there's a better way than listening to the root? #include <stdio.h> #include <stdlib.h> #include <xcb/xcb.h> int main (int argc, char **argv) { xcb_connection_t* conn = xcb_connect(NULL, NULL); if (xcb_connection_has

Detect window focus changes with XCB

吃可爱长大的小学妹 提交于 2021-02-19 06:05:56
问题 I'm writing a program with XCB that needs to detect whenever a window gains or loses focus. So far I have this but it just hangs on the xcb_wait_for_event call, never entering the loop. What am I missing here to grab root events? Or am I just going about this totally wrong and there's a better way than listening to the root? #include <stdio.h> #include <stdlib.h> #include <xcb/xcb.h> int main (int argc, char **argv) { xcb_connection_t* conn = xcb_connect(NULL, NULL); if (xcb_connection_has

Controlling multiple pointers with Xlib or xinput in ubuntu/linux

廉价感情. 提交于 2021-02-10 23:25:50
问题 I'm creating a system that uses multiple cursors (pointers) in multiple xsessions. My computer has multiple video cards in it for controlling different monitors. I want to have a different cursor on each screen and control each. Each monitor is a different session. I started using the xlib library in C to control the single cursor I have using the following command: XWarpPointer(display,None,window,0,0,0,0,x,y); This works perfectly for one cursor. Then I created a second cursor using xinput

XWarpPointer does not work on ubuntu 12.04 in wmware player

五迷三道 提交于 2021-02-08 11:30:23
问题 Hello i'm trying to move the mouse pointer by using Xlib in my Qt application: cout <<"move mouse to "<<x<<","<<y<<endl; XWarpPointer(defaultdisplay, None, desktoproot, 0, 0, 0, 0, x, y); XFlush(defaultdisplay); //QCursor::setPos(x,y); but this not work in an ubuntu that is inside a wmware player (maybe vmware tools uses X11), any idea for disabling the vmware mouse integration or using any other code? thanks. 回答1: i finally found the solucion, all i needed to do is edit the .vmx file in my

Resolve union structure in Rust FFI

谁说我不能喝 提交于 2021-02-07 14:23:20
问题 I have problem with resolving c-union structure XEvent. I'm experimenting with Xlib and X Record Extension in Rust. I'm generate ffi-bindings with rust-bindgen. All code hosted on github alxkolm/rust-xlib-record. Trouble happen on line src/main.rs:106 when I try extract data from XEvent structure. let key_event: *mut xlib::XKeyEvent = event.xkey(); println!("KeyPress {}", (*key_event).keycode); // this always print 128 on any key My program listen key events and print out keycode . But it is

How to catch X errors?

眉间皱痕 提交于 2021-02-07 07:19:27
问题 I tried searching the web, but I must note that finding materials about this aspect of X programming is not really easy. I use X with GLX to create OpenGL contexts. I already know my current graphics card driver only supports up to OpenGL API version 3.3, but I want my application to be able to try to create a context with any kind of version (as it could run on other computers). My code goes like this : Version <- requested OpenGL Version (by example : 3.3) Create a context : if Version is 3

How to catch X errors?

隐身守侯 提交于 2021-02-07 07:19:18
问题 I tried searching the web, but I must note that finding materials about this aspect of X programming is not really easy. I use X with GLX to create OpenGL contexts. I already know my current graphics card driver only supports up to OpenGL API version 3.3, but I want my application to be able to try to create a context with any kind of version (as it could run on other computers). My code goes like this : Version <- requested OpenGL Version (by example : 3.3) Create a context : if Version is 3

Detect if compositor is running

爷,独闯天下 提交于 2021-02-07 04:20:44
问题 I want my UI to change design depending on whether the screen is composited (thus supporting certain effects) or not. Is it possible to Reliably query whether the X server is running a compositing window manager Get notified when compositing is switched on/off? Solution: To elaborate on Andrey Sidorov's correct answer for people not so familiar with the X11 API, this is the code for detecting a EWMH-compliant compositor: int has_compositor(Display *dpy, int screen) { char prop_name[20];

Detect if compositor is running

会有一股神秘感。 提交于 2021-02-07 04:19:22
问题 I want my UI to change design depending on whether the screen is composited (thus supporting certain effects) or not. Is it possible to Reliably query whether the X server is running a compositing window manager Get notified when compositing is switched on/off? Solution: To elaborate on Andrey Sidorov's correct answer for people not so familiar with the X11 API, this is the code for detecting a EWMH-compliant compositor: int has_compositor(Display *dpy, int screen) { char prop_name[20];

How do I simulate mouse clicks with Xlib on Python

时光毁灭记忆、已成空白 提交于 2021-02-06 13:47:23
问题 For educational purposes I've set out to write a python script using cwiid and Xlib so that I can use my wiimote like a mouse. So far I've gotten the cursor to move by calling disp.warp_pointer(dx,dy) then calling disp.sync() every set time interval. I'm afraid that it might not be the most efficient way to do it but at least for now, it's simple and works well enough. The problem I'm having more difficulty with is mouse clicks. How do I simulate a mouse click in Xlib? I would like separate