Xlib: XKeysymToKeycode hangs


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Xlib: XKeysymToKeycode hangs
# 1  
Old 12-24-2012
Xlib: XKeysymToKeycode hangs

Two simple questions related to the following puzzling behaviour:

I have the following line of code:

Code:
   const KeyCode kc = XKeysymToKeycode(_display_p, ks);

where _display_p is a valid Display* returned from XOpenDisplay() and ks has the value 103 (which was returned by XStringToKeysym(), and corresponds to 'g').

The above line of code hangs indefinitely; I have to kill the job manually.

Question #1: why is this happening? I can't see anything in any documentation that suggests that XKeysymToKeycode() can ever fail to return.

Question #2: how do I stop the call from hanging?
# 2  
Old 12-24-2012
Ok - this is C, you assert the _display_p variable is valid. You know this how?

Please post your code.
# 3  
Old 12-26-2012
Quote:
Ok - this is C, you assert the _display_p variable is valid. You know this how?

Please post your code.
The pertinent class is called keyboard_queue.

In the class definition, there is:

Code:
  Display*                    _display_p;   // the X display pointer

The constructor provides a value for this in the initializer list:

Code:
  _display_p(XOpenDisplay(NULL)),

The value is tested inside the construstor, just in case the call to XOpenDisplay() failed:

Code:
 if (!_display_p)
  { cerr << "Fatal error: unable to open display" << endl;
    exit (-1);
  }

Then, inside a member function called push_key_press, occurs the line that hangs (I have temporarily, while testing, replaced the call to the variable ks of type KeySym with an explicit value, XK_g):

Code:
   const KeyCode kc = XKeysymToKeycode(_display_p, XK_g);

Following the initialisation of _display_p in the class constructor, the only place that _display_p is used is in direct calls to X functions: I never access it myself.

If I remove the line that hangs, and code that depends on it, then everything else -- in particular, all the calls to X functions, both prior to and subsequent to the offending line -- works as expected.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Linux (Xlib) Application hangs on GetGeometry()

Hello, I was just wondering why XGetGeometry() would cause a hang in an application. In the xlib book it says any of there "Get" functions don't necessarily return immediately. Is there a way to make a it return immediately or other functions that will give me the same results. I... (1 Reply)
Discussion started by: TMurray77
1 Replies

2. Programming

Xlib search window by his name

Hello, I just try to get the control of a Window by searching his name. I curretly do that : Window CMD::window_from_name_search(Display *display, Window current, char const *needle) { Window retval, root, parent, *children; unsigned children_count; char *name = NULL; ... (0 Replies)
Discussion started by: Loustak
0 Replies

3. Programming

[xlib] Image has just 1/4 size

Hello, i'm trying to show the Image of an monochrome webcam in an xlib-Window. initializing of the window: if (NULL == ((*XWindow)->display = XOpenDisplay(NULL))) APPLICATION_Set_Error(V4LCamera->Application, XWINDOW, "failed to open display", 123, -1, APPLICATION_ERROR_MESSAGE); ... (1 Reply)
Discussion started by: mirrowwinger
1 Replies

4. Programming

Xlib registering

hey, Im new to the linux world. Lately, I have tried to create a glx window with xlib, making it a popup window(fullscreen) so I set override_redirect to true. Im happy with the removed borders, but apparantly, the application doesnt show up in the left bar in ubuntu, neither when I press alt... (4 Replies)
Discussion started by: thedardanius
4 Replies

5. Homework & Coursework Questions

Xlib help - Array of Structs

Hey guys! First of all english is not my main language so sorry for any english mistakes. Im from Portugal! 1. The problem statement, all variables and given/known data: Im having a problema creating and array of structs for a work i need to do. (xLib) 2. Relevant commands, code,... (1 Reply)
Discussion started by: Spiritvs
1 Replies

6. UNIX for Advanced & Expert Users

xlib and keyboard events

1. If there's some better place where xlib experts hang out, please tell me. Despite an assiduous search, I could not find an xlib reflector. 2. My actual question: In an xterm, I want to grab and process all keyboard events in a program running inside the xterm. For example, with my program... (5 Replies)
Discussion started by: N7DR
5 Replies

7. UNIX for Dummies Questions & Answers

Xlib Errors

Hi, I am handling user issues in my team. Users have their Unix session running on Citrix MFU. Recently, I was suppose to address a user issue which is as below: Gets the below error when tries to open nedit: Xlib: connection to ":165.0" refused by server Xlib: Client is not... (1 Reply)
Discussion started by: mspatil0037
1 Replies

8. Programming

Xlib simple program.

I don't know if it is right to ask you this. Can someone help me write a simple Xlib program,with button on it,and all that button do is switch 2 messages. I have tried and tried,but never get past Hello World. Can someone help me please? ---------- Post updated at 10:17 PM ---------- Previous... (2 Replies)
Discussion started by: megane16v
2 Replies

9. UNIX and Linux Applications

vncserver xlib error

Hello! Im running tight VNC on Red Hat Enterprise Linux 4.0. How can I increase the number of X clients that I can run in a VNC session?I need to run aproximately 500 programs in one VNC session, but at this time I can only 236 -> i've tryed to launch 250 xclock's in background and when it... (0 Replies)
Discussion started by: karpoand
0 Replies

10. UNIX for Advanced & Expert Users

xlib error

Hello! Im running tight VNC on Red Hat Enterprise Linux 4.0. How can I increase the number of X clients that I can run in a VNC session?I need to run aproximately 500 programs in one VNC session, but at this time I can only 236 -> i've tryed to launch 250 xclock's in background and when it... (3 Replies)
Discussion started by: karpoand
3 Replies
Login or Register to Ask a Question