Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Desktop Environments
  • Search

Stupid mistake of XFree86

Problems with GUI applications? Questions about X, KDE, Gnome, Fluxbox, etc.? Come on in. NOTE: For multimedia, go up one forum
Post Reply
Advanced search
13 posts • Page 1 of 1
Author
Message
MadEgg
l33t
l33t
User avatar
Posts: 678
Joined: Thu Jun 06, 2002 7:46 pm
Location: Netherlands

Stupid mistake of XFree86

  • Quote

Post by MadEgg » Tue Apr 15, 2003 4:33 pm

I'm one of those from the old days ;) that still like to use the directional keys on the numpad instead of directional keys left of the numpad.

That works most of the time, but X has some stupid mistake that confuses Shift with numlock.

When I press and hold shift and push one of the directional keys, it assumes I want the number of that key, instead of moving in that direction, so when I press shift + right, I get a 6, while I was just trying to expand my selection to the right. And that should only happen when numlock is on. It happens the other way around when I press numlock, making numlock act as an alternative capslock for the numpad. IMHO that is completely wrong.

Is there any way I can stop X from toggling between cursors and numbers when pressing shift, but keep toggling when using numlock?
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Top
MadEgg
l33t
l33t
User avatar
Posts: 678
Joined: Thu Jun 06, 2002 7:46 pm
Location: Netherlands

  • Quote

Post by MadEgg » Thu Apr 17, 2003 7:26 pm

*subtle bump*
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Top
MadEgg
l33t
l33t
User avatar
Posts: 678
Joined: Thu Jun 06, 2002 7:46 pm
Location: Netherlands

  • Quote

Post by MadEgg » Fri Apr 18, 2003 5:13 pm

noone? :(
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Top
PowerFactor
Veteran
Veteran
User avatar
Posts: 1693
Joined: Thu Jan 30, 2003 7:45 pm
Location: out of it

  • Quote

Post by PowerFactor » Fri Apr 18, 2003 6:04 pm

Well, you could try playing with xmodmap some. I tried briefly but didn't get it to work like you wanted.
Top
MadEgg
l33t
l33t
User avatar
Posts: 678
Joined: Thu Jun 06, 2002 7:46 pm
Location: Netherlands

  • Quote

Post by MadEgg » Fri Apr 18, 2003 9:35 pm

Yea, that's what I tried.. but this seems something completely different...
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Top
pjp
Administrator
Administrator
User avatar
Posts: 20708
Joined: Tue Apr 16, 2002 10:35 pm

  • Quote

Post by pjp » Fri Apr 18, 2003 9:39 pm

Have you tried using xev to see if that helps? Run it from a terminal so you can see the output.
Quis separabit? Quo animo?
Top
j-kidd
Apprentice
Apprentice
User avatar
Posts: 213
Joined: Thu Feb 20, 2003 5:27 pm

  • Quote

Post by j-kidd » Sat Apr 19, 2003 2:45 am

I found a partial solution, which not only disable the effect of capslock on keypad, but disable the effect of numlock as well :roll:

Just put this into ~/.xmodmap

Code: Select all

keycode 0x4F =  KP_Home
keycode 0x50 =  KP_Up
keycode 0x51 =  KP_Prior
keycode 0x53 =  KP_Left
keycode 0x55 =  KP_Right
keycode 0x57 =  KP_End
keycode 0x58 =  KP_Down
keycode 0x59 =  KP_Next
And then add this line into ~/.xinitrc

Code: Select all

xmodmap ~/.xmodmap
In my opinion, "Shift + keypad = number" is a really stupid behavior... if I want to type a few numbers, I use the row of 1234567890... if I want to type a lot of numbers, I switch on numlock and use the keypad... why Shift? :?

Anyway, I really hope someone can come up with a good solution :)
Top
MadEgg
l33t
l33t
User avatar
Posts: 678
Joined: Thu Jun 06, 2002 7:46 pm
Location: Netherlands

  • Quote

Post by MadEgg » Sat Apr 19, 2003 8:03 am

Ok, this solves that part of the problem, but indeed it would be cool to do have them output numbers on numlock...

Hmmz, I figure I gotta do something with numlock as a modifier key then.
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Top
grant.mcdorman
Apprentice
Apprentice
User avatar
Posts: 295
Joined: Wed Jan 29, 2003 2:01 am
Location: Toronto, ON, Canada

  • Quote

Post by grant.mcdorman » Wed Apr 23, 2003 3:08 am

j-kidd wrote:I found a partial solution, which not only disable the effect of capslock on keypad, but disable the effect of numlock as well :roll:

Just put this into ~/.xmodmap

Code: Select all

keycode 0x4F =  KP_Home
keycode 0x50 =  KP_Up
snip..

This style of xmodmap code is usually A Bad Idea. The problem is that it will only work for your current keyboard - and possibly even your current version of XFree86. It will definitely break if you use VNC.

A better way of doing these things is:

Code: Select all

keysym KP_7 = KP_Home
keysym KP_8 = KP_Up
etc.

To answer the original question, though: what you want is supported by X, at least using xmodmap. I don't know much about the X keyboard extension (XKb) unfortunately.

The keypad normally has two symbols for each key; that is:

Code: Select all

7: KP_Home KP_7
8: KP_Up KP_8
and so forth. The shift key, of course, selects the second symbol. NumLock reverses the behavior, so the second symbol is selected when unshifted. There is no way to have the keypad ignore the shift key.

This behaviour is the same on Windows (and even in MS-DOS), for the most part.

It would be possible, however, to get a program to trap NumLock presses and dynamically change the keymap; I just whipped up a little program (54 lines) that can do this for you:

watch_numlock.c:

Code: Select all

#include <stdio.h>

#include <X11/Xlib.h>
#define XK_MISCELLANY
#include <X11/keysymdef.h>

static Display * disp;
static Screen  * scrn;
static Window    root;
static XEvent    event;
static KeyCode code;
static int is_on = 0;

int main(int argc, char *argv[])
{
    if (argc != 3) {
        fprintf(stderr, "Usage: %s num-lock-on-cmd num-lock-off-cmd\n",
                argv[0]);
        exit(1);
    }

    disp = XOpenDisplay(NULL);
    if (disp == NULL) {
        fprintf(stderr, "Could not open display\n");
        exit(1);
    }

    scrn = DefaultScreenOfDisplay(disp);
    root = RootWindowOfScreen(scrn);
    code = XKeysymToKeycode(disp, XK_Num_Lock);


    XGrabKey(disp, code, AnyModifier, root,
                True,
                GrabModeAsync, GrabModeAsync);


    while (1) {
        XNextEvent(disp, &event);
        if (event.xany.type == KeyRelease &&
            event.xkey.keycode == code) {
            XKeyboardState  keyboard_state;
            XGetKeyboardControl(disp, &keyboard_state);
            /* LED 2 is Num Lock */
            if (keyboard_state.led_mask & 2) {
                system(argv[1]);
            } else {
                system(argv[2]);
            }

        }
    }
    return -1;
}
Compile with

Code: Select all

gcc -o watch_numlock watch_numlock.c -L /usr/X11R6/lib -lX11
You could run it like this when you sign in to X:

Code: Select all

watch_numlock 'xmodmap -e make_num_keypad' 'xmodmap -e make_ctrl_keypad'
where make_num_keypad would look like:

Code: Select all

keysym KP_Home = KP_7
keysym KP_Up = KP_8
keysym KP_Prior = KP_9
and so on, and make_ctrl_keypad would be the reverse.

Hope this resolves your problem.
Top
grant.mcdorman
Apprentice
Apprentice
User avatar
Posts: 295
Joined: Wed Jan 29, 2003 2:01 am
Location: Toronto, ON, Canada

More comments on my last post

  • Quote

Post by grant.mcdorman » Wed Apr 23, 2003 4:47 pm

Some further comments.

First off, most applications can be set up with their own meanings for the numeric pad keys (or any other keys, for that matter). Older applications, like xterm, use the Intrinsics translation mechanism. Newer applications use different mechanism; KDE's konsole, for example, uses a key table (various key tables can be found in <KDE>/share/apps/konsole/). Gnome applications presumably have their own mechanism; I don't use Gnome apps that much, though, so I'm not familiar with them.

However, the solution (hack!) I gave changes the numeric keypad for *everything*.

For reference, the default Sun Solaris [XSun] keypad map looks like:

Code: Select all

keycode 53  = F25           F25       KP_Divide
keycode 54  = F26           F26       KP_Multiply
keycode 57  = Delete        Delete    KP_Decimal
keycode 75  = F27           F27       KP_7          Home
keycode 76  = Up            F28       KP_8
keycode 77  = F29           F29       KP_9          Prior
keycode 78  = KP_Subtract
keycode 97  = KP_Enter
keycode 98  = Left          F30         KP_4
keycode 99  = F31           F31       KP_5
keycode 100 = Right         F32       KP_6
keycode 101 = KP_Insert     KP_Insert KP_0
keycode 119 = F33           F33       KP_1          End
keycode 120 = Down          F34       KP_2
keycode 121 = F35           F35       KP_3            Next
keycode 132 = KP_Add
An interesting thing to note about this keyboard is that the shifted keys are, technically, neither the number nor the control. Sun's keyboard mappings are wierd in general, though. (For example, F11 is not F11 but SunF35; this is because F11 didn't exist on early Sun keyboards, so it was assigned to a key labeled Stop on the left side of the Sun keyboard).

The standard XFree86 US XKB layout is:

Code: Select all

symbols/us:    key <KPDV> {     [  KP_Divide            ]       };
symbols/us:    key <KPMU> {     [  KP_Multiply          ]       };
symbols/us:    key <KPSU> {     [  KP_Subtract          ]       };
symbols/us:    key  <KP7> {     [  KP_Home,     KP_7    ]       };
symbols/us:    key  <KP8> {     [  KP_Up,       KP_8    ]       };
symbols/us:    key  <KP9> {     [  KP_Prior,    KP_9    ]       };
symbols/us:    key <KPAD> {     [       KP_Add          ]       };
symbols/us:    key  <KP4> {     [  KP_Left,     KP_4    ]       };
symbols/us:    key  <KP5> {     [  KP_Begin,    KP_5    ]       };
symbols/us:    key  <KP6> {     [  KP_Right,    KP_6    ]       };
symbols/us:    key  <KP1> {     [  KP_End,      KP_1    ]       };
symbols/us:    key  <KP2> {     [  KP_Down,     KP_2    ]       };
symbols/us:    key  <KP3> {     [  KP_Next,     KP_3    ]       };
symbols/us:    key <KPEN> {     [       KP_Enter        ]       };
symbols/us:    key  <KP0> {     [  KP_Insert,   KP_0    ]       };
symbols/us:    key  <KP0> {     [  KP_Insert,   KP_0    ]       };
symbols/us:    key <KPDL> {  [  KP_Delete,      KP_Decimal ]    };
VNC (Xnvc) does not have a keypad setup.

Thus, a generic, fully portable, set of xmodmap files would be as follows. These files will work on any server at all, including the Sun Solaris server, XFree86 (any version) and VNC.

set numeric mode:

Code: Select all

! Ensure that we have all keysyms we're going to use assigned to something.

keycode any = KP_Insert
keycode any = KP_End
keycode any = KP_Down
keycode any = KP_Next
keycode any = KP_Left
keycode any = KP_Right
keycode any = KP_Home
keycode any = KP_Up
keycode any = KP_Prior
keycode any = KP_Delete

! Set the keypad to numeric mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_Insert = KP_0
keysym KP_End    = KP_1
keysym KP_Down   = KP_2
keysym KP_Next   = KP_3
keysym KP_Left   = KP_4
keysym KP_Right  = KP_6
keysym KP_Home   = KP_7
keysym KP_Up     = KP_8
keysym KP_Prior  = KP_9
keysym KP_Delete = KP_Decimal
set control mode:

Code: Select all

! Ensure that we have all keysyms we're going to use defined.

keycode any = KP_0
keycode any = KP_1
keycode any = KP_2
keycode any = KP_3
keycode any = KP_4
keycode any = KP_6
keycode any = KP_7
keycode any = KP_8
keycode any = KP_9
keycode any = KP_Decimal

! Set the keypad to control mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_0 = KP_Insert
keysym KP_1 = KP_End
keysym KP_2 = KP_Down
keysym KP_3 = KP_Next
keysym KP_4 = KP_Left
keysym KP_6 = KP_Right
keysym KP_7 = KP_Home
keysym KP_8 = KP_Up
keysym KP_9 = KP_Prior
keysym KP_Decimal = KP_Delete
Default mode:

Code: Select all

! Ensure that we have all keysyms we're going to use defined.

keycode any = KP_0
keycode any = KP_1
keycode any = KP_2
keycode any = KP_3
keycode any = KP_4
keycode any = KP_6
keycode any = KP_7
keycode any = KP_8
keycode any = KP_9
keycode any = KP_Decimal

! Set the keypad to normal (Num Lock controled) mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_0 = KP_Insert         KP_0
keysym KP_1 = KP_End            KP_1
keysym KP_2 = KP_Down           KP_2
keysym KP_3 = KP_Next           KP_3
keysym KP_4 = KP_Left           KP_4
keysym KP_6 = KP_Right          KP_6
keysym KP_7 = KP_Home           KP_7
keysym KP_8 = KP_Up             KP_8
keysym KP_9 = KP_Prior          KP_9
keysym KP_Decimal = KP_Delete   KP_Decimal
[edit: fixed syntax error, corrected 'keysym any' to 'keycode any']
Top
j-kidd
Apprentice
Apprentice
User avatar
Posts: 213
Joined: Thu Feb 20, 2003 5:27 pm

  • Quote

Post by j-kidd » Tue Apr 20, 2004 1:19 am

I just noticed that since months ago there has been an option added to toggle this behavior (bug #558 at xfee86 bugzilla).

So, to have the keypad working like in Windows, just add this line to your XF86Config or xorg.conf under the keyboard section

Code: Select all

Option "XkbTypes"   "default+numpad(microsoft)"
It has been 1 year since I last posted in this thread. I am glad that it is fully working now 8)
(my apologize to bump an old thread, as some people may find this useful)
Top
sufehmi
n00b
n00b
Posts: 6
Joined: Sat Sep 20, 2003 11:00 am
Contact:
Contact sufehmi
Website

  • Quote

Post by sufehmi » Sat Jul 30, 2005 4:04 am

j-kidd wrote:I just noticed that since months ago there has been an option added to toggle this behavior (bug #558 at xfee86 bugzilla).

So, to have the keypad working like in Windows, just add this line to your XF86Config or xorg.conf under the keyboard section

Code: Select all

Option "XkbTypes"   "default+numpad(microsoft)"
It has been 1 year since I last posted in this thread. I am glad that it is fully working now 8)
(my apologize to bump an old thread, as some people may find this useful)
Indeed I have :D I'm having a problem with VNC/Wine/Crossover Office, but it seems that this thread will finally enable me to resolve it.

I'll keep you all posted.


Thanks!
Harry
Top
sufehmi
n00b
n00b
Posts: 6
Joined: Sat Sep 20, 2003 11:00 am
Contact:
Contact sufehmi
Website

Solved !

  • Quote

Post by sufehmi » Mon Aug 01, 2005 7:36 am

Oh yes :D finally cracked it.
Now on Windows apps on Wine/Crossover Office, accessed via VNC, NumPad works !

Here's how I did it :

1. Create a xmodmap file, with these contents :

Code: Select all

! initialization,
! Ensure that we have all keysyms we're going to use assigned to something.

keycode any = KP_Insert
keycode any = KP_End
keycode any = KP_Down
keycode any = KP_Next
keycode any = KP_Left
keycode any = KP_Begin
keycode any = KP_Right
keycode any = KP_Home
keycode any = KP_Up
keycode any = KP_Prior
keycode any = KP_Delete

! Set the keypad to numeric mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_Insert = KP_0
keysym KP_End    = KP_1
keysym KP_Down   = KP_2
keysym KP_Next   = KP_3
keysym KP_Left   = KP_4
keysym KP_Begin  = KP_5
keysym KP_Right  = KP_6
keysym KP_Home   = KP_7
keysym KP_Up     = KP_8
keysym KP_Prior  = KP_9
keysym KP_Delete = KP_Decimal
Yes, it's quite similar to grant.mcdorman's post, with one addition: settings for Numpad 5 / KP_Begin key.

2. VNC sessions doesn't use ~/.xinitrc, but ~/.vnc/xstartup instead.
So that's where we put the following lines :

Code: Select all

# The line below is to enable NumPad in Windows Apps
xmodmap ~/.xmodmap
Done ! Problem solved.

Many thanks to everyone, especially to grant.mcdorman


cheers,
Harry
Top
Post Reply

13 posts • Page 1 of 1

Return to “Desktop Environments”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. and of Förderverein Gentoo e.V.
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license.
The Gentoo Name and Logo Usage Guidelines apply.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy