LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2010, 04:54 PM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Capture X events


I wonder if there is a way to caputure all X keyboard events, blocking them from going to the window with keyboard focus?
 
Old 01-10-2010, 08:10 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Keyboard Grabbing
 
Old 01-10-2010, 12:47 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
So if I run XGrabKeyboard() no other, separate programs can get keyboard input (which is my goal)?
 
Old 03-17-2011, 02:55 PM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I decided to return to this, and found that XGrabKeyboard() really does what I want.

But when a grabbed key is pressed, how do I re-send it to the window that would have recieved the key had I not grabbed it?

Also, is it possible to use XGrabKeyboard() without having a window visible on screen? It doesn't grab the keyboard when the window isn't mapped.

Last edited by MTK358; 03-17-2011 at 02:56 PM.
 
Old 04-03-2011, 04:32 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Anyone?
 
Old 10-31-2011, 07:09 PM   #6
waltinator
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Rep: Reputation: 1
XGrabKeyboard controls handling of X events

XGrabKeyboard tells the X server "Send keyboards events ONLY to me", and, in between the XGrabKeyboard() and the XUngrabKeyboard (), the X server does not send X keyboard events to other clients. When you do the XUngrabKeyboard(), the X server goes back to sending X keyboard events to everybody who is registered for them. You don't have to forward an event to others. See man XGrabKeyboard for details.

When a window is offscreen the idea of a keyboard to be grabbed does not make sense, does it? How does a keyboard find an offscreen window?

If you really want to see all the characters, and let others see them, too, learn about X events.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture or monitor Mouse Button events in console lumpy2000 Linux - Software 1 02-10-2009 02:45 AM
Hang on triggering udev events- is there a buildup of events? sonichedgehog Slackware 20 07-11-2008 02:49 AM
How to capture Windows API Events sridhar_dct3 Linux - Software 1 10-18-2007 09:48 AM
Capture Windows Events erat123 Programming 1 07-05-2007 11:10 AM
how to capture mouse and keyboard events programatically karthikeyan Programming 3 02-21-2003 07:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration