Skip to content

Commit

Permalink
Removed warning on deprecated XKeycodeToKeysym()
Browse files Browse the repository at this point in the history
New X11 headers define `XKeycodeToKeysym()` as deprecated.

I looked around and found a solution, which involves
`XGetKeyboardMapping()` and `XFree()`:

http://stackoverflow.com/a/14408715

I have zero knowledge of X11 so it might be wrong in any way.
  • Loading branch information
alexdantas committed Aug 12, 2014
1 parent eaaa2b1 commit ad252f1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* FILE board.c
* MODULE OF snake4 - game of snake eating fruit
*
* DESCRIPTION
* DESCRIPTION
*
* WRITTEN BY Sverre H. Huseby <shh@thathost.com>
*
Expand Down Expand Up @@ -443,7 +443,7 @@ void
boardHandleEvent(XEvent *evt)
{
static int setupDone = 0;
KeySym ks;
KeySym* ks;

switch (evt->type) {
case Expose:
Expand All @@ -469,8 +469,10 @@ boardHandleEvent(XEvent *evt)
}
break;
case KeyPress:
ks = XKeycodeToKeysym(winDisplay, evt->xkey.keycode, 0);
switch (ks) {
{
int keysyms_per_keycode_return;
ks = XGetKeyboardMapping(winDisplay, evt->xkey.keycode, 1, &keysyms_per_keycode_return);
switch (*ks) {
case XK_Up:
case XK_A:
case XK_a:
Expand Down Expand Up @@ -540,7 +542,9 @@ boardHandleEvent(XEvent *evt)
winChooseLevel(5);
break;
}
XFree(ks);
break;
}
}
}

Expand Down

2 comments on commit ad252f1

@alexdantas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sverrehu , please evaluate if this follows your code style.
It is my first actual change to the code and I'm unsure on what might suit you or not.

@sverrehu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to prefer camel case over the underscore thing. :)

Please sign in to comment.