Changeset 353 for trunk/src/gui/kernel


Ignore:
Timestamp:
Nov 27, 2009, 1:20:02 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui/kernel: Completely steal the Alt key and other default shortcuts (Alt+F7, Alt+F10 etc) from the system-wide frame accelerator table so that they can be normally processed by Qt applications. The only ones remaining for the system are are Alt+F4, Ctrl+Esc, Alt+Esc.

Location:
trunk/src/gui/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r317 r353  
    842842        } else {
    843843            switch(msg) {
     844
     845            case WM_TRANSLATEACCEL: {
     846                if (widget->isWindow()) {
     847                    rc = WinDefWindowProc(hwnd, msg, mp1, mp2);
     848                    if (rc) {
     849                        QMSG &qmsg = *(QMSG*)mp1;
     850                        if (qmsg.msg == WM_SYSCOMMAND &&
     851                            WinWindowFromID(widget->internalFrameWinId(),
     852                                            FID_SYSMENU)) {
     853                            switch (SHORT1FROMMP(qmsg.mp1)) {
     854                                case SC_CLOSE:
     855                                case SC_TASKMANAGER:
     856                                    return (MRESULT)TRUE;
     857                                default:
     858                                    break;
     859                            }
     860                        }
     861                    }
     862                }
     863                // return FALSE in all other cases to let Qt process keystrokes
     864                // that are in the system-wide frame accelerator table.
     865                return FALSE;
     866            }
    844867
    845868            case WM_CHAR: { // keyboard event
  • trunk/src/gui/kernel/qkeymapper_pm.cpp

    r180 r353  
    375375        KeyRecord *rec = key_recorder.findKey(chm.scancode, false);
    376376
     377        if (state == Qt::AltModifier) {
     378            // Special handling of global PM hotkeys
     379            switch (code) {
     380                case Qt::Key_Space: {
     381                    // show system menu
     382                    HWND fId = widget->window()->internalFrameWinId();
     383                    HWND sysMenu = WinWindowFromID(fId, FID_SYSMENU);
     384                    if (!sysMenu)
     385                        break; // no menu for this window
     386                    WinPostMsg(sysMenu, MM_STARTMENUMODE,
     387                               MPFROM2SHORT(TRUE, FALSE), 0);
     388                    return true;
     389                }
     390                case Qt::Key_F4: {
     391                    // we handle this key combination ourselves because not
     392                    // all top-level widgets have the system menu
     393                    WinPostMsg(widget->window()->internalFrameWinId(),
     394                               WM_CLOSE, 0, 0);
     395                    return true;
     396                }
     397                default:
     398                    break;
     399            }
     400        }
     401
    377402        // If rec's state doesn't match the current state, something has changed behind our back
    378403        // (Consumed by modal widget is one possibility) So, remove the record from the list
Note: See TracChangeset for help on using the changeset viewer.