Bug 492529

Summary: Openmotif accelerators XmNaccelerator do not work with CapsLock/ScrollLock/NumLock modifiers
Product: Red Hat Enterprise Linux 5 Reporter: Olivier Fourdan <ofourdan>
Component: openmotifAssignee: Thomas Woerner <twoerner>
Status: CLOSED ERRATA QA Contact: Filip Holec <fholec>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.2CC: cward, fholec, jwest, kem, pknirsch, psplicha, tao, yves.begrand
Target Milestone: rcKeywords: Patch, ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-01 00:32:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 569908    
Attachments:
Description Flags
Simple reproducer
none
Proposed patch
none
Reworked patch
none
Another reproducer none

Description Olivier Fourdan 2009-03-27 09:19:24 UTC
Created attachment 336982 [details]
Simple reproducer

Description of problem:

Motif (and subsequently Openmotif) were never ported to support X11R6 modifiers scheme.

As a result, keyboard accelerators do not work if on of the Lock keys (CapsLock/ScrollLock/NumLock) is engaged.

Version-Release number of selected component (if applicable):

openmotif-2.3.1-2.el5

How reproducible:

100% reproducible

Steps to Reproduce:
1. Save and build the attached reproducer
   $ cc -o accel accel.c -L/usr/lib -lXm -lXt -lX11

2. Run the reproducer, make sure no lock key is engaged and press Ctrl+W
   $ ./accel
   => The window closes as expected
2. Rerun the reproducer, now press NumLock key and press Ctrl+W
   $ ./accel
   => The window does not close
  
Actual results:

The accelerator does not work if CapsLock/ScrollLock/NumLock is engaged

Expected results:

The accelerator works independently of any CapsLock/ScrollLock/NumLock modifier

Additional info:

This is apparently a 14 years old flaw in Motif that was first reported in this bug upstream:

    http://bugs.motifzone.net/long_list.cgi?buglist=345

Proposed patch to follow.

Comment 1 Olivier Fourdan 2009-03-27 09:29:00 UTC
Created attachment 336985 [details]
Proposed patch

For the accelerators to work, we need to filter the state of the KeyPress event with the appropriate modifier mask.

But the mask depends on the actual modifiers mapping, so this needs to be determined first, that's the purpose of the InitModifiers() function in the patch.

Once the appropriate modifier mask is known, all that needs to be done is to use that mask prior to compare the state of the modifiers in the event and the expected modifiers in XmMatchKeyEvent() in lib/Xm/MapEvents.c

Comment 2 Olivier Fourdan 2009-03-27 09:33:44 UTC
Please also note that some Motif applications implement workarounds for that issue in Motif, like NEdit since 5.2 that has a mechanism to add the required grabs on all combinations of modifiers mask (that's in NEdit-5.5/util/misc.c)

AFAICT, the proposed fix in Openmotif does not break NEdit workaround, as the event will be processed either by Openmotif or by the additional grab in NEdit.

Comment 4 Olivier Fourdan 2009-04-30 11:47:33 UTC
Created attachment 341911 [details]
Reworked patch

The previous patch was just partially working, because the activa grabs were not modifed to also grab the various problematic modifiers combinations.

This new version adds the missing bits (ir XtGrabKey/XtUngrabKey of key + all modifiers combinations) and also refactor the added code a bit to be cleaner and hopefully more in line with upstream coding style.

Comment 5 Olivier Fourdan 2009-04-30 11:51:19 UTC
Created attachment 341912 [details]
Another reproducer

Another reproducer provided by the customer, that demonstrates the need for the updated patch (ie, the new reworked patch also fixes the problem in the case of that new reproducer)

Comment 11 Thomas Woerner 2010-02-12 17:16:42 UTC
This patch has been accepted upstream. (motifzone bz#345)

Comment 30 errata-xmlrpc 2013-10-01 00:32:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1355.html