Closed
Bug 197474
Opened 22 years ago
Closed 21 years ago
Event.altKey && Event.ctrlKey not true together unlike IE
Categories
(Core Graveyard :: GFX: Win32, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: tim.c.quinn, Assigned: emaijala+moz)
References
Details
Attachments
(3 files, 11 obsolete files)
1.77 KB,
text/html
|
Details | |
27.74 KB,
patch
|
neil
:
review+
bryner
:
superreview+
|
Details | Diff | Splinter Review |
24.95 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030210
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030210
I have a page speed tester I built in IE and I use the shift-control-alt-T to
start it. This works great in IE but not in mozilla. Looks like mozilla cannot
handle these special keys in combination.
I will attach a test case. The source should show the workings of the bug. This
code works in IE 5.5+ and Moz 5+. Pardon the cross browser js code at the top it
just makes my level 2 code much cleaner.
Reproducible: Always
Steps to Reproduce:
1.Press control key
2.While holding control key, press alt key
3.notice that control key output is now false
Actual Results:
Event.ctrlKey is true at 1 then when alt key is pressed (2) Event.ctrlKey is
false and Event.altKey is true.
Expected Results:
Event.ctrlKey && Event.altKeykey should be true when both are pressed
Reporter | ||
Comment 1•22 years ago
|
||
Please excuse the X-Browser stuff at top. This is my way of normaizing IE's
event stupidity.
Reporter | ||
Comment 2•22 years ago
|
||
Correction: when control and alt are pressed together, they are both false while
they should both be true. Shift and Alt and Shift with Control works correct
(both true).
![]() |
||
Updated•22 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 3•21 years ago
|
||
The problem is in the file /widget/src/windows/nsWindow.cpp, it's this code
(occures several times in the file):
// If the Context Code bit is down and we got a WM_KEY
// it is a key press for character, not accelerator
// see p246 of Programming Windows 95 [Charles Petzold] for details
mIsControlDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_CONTROL);
mIsAltDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_ALT);
I don't know what is said in this book but I cannot find anything on
microsoft.com that says that you have to ignore modifier keys when the context
code bit is set.
![]() |
||
Comment 4•21 years ago
|
||
Sounds like a win32 gfx issue....
Assignee: saari → win32
Component: DOM: Events → GFX: Win32
QA Contact: desale → ian
Assignee | ||
Updated•21 years ago
|
Assignee: win32 → ere
Assignee | ||
Comment 6•21 years ago
|
||
Changes in this patch:
- make it so that the alt, control and shift states are given as parameters to
DispatchKeyEvent to avoid messing around with the member variables
- control and alt are never down at the same time in keypress events (in this
case it's a keypress for a character)
- don't set control and alt state in WM_CHAR/WM_SYSCHAR, there is no point in
doing that
- don't use the context bit (it's not valid in WM_CHAR and useless anywhere
else too)
Assignee | ||
Updated•21 years ago
|
Attachment #142063 -
Flags: review?(danm-moz)
OK, there's no way that can be the right patch. I haven't looked through the
source yet, but is there any chance this is a copy-and-paste error?
mIsControlDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_CONTROL);
mIsAltDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_ALT);
Why are we looking for KF_ALTDOWN to determine if Control is pressed?
Assignee | ||
Comment 8•21 years ago
|
||
That's one of the things my patch removes. Did I miss something?
Comment 9•21 years ago
|
||
Is the reason that Mozilla doesn't allow you to use Ctrl+Alt+Shift+T is that in
theory a keyboard could map that to a unique character (Ŧ perhaps)?
Comment 10•21 years ago
|
||
Actually I just tried both Dean's keyboard test page and Spy++ and I don't get
WM_CHAR for Ctrl+Alt keys except for those which the keyboard driver remaps.
Assignee | ||
Comment 11•21 years ago
|
||
Comment on attachment 142063 [details] [diff] [review]
Possible patch
I discovered a problem with this patch. Dean's test page shows that we're now
firing two keypress events for AltGr-2 (@).
Attachment #142063 -
Attachment is obsolete: true
Attachment #142063 -
Flags: review?(danm-moz)
Comment 12•21 years ago
|
||
> - make it so that the alt, control and shift states are given as parameters to
> DispatchKeyEvent to avoid messing around with the member variables
Isn't this going to be confusing?
Comment 13•21 years ago
|
||
In fact, every time except once you're passing in the member variables. Can't
you continue to use the member variables only, and move your isAltDown and
isControlDown determination into an NS_KEY_PRESS section in DispatchKeyEvent?
Assignee | ||
Comment 14•21 years ago
|
||
>> - make it so that the alt, control and shift states are given as parameters to
>> DispatchKeyEvent to avoid messing around with the member variables
>Isn't this going to be confusing?
No, it's much more clear than messing with the members. There are actually two
places where non-members are passed (IME being the other one). I want
DispatchKeyEvent to not mess around with the parameters but just do what it
says. It is called from quite a few places and there are already enough places
where the keycodes and shift states are being handled.
Comment 15•21 years ago
|
||
Then can we get rid of the member variables entirely?
Assignee | ||
Comment 16•21 years ago
|
||
A revised patch. I've changed the logic of deciding when to synthesize the
keypress event. Now it's done by peeking the message queue for WM_CHAR,
WM_SYSCHAR or WM_DEADCHAR.
Assignee | ||
Comment 17•21 years ago
|
||
Same patch with -w.
Assignee | ||
Comment 18•21 years ago
|
||
Dean: interesting idea. The only thing worrying me would be the IME code and
whether the state read there would be reliable and not causing any trouble. I've
tried to stay away from that because I don't have too much experience in IME.
Assignee | ||
Updated•21 years ago
|
Attachment #142265 -
Flags: review?(danm-moz)
Comment 19•21 years ago
|
||
Oh right, I keep forgetting about the IME code. We definitely wouldn't want to
touch that! Those are booleans defined in nsBaseWidget.h. Too bad they weren't
functions, then we could use them inside nsWindow.cpp and expose them to the
outside as well. They could just check the current keyboard state for each key.
Comment 20•21 years ago
|
||
That OnChar processing looks very ugly, it appears to be passing the same
parameter not once, not twice, but three times!
I don't suppose that in the VK_RETURN/VK_BACK case you can remove the WM_CHAR?
I would prefer to stick with the member variables myself.
CC'ing some guys who might know about IME...
Assignee | ||
Comment 21•21 years ago
|
||
Comment on attachment 142265 [details] [diff] [review]
Patch v2
Bah, now I have to clean up OnChar too.
Attachment #142265 -
Attachment is obsolete: true
Attachment #142265 -
Flags: review?(danm-moz)
Assignee | ||
Updated•21 years ago
|
Attachment #142266 -
Attachment is obsolete: true
Assignee | ||
Comment 22•21 years ago
|
||
Third shot: cleaned up OnChar and its parameters and moved all the
enter/backspace special handling into OnKeyDown (it will remove the char
message from the queue so the WM_(SYS)CHAR handler doesn't need to do any
tricks).
Assignee | ||
Comment 23•21 years ago
|
||
Same patch with -w
Comment 24•21 years ago
|
||
Comment on attachment 142368 [details] [diff] [review]
Patch v3 with no whitespace diff
Does Ctrl+Enter still work properly with this change? (bug 50255)
Assignee | ||
Comment 25•21 years ago
|
||
Yes, it works.
Assignee | ||
Comment 26•21 years ago
|
||
Comment on attachment 142367 [details] [diff] [review]
Patch v3
Embarrassing bug in PeekMessage bits..
Attachment #142367 -
Attachment is obsolete: true
Assignee | ||
Comment 27•21 years ago
|
||
Fixed the mistake with PeekMessage calls' parameters and restructured lines
around them a bit. Thanks to Neil for spotting these.
Attachment #142368 -
Attachment is obsolete: true
Assignee | ||
Comment 28•21 years ago
|
||
Again, the same with diff -w.
Assignee | ||
Updated•21 years ago
|
Attachment #142372 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 29•21 years ago
|
||
Comment on attachment 142372 [details] [diff] [review]
Patch v4
>- if (!isMultiByte) {
>- if (mLeadByte) { // mLeadByte is used for keeping the lead-byte of CJK char
>+ if (charCode > 0xFF) { // multibyte character
>+ if (mLeadByte) { // mLeadByte is used for keeping the lead-byte of CJK char
isMultiByte used to be (wParam > 0xff) so I doubt replacing !isMultiByte with
charCode > 0xFF is going to be of much use...
Nit: try to remove trailing whitespace on modified lines.
Assignee | ||
Comment 30•21 years ago
|
||
Yep, thanks for catching that. This patch fixes the evaluation and removes some
trailing spaces.
Attachment #142372 -
Attachment is obsolete: true
Attachment #142373 -
Attachment is obsolete: true
Assignee | ||
Updated•21 years ago
|
Attachment #142372 -
Flags: review?(neil.parkwaycc.co.uk)
Assignee | ||
Comment 31•21 years ago
|
||
Same with diff -w
Assignee | ||
Updated•21 years ago
|
Attachment #142382 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 32•21 years ago
|
||
You might want to replace the hack to translate the virtual key into an ascii
code in OnKeyDown as well. It seems to me that this code is equivalent to
something like this:
UINT asciiKey = MapVirtualKey(virtualKeyCode, 2) & 0xFF; // remove the top bit
(set for dead keys)
if (asciiKey)
...
Comment 33•21 years ago
|
||
Sorry, the bit mask 0x7FFF would be probably more appropriate (though
MapVirtualKeyEx() doesn't seem to return a multibyte value on any occasion). The
bit set for dead keys is 0x8000 on Win98 and 0x80000000 on WinXP, this mask will
remove both. The correct form should be then:
UINT asciiKey = MapVirtualKeyEx(virtualKeyCode, 2, gKeyboardLayout) & 0x7FFF;
I checked it with the German and Russian keyboard layout on both Win98 and WinXP
and it seems to work fine.
Comment 34•21 years ago
|
||
OK, I think I found a possible issue - Ctrl+Alt+T gives me "T", Ctrl, Alt which
while better than nothing (i.e what we currently get!) on linux it gives me "t",
Ctrl, Alt; "T", Ctrl, Alt, Shift is the same on both platforms of course.
I still don't like the business about the extra parameters...
Other than that, this is great work, it should clear up several bugs :-)
Assignee | ||
Comment 35•21 years ago
|
||
Comment on attachment 142382 [details] [diff] [review]
Patch v5
Ok, I'll remove the parameters and go back to messing around with the members.
I'll also look into the other problems.
Attachment #142382 -
Attachment is obsolete: true
Attachment #142382 -
Flags: review?(neil.parkwaycc.co.uk)
Assignee | ||
Comment 36•21 years ago
|
||
MapVirtualKeyEx sucks for Moz in many ways. One of them is that NS_VK_RETURN is
converted to char code 13, which doesn't work. I won't try to guess how many
similar problems it would cause.
Assignee | ||
Comment 37•21 years ago
|
||
Removed the extra parameters to DispatchKeyEvent due to overwhelming pressure
:) Also fixed ctrl-alt-lower case letters.
Assignee | ||
Comment 38•21 years ago
|
||
Again the same with diff -w.
Assignee | ||
Updated•21 years ago
|
Attachment #142383 -
Attachment is obsolete: true
Assignee | ||
Updated•21 years ago
|
Attachment #142449 -
Flags: review?(neil.parkwaycc.co.uk)
Assignee | ||
Comment 39•21 years ago
|
||
Removed an accidentally left MapVirtualKeyEx and change the code to the way it
was before. Also removed an unnecessary block from WM_KEYDOWN case.
Attachment #142449 -
Attachment is obsolete: true
Attachment #142450 -
Attachment is obsolete: true
Assignee | ||
Comment 40•21 years ago
|
||
Same with diff -w
Assignee | ||
Updated•21 years ago
|
Attachment #142449 -
Flags: review?(neil.parkwaycc.co.uk)
Assignee | ||
Updated•21 years ago
|
Attachment #142468 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 41•21 years ago
|
||
Comment on attachment 142468 [details] [diff] [review]
Patch v7
>+ if (PeekMessage(&msg, mWnd, 0, 0, PM_NOREMOVE | PM_NOYIELD) &&
>+ (msg.message == WM_CHAR || msg.message == WM_SYSCHAR)) {
It's probably no use to put in WM_KEYFIRST, WMKEYLAST instead of 0,0 right?
This is funky code. Nice.
Comment 42•21 years ago
|
||
Comment on attachment 142468 [details] [diff] [review]
Patch v7
>+ asciiKey = virtualKeyCode;
>+ // Take the Shift state into account
>+ if (!mIsShiftDown && NS_VK_A <= virtualKeyCode && virtualKeyCode <= NS_VK_Z)
>+ asciiKey += 0x20;
Nit: remove trailing spaces... anyway, try this (or some variant thereof):
asciiKey = virtualKeyode;
if (!mIsShiftDown)
asciiKey |= 0x20;
>+ PRBool saveIsAltDown = mIsAltDown;
>+ PRBool saveIsControlDown = mIsControlDown;
I didn't trawl through the code to see if this is necessary so I'll take your
word for it.
>+ mIsAltDown = saveIsAltDown;
>+ mIsControlDown = saveIsControlDown;
It looks as if this patch doesn't quite solve the original problem - there
appears to be a bug in the menu code such that ctrl+alt+shift+t opens the tools
menu :-(
Attachment #142468 -
Flags: review?(neil.parkwaycc.co.uk) → review+
Assignee | ||
Comment 43•21 years ago
|
||
> It's probably no use to put in WM_KEYFIRST, WMKEYLAST instead of 0,0 right?
I decided it's better not as it would cause trouble in the unlikely event there
was another WM_CHAR somewhere down the queue.
> asciiKey |= 0x20;
Done and trailing spaces removed.
> It looks as if this patch doesn't quite solve the original problem - there
> appears to be a bug in the menu code such that ctrl+alt+shift+t opens the
> tools menu :-(
I noticed that too, but it doesn't prevent the page from getting the key press
before the menu is shown. I think it's worth another bug anyway.
Assignee | ||
Updated•21 years ago
|
Attachment #142468 -
Flags: superreview?(bzbarsky)
Comment 44•21 years ago
|
||
comment 20:
I tested patch v7.
Alt + kanji and some IME functions with alt or ctrl work well.
(I don't know that this patch causes no problem for IME...)
![]() |
||
Comment 45•21 years ago
|
||
It'll take me a few days to get to this.... this code is way outside what I know
about.
Assignee | ||
Updated•21 years ago
|
Attachment #142468 -
Flags: superreview?(bzbarsky) → superreview?(bryner)
Comment 46•21 years ago
|
||
Comment on attachment 142468 [details] [diff] [review]
Patch v7
Dan, I'm delegating sr= to you on this one :)
If you don't want it, bounce it back to me.
Attachment #142468 -
Flags: superreview?(bryner) → superreview?(danm-moz)
Comment 47•21 years ago
|
||
Comment on attachment 142468 [details] [diff] [review]
Patch v7
Sorry. I don't know this part of the widget code, and I'm not going to have
time to do the patch any justice.
Attachment #142468 -
Flags: superreview?(danm-moz) → superreview?(bryner)
Assignee | ||
Comment 48•21 years ago
|
||
Brian, any estimate on when you can sr this?
Assignee | ||
Comment 49•21 years ago
|
||
Cc'ing bryner for a comment...
Comment 50•21 years ago
|
||
Comment on attachment 142468 [details] [diff] [review]
Patch v7
Would it be better to factor the PeekMessage call out, something like:
MSG msg;
BOOL gotMsg = ::PeekMessage(&msg, mWnd, 0, 0, PM_NOREMOVE | PM_NOYIELD);
if (virtualKeyCode == NS_VK_RETURN || virtualKeyCode == NS_VK_BACK) {
if (gotMsg && (msg.message == WM_CHAR || msg.message == WM_SYSCHAR)) {
::GetMessage(&msg, mWnd, 0, 0);
}
} else if (gotMsg &&
msg.message == WM_CHAR || msg.message == WM_SYSCHAR || msg.message
== WM_DEADCHAR) {
return result;
}
The rest of the patch looks ok but I'm going to run it through a few tests
before marking sr+.
Comment 51•21 years ago
|
||
Comment on attachment 142468 [details] [diff] [review]
Patch v7
While I did find some alarming inconsistencies between platforms wrt key
events, this patch seems to do nothing but make things better. sr=me.
Attachment #142468 -
Flags: superreview?(bryner) → superreview+
Assignee | ||
Comment 52•21 years ago
|
||
Fix checked in with the second PeekMessage factored out as Brian suggested.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment 53•21 years ago
|
||
This is the most likely cause of the regression for Ctrl++ and Ctrl+- zooming
under Windows in bug 244334. It fits the regression window.
Comment 54•21 years ago
|
||
Is this bug checked in 1.7 branch or trunk only?
If this bug is checked in 1.7 branch,
bug 194559 should be fixed on 1.7 branch too.
Assignee | ||
Comment 55•21 years ago
|
||
This is trunk only.
Comment 56•21 years ago
|
||
Ere:
Thank you for reply.
However, Bug 194559 is major bug for Japanese people.
If this bug is low risk, I hope that this bug and Bug 194559 are fixed
on 1.7 branch...
Assignee | ||
Comment 57•21 years ago
|
||
Unfortunately this isn't a low risk fix and it has caused some regressions.
There is still one open, bug 244334. I'm not sure if after fixing that it would
be possible to merge it to the branch.
Comment 58•21 years ago
|
||
Thank you, Ere.
Bug 194559 is major bug for Japanese people,
but the bug have no value of risking.
Comment 59•21 years ago
|
||
*** Bug 208302 has been marked as a duplicate of this bug. ***
Updated•16 years ago
|
Product: Core → Core Graveyard
Updated•1 year ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•