Qt 4.8
Classes | Macros | Enumerations | Functions | Variables
qkeymapper_win.cpp File Reference
#include "qkeymapper_p.h"
#include <qt_windows.h>
#include <qdebug.h>
#include <private/qevent_p.h>
#include <private/qlocale_p.h>
#include <private/qapplication_p.h>
#include <qwidget.h>
#include <qapplication.h>
#include <ctype.h>

Go to the source code of this file.

Classes

struct  KeyboardLayoutItem
 
struct  KeyRecord
 
struct  KeyRecorder
 
class  QETWidget
 

Macros

#define disabled   (MF_BYCOMMAND | MF_GRAYED)
 
#define enabled   (MF_BYCOMMAND | MF_ENABLED)
 
#define LANG_DIVEHI   0x65
 
#define LANG_PASHTO   0x63
 
#define LANG_SYRIAC   0x5a
 
#define MAPVK_VK_TO_CHAR   (2)
 
#define VK_OEM_3   0xC0
 
#define VK_OEM_PLUS   0xBB
 

Enumerations

enum  { scancodeBitmask = 0x1ff }
 

Functions

static int asciiToKeycode (char a, int state)
 
bool GetKeyboardState (unsigned char *kbuffer)
 
static bool isModifierKey (int code)
 
Q_CORE_EXPORT QLocale qt_localeFromLCID (LCID id)
 
static void qt_show_system_menu (QWidget *tlw)
 
Q_GUI_EXPORT int qt_translateKeyCode (int vk)
 
LRESULT QT_WIN_CALLBACK QtWndProc (HWND, UINT, WPARAM, LPARAM)
 
void setKbdState (unsigned char *kbd, bool shift, bool ctrl, bool alt)
 
int ToAscii (UINT vk, int scancode, unsigned char *kbdBuffer, LPWORD unicodeBuffer, int flag)
 
static int toKeyOrUnicode (int vk, int scancode, unsigned char *kbdBuffer, bool *isDeadkey=0)
 
int ToUnicode (UINT vk, int, unsigned char *, LPWSTR unicodeBuffer, int, int)
 
int winceKeyBend (int keyCode)
 

Variables

static KeyRecorder key_recorder
 
static const uint KeyTbl []
 
static const Qt::KeyboardModifiers ModsTbl []
 
static const int QT_MAX_KEY_RECORDINGS = 64
 
bool qt_use_rtl_extensions
 

Macro Definition Documentation

◆ disabled

#define disabled   (MF_BYCOMMAND | MF_GRAYED)

◆ enabled

#define enabled   (MF_BYCOMMAND | MF_ENABLED)

Referenced by QStylePainter::begin(), breakpointDataFromScriptValue(), QDeclarativeCompiledBindingsPrivate::Binding::destroy(), QWindowsStyle::drawComplexControl(), QCommonStyle::drawControl(), QCleanlooksStyle::drawControl(), QGtkStyle::drawControl(), QMacStyle::drawControl(), QStyleHelper::drawDial(), QPlastiqueStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QBBInputContext::eventFilter(), QThreadPrivate::finish(), QGraphicsItemPrivate::get(), QGraphicsItemPrivate::initStyleOption(), QStandardItem::isEnabled(), isHostExcluded(), QApplication::isLeftToRight(), macQueryInternal(), QPlainTextEdit::maximumBlockCount(), QJSDebugService::messageReceived(), operator>>(), QIcon::paint(), proxyFromDictionary(), QClipData::QClipData(), qDBusRealToggleWatch(), qDrawPlainRect(), QOpenKODEScreen::QOpenKODEScreen(), qt_mac_get_accel(), qt_mac_set_modal_state(), qt_show_system_menu(), QGraphicsWidget::rect(), QColor::setAllowX11ColorNames(), QStateMachine::setAnimated(), QImageReader::setAutoDetectImageFormat(), QTextStream::setAutoDetectUnicode(), QWidget::setAutoFillBackground(), QApplication::setAutoSipEnabled(), QFutureSynchronizer< T >::setCancelOnWait(), QJSDebuggerAgent::setCoverageEnabled(), QMainWindowLayout::setDocumentMode(), QTextControl::setDragEnabled(), QScriptBreakpointData::setEnabled(), QDeclarativeCompiledBindingsPrivate::Binding::setEnabled(), QDeclarativeKeysAttached::setEnabled(), QGraphicsItemPrivate::setEnabledHelper(), QGraphicsItem::setFiltersChildEvents(), QGraphicsItem::setHandlesChildEvents(), QGraphicsItemPrivate::setIsMemberOfGroup(), QGLFramebufferObjectFormat::setMipmap(), QDeclarativeEngine::setOutputWarningsToStandardError(), QGraphicsItemPrivate::setParentItemHelper(), QGraphicsScenePrivate::setScenePosItemEnabled(), QGraphicsScene::setSceneRect(), QWSSoundServerPrivate::setSilent(), QUnifiedTimer::setSlowModeEnabled(), QGraphicsScene::setSortCacheEnabled(), QGraphicsScene::setStickyFocus(), QMainWindowLayout::setVerticalTabsEnabled(), QTextControl::setWordSelectionEnabled(), QGraphicsItem::show(), QColor::spec(), QPainter::testRenderHint(), QTextControl::toHtml(), QPicturePaintEngine::updateClipEnabled(), QGraphicsViewPrivate::updateInputMethodSensitivity(), and QWSSoundServerPrivate::~QWSSoundServerPrivate().

◆ LANG_DIVEHI

#define LANG_DIVEHI   0x65

Definition at line 69 of file qkeymapper_win.cpp.

◆ LANG_PASHTO

#define LANG_PASHTO   0x63

Definition at line 63 of file qkeymapper_win.cpp.

◆ LANG_SYRIAC

#define LANG_SYRIAC   0x5a

Definition at line 66 of file qkeymapper_win.cpp.

Referenced by QWinInputContext::QWinInputContext().

◆ MAPVK_VK_TO_CHAR

#define MAPVK_VK_TO_CHAR   (2)

Definition at line 78 of file qkeymapper_win.cpp.

◆ VK_OEM_3

#define VK_OEM_3   0xC0

Definition at line 75 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().

◆ VK_OEM_PLUS

#define VK_OEM_PLUS   0xBB

Definition at line 72 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
scancodeBitmask 

Definition at line 92 of file qkeymapper_win.cpp.

Function Documentation

◆ asciiToKeycode()

static int asciiToKeycode ( char  a,
int  state 
)
inlinestatic

Definition at line 523 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().

524 {
525  if (a >= 'a' && a <= 'z')
526  a = toupper(a);
527  if ((state & Qt::ControlModifier) != 0) {
528  if (a >= 0 && a <= 31) // Ctrl+@..Ctrl+A..CTRL+Z..Ctrl+_
529  a += '@'; // to @..A..Z.._
530  }
531  return a & 0xff;
532 }
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ GetKeyboardState()

bool GetKeyboardState ( unsigned char *  kbuffer)

Definition at line 82 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey(), and setKbdState().

83 {
84  for (int i=0; i< 256; ++i)
85  kbuffer[i] = GetAsyncKeyState(i);
86  return true;
87 }

◆ isModifierKey()

static bool isModifierKey ( int  code)
inlinestatic

Definition at line 534 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().

535 {
536  return (code >= Qt::Key_Shift) && (code <= Qt::Key_ScrollLock);
537 }

◆ qt_localeFromLCID()

Q_CORE_EXPORT QLocale qt_localeFromLCID ( LCID  id)

Definition at line 985 of file qlocale_win.cpp.

986 {
988 }
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static QByteArray getWinLocaleName(LCID id=LOCALE_USER_DEFAULT)

◆ qt_show_system_menu()

static void qt_show_system_menu ( QWidget tlw)
static

Definition at line 541 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().

542 {
544  HMENU menu = GetSystemMenu(tlw->internalWinId(), FALSE);
545  if (!menu)
546  return; // no menu for this window
547 
548 #define enabled (MF_BYCOMMAND | MF_ENABLED)
549 #define disabled (MF_BYCOMMAND | MF_GRAYED)
550 
551 #ifndef Q_OS_WINCE
552  EnableMenuItem(menu, SC_MINIMIZE, (tlw->windowFlags() & Qt::WindowMinimizeButtonHint)?enabled:disabled);
553  bool maximized = IsZoomed(tlw->internalWinId());
554 
555  EnableMenuItem(menu, SC_MAXIMIZE, ! (tlw->windowFlags() & Qt::WindowMaximizeButtonHint) || maximized?disabled:enabled);
556  EnableMenuItem(menu, SC_RESTORE, maximized?enabled:disabled);
557 
558  // We should _not_ check with the setFixedSize(x,y) case here, since Windows is not able to check
559  // this and our menu here would be out-of-sync with the menu produced by mouse-click on the
560  // System Menu, or right-click on the title bar.
561  EnableMenuItem(menu, SC_SIZE, (tlw->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) || maximized?disabled:enabled);
562  EnableMenuItem(menu, SC_MOVE, maximized?disabled:enabled);
563  EnableMenuItem(menu, SC_CLOSE, enabled);
564  // Set bold on close menu item
565  MENUITEMINFO closeItem;
566  closeItem.cbSize = sizeof(MENUITEMINFO);
567  closeItem.fMask = MIIM_STATE;
568  closeItem.fState = MFS_DEFAULT;
569  SetMenuItemInfo(menu, SC_CLOSE, FALSE, &closeItem);
570 #endif
571 
572 #undef enabled
573 #undef disabled
574  int ret = TrackPopupMenuEx(menu,
575  TPM_LEFTALIGN | TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD,
576  tlw->geometry().x(), tlw->geometry().y(),
577  tlw->internalWinId(),
578  0);
579  if (ret)
580  QtWndProc(tlw->internalWinId(), WM_SYSCOMMAND, ret, 0);
581 }
#define disabled
LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
#define enabled

◆ qt_translateKeyCode()

Q_GUI_EXPORT int qt_translateKeyCode ( int  vk)

Definition at line 517 of file qkeymapper_win.cpp.

Referenced by QAxServerBase::ReactivateAndUndo(), and QAxServerBase::TranslateAcceleratorW().

518 {
519  int code = winceKeyBend((vk < 0 || vk > 255) ? 0 : vk);
520  return code == Qt::Key_unknown ? 0 : code;
521 }
int winceKeyBend(int keyCode)

◆ QtWndProc()

LRESULT QT_WIN_CALLBACK QtWndProc ( HWND  ,
UINT  ,
WPARAM  ,
LPARAM   
)

Definition at line 1475 of file qapplication_win.cpp.

Referenced by qt_show_system_menu().

1476 {
1477  bool result = true;
1478  QEvent::Type evt_type = QEvent::None;
1479  QETWidget *widget = 0;
1480 
1481  // there is no need to process pakcets from tablet unless
1482  // it is actually on the tablet, a flag to let us know...
1483  int nPackets; // the number of packets we get from the queue
1484 
1485  long res = 0;
1486  if (!qApp) // unstable app state
1487 #ifndef QT_NO_IM
1488  RETURN(QWinInputContext::DefWindowProc(hwnd,message,wParam,lParam))
1489 #else
1490  return res;
1491 #endif // QT_NO_IM
1492  QScopedLoopLevelCounter loopLevelCounter(QThreadData::get2(qApp->thread()));
1493 
1494 #if 0
1495  // make sure we update widgets also when the user resizes
1496  if (inLoop && qApp->loopLevel())
1497  qApp->sendPostedEvents(0, QEvent::Paint);
1498 #endif
1499 
1500  inLoop = true;
1501 
1502  MSG msg;
1503  msg.hwnd = hwnd; // create MSG structure
1504  msg.message = message; // time and pt fields ignored
1505  msg.wParam = wParam;
1506  msg.lParam = lParam;
1507  msg.pt.x = GET_X_LPARAM(lParam);
1508  msg.pt.y = GET_Y_LPARAM(lParam);
1509  // If it's a non-client-area message the coords are screen coords, otherwise they are
1510  // client coords.
1511 #ifndef Q_WS_WINCE
1512  if (message < WM_NCMOUSEMOVE || message > WM_NCMBUTTONDBLCLK)
1513 #endif
1514  ClientToScreen(msg.hwnd, &msg.pt);
1515 
1516  /*
1517  // sometimes the autograb is not released, so the clickevent is sent
1518  // to the wrong window. We ignore this for now, because it doesn't
1519  // cause any problems.
1520  if (msg.message == WM_LBUTTONDOWN || msg.message == WM_RBUTTONDOWN || msg.message == WM_MBUTTONDOWN) {
1521  HWND handle = WindowFromPoint(msg.pt);
1522  if (msg.hwnd != handle) {
1523  msg.hwnd = handle;
1524  hwnd = handle;
1525  }
1526  }
1527  */
1528 
1529 #if defined(QT_NON_COMMERCIAL)
1530  QT_NC_WNDPROC
1531 #endif
1532 
1533  // send through app filter
1534  if (qApp->filterEvent(&msg, &res))
1535  return res;
1536 
1537  // close any opened ime candidate window (enabled only on a popup widget)
1539  && (message == WM_MBUTTONDOWN || message == WM_XBUTTONDOWN
1540  || message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN
1541 #ifndef Q_WS_WINCE
1542  || message == WM_NCMBUTTONDOWN || message == WM_NCLBUTTONDOWN
1543  || message == WM_NCRBUTTONDOWN)) {
1544 #else
1545  )) {
1546 #endif
1547  ::SendMessage(imeParentWnd, WM_IME_ENDCOMPOSITION, 0, 0);
1548  }
1549 
1550  switch (message) {
1551 #ifndef Q_WS_WINCE
1552 #ifndef QT_NO_SESSIONMANAGER
1553  case WM_QUERYENDSESSION: {
1554  if (sm_smActive) // bogus message from windows
1555  RETURN(true);
1556 
1557  sm_smActive = true;
1558  sm_blockUserInput = true; // prevent user-interaction outside interaction windows
1559  sm_cancel = false;
1561  qApp->commitData(*qt_session_manager_self);
1562  if (lParam & ENDSESSION_LOGOFF) {
1563  _flushall();
1564  }
1565  RETURN(!sm_cancel);
1566  }
1567  case WM_ENDSESSION: {
1568  sm_smActive = false;
1569  sm_blockUserInput = false;
1570  bool endsession = (bool) wParam;
1571 
1572  // we receive the message for each toplevel window included internal hidden ones,
1573  // but the aboutToQuit signal should be emitted only once.
1575  if (endsession && !qAppPriv->aboutToQuitEmitted) {
1576  qAppPriv->aboutToQuitEmitted = true;
1577  int index = QApplication::staticMetaObject.indexOfSignal("aboutToQuit()");
1578  qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0);
1579  // since the process will be killed immediately quit() has no real effect
1581  }
1582 
1583  RETURN(0);
1584  }
1585 #endif
1586  case WM_DISPLAYCHANGE:
1588  break;
1589  if (qt_desktopWidget) {
1590  qt_desktopWidget->move(GetSystemMetrics(76), GetSystemMetrics(77));
1591  QSize sz(GetSystemMetrics(78), GetSystemMetrics(79));
1592  if (sz == qt_desktopWidget->size()) {
1593  // a screen resized without changing size of the virtual desktop
1594  QResizeEvent rs(sz, qt_desktopWidget->size());
1596  } else {
1597  qt_desktopWidget->resize(sz);
1598  }
1599  }
1600  break;
1601 #endif
1602 
1603  case WM_SETTINGCHANGE:
1604 #ifdef Q_WS_WINCE
1605  // CE SIP hide/show
1606  if (qt_desktopWidget && wParam == SPI_SETSIPINFO) {
1607  QResizeEvent re(QSize(0, 0), QSize(0, 0)); // Calculated by QDesktopWidget
1609  break;
1610  }
1611 #endif
1612  // ignore spurious XP message when user logs in again after locking
1614  break;
1615  if (QApplication::desktopSettingsAware() && wParam != SPI_SETWORKAREA) {
1616  widget = (QETWidget*)QWidget::find(hwnd);
1617  if (widget) {
1618  if (wParam == SPI_SETNONCLIENTMETRICS)
1619  widget->markFrameStrutDirty();
1620  }
1621  }
1622  else if (qt_desktopWidget && wParam == SPI_SETWORKAREA) {
1623  qt_desktopWidget->move(GetSystemMetrics(76), GetSystemMetrics(77));
1624  QSize sz(GetSystemMetrics(78), GetSystemMetrics(79));
1625  if (sz == qt_desktopWidget->size()) {
1626  // a screen resized without changing size of the virtual desktop
1627  QResizeEvent rs(sz, qt_desktopWidget->size());
1629  } else {
1630  qt_desktopWidget->resize(sz);
1631  }
1632  }
1633 
1634  if (wParam == SPI_SETFONTSMOOTHINGTYPE) {
1636  foreach (QWidget *w, QApplication::topLevelWidgets()) {
1637  if (!w->isVisible())
1638  continue;
1639  ((QETWidget *) w)->forceUpdate();
1640  }
1641  }
1642 
1643  break;
1644  case WM_SYSCOLORCHANGE:
1646  break;
1648  widget = (QETWidget*)QWidget::find(hwnd);
1649  if (widget && !widget->parentWidget())
1651  }
1652  break;
1653 
1654  case WM_LBUTTONDOWN:
1655  case WM_MBUTTONDOWN:
1656  case WM_RBUTTONDOWN:
1657  case WM_XBUTTONDOWN:
1658  case WM_LBUTTONDBLCLK:
1659  case WM_RBUTTONDBLCLK:
1660  case WM_MBUTTONDBLCLK:
1661  case WM_XBUTTONDBLCLK:
1664  break;
1665 
1666  case WM_LBUTTONUP:
1667  case WM_MBUTTONUP:
1668  case WM_RBUTTONUP:
1669  case WM_XBUTTONUP:
1674  qt_button_down = 0;
1675  }
1676 
1677  RETURN(0);
1678  }
1679  break;
1680 
1681  default:
1682  break;
1683  }
1684 
1685  if (!widget)
1686  widget = (QETWidget*)QWidget::find(hwnd);
1687  if (!widget) // don't know this widget
1688  goto do_default;
1689 
1690  if (app_do_modal) { // modal event handling
1691  int ret = 0;
1692  if (!qt_try_modal(widget, &msg, ret))
1693  RETURN(ret);
1694  }
1695 
1696  res = 0;
1697  if (widget->winEvent(&msg, &res)) // send through widget filter
1698  RETURN(res);
1699 
1700  if (qt_is_translatable_mouse_event(message)) {
1701  if (QApplication::activePopupWidget() != 0) { // in popup mode
1702  POINT curPos = msg.pt;
1703  QWidget* w = QApplication::widgetAt(curPos.x, curPos.y);
1704  if (w)
1705  widget = (QETWidget*)w;
1706  }
1707 
1708  if (!qt_tabletChokeMouse) {
1709  result = widget->translateMouseEvent(msg); // mouse event
1710 #if defined(Q_WS_WINCE) && !defined(QT_NO_CONTEXTMENU)
1711  if (message == WM_LBUTTONDOWN && widget != QApplication::activePopupWidget()) {
1712  QWidget* alienWidget = widget;
1713  if ((alienWidget != QApplication::activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) {
1714  QPoint pos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1715  QPoint globalPos(msg.pt.x, msg.pt.y);
1716  // In case we are using Alien, then the widget to
1717  // send the context menu event is a different one
1718  if (!alienWidget->testAttribute(Qt::WA_NativeWindow) && !alienWidget->testAttribute(Qt::WA_PaintOnScreen)) {
1719  alienWidget = QApplication::widgetAt(globalPos);
1720  if (alienWidget)
1721  pos = alienWidget->mapFromGlobal(globalPos);
1722  }
1723  if (alienWidget) {
1724  SHRGINFO shrg;
1725  shrg.cbSize = sizeof(shrg);
1726  shrg.hwndClient = hwnd;
1727  shrg.ptDown.x = GET_X_LPARAM(lParam);
1728  shrg.ptDown.y = GET_Y_LPARAM(lParam);
1730 #ifndef QT_NO_GESTURES
1731  resolveAygLibs();
1735  QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
1736  result = qt_sendSpontaneousEvent(alienWidget, &e);
1737  }
1738 #endif // QT_NO_GESTURES
1739  }
1740  }
1741  }
1742 #endif
1743  } else {
1744  // Sometimes we only get a WM_MOUSEMOVE message
1745  // and sometimes we get both a WM_MOUSEMOVE and
1746  // a WM_LBUTTONDOWN/UP, this creates a spurious mouse
1747  // press/release event, using the PeekMessage
1748  // will help us fix this. This leaves us with a
1749  // question:
1750  // This effectively kills using the mouse AND the
1751  // tablet simultaneously, well creates wacky input.
1752  // Is this going to be a problem? (probably not)
1753  bool next_is_button = false;
1754  bool is_mouse_move = (message == WM_MOUSEMOVE);
1755  if (is_mouse_move) {
1756  MSG msg1;
1757  if (PeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,
1758  WM_MOUSELAST, PM_NOREMOVE))
1759  next_is_button = (msg1.message == WM_LBUTTONUP
1760  || msg1.message == WM_LBUTTONDOWN);
1761  }
1762  if (!is_mouse_move || (is_mouse_move && !next_is_button))
1763  qt_tabletChokeMouse = false;
1764  }
1765  } else {
1766  switch (message) {
1767  case WM_TOUCH:
1769  break;
1770  case WM_KEYDOWN: // keyboard event
1771  case WM_SYSKEYDOWN:
1773  // fall-through intended
1774  case WM_KEYUP:
1775  case WM_SYSKEYUP:
1776 #if Q_OS_WINCE_WM
1777  case WM_HOTKEY:
1778  if(HIWORD(msg.lParam) == VK_TBACK) {
1779  const bool hotKeyDown = !(LOWORD(msg.lParam) & MOD_KEYUP);
1780  msg.lParam = 0x69 << 16;
1781  msg.wParam = VK_BACK;
1782  if (hotKeyDown) {
1783  msg.message = WM_KEYDOWN;
1785  } else {
1786  msg.message = WM_KEYUP;
1787  }
1788  }
1789  // fall-through intended
1790 #endif
1791  case WM_IME_CHAR:
1792  case WM_IME_KEYDOWN:
1793  case WM_CHAR: {
1794  MSG msg1;
1795  bool anyMsg = PeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);
1796  if (anyMsg && msg1.message == WM_DEADCHAR) {
1797  result = true; // consume event since there is a dead char next
1798  break;
1799  }
1801  if (g && qt_get_tablet_widget() && hwnd == qt_get_tablet_widget()->winId()) {
1802  // if we get an event for the internal tablet widget,
1803  // then don't send it to the keyboard grabber, but
1804  // send it to the widget itself (we don't use it right
1805  // now, just in case).
1806  g = 0;
1807  }
1808  if (g)
1809  widget = (QETWidget*)g;
1814  else if (QApplication::focusWidget())
1815  widget = (QETWidget*)QApplication::focusWidget();
1816  else if (!widget || widget->internalWinId() == GetFocus()) // We faked the message to go to exactly that widget.
1817  widget = (QETWidget*)widget->window();
1818  if (widget->isEnabled())
1819  result = sm_blockUserInput
1820  ? true
1821  : qt_keymapper_private()->translateKeyEvent(widget, msg, g != 0);
1822  break;
1823  }
1824  case WM_SYSCHAR:
1825  result = true; // consume event
1826  break;
1827 
1828  case WM_MOUSEWHEEL:
1829  case WM_MOUSEHWHEEL:
1830  result = widget->translateWheelEvent(msg);
1831  break;
1832 
1833  case WM_APPCOMMAND:
1834  {
1835  uint cmd = GET_APPCOMMAND_LPARAM(lParam);
1836  uint uDevice = GET_DEVICE_LPARAM(lParam);
1837  uint dwKeys = GET_KEYSTATE_LPARAM(lParam);
1838 
1839  int state = translateButtonState(dwKeys, QEvent::KeyPress, 0);
1840 
1841  switch (uDevice) {
1842  case FAPPCOMMAND_KEY:
1843  {
1844  int key = 0;
1845 
1846  switch(cmd) {
1847  case APPCOMMAND_BASS_BOOST:
1848  key = Qt::Key_BassBoost;
1849  break;
1850  case APPCOMMAND_BASS_DOWN:
1851  key = Qt::Key_BassDown;
1852  break;
1853  case APPCOMMAND_BASS_UP:
1854  key = Qt::Key_BassUp;
1855  break;
1857  key = Qt::Key_TrebleDown;
1858  break;
1859  case APPCOMMAND_TREBLE_UP:
1860  key = Qt::Key_TrebleUp;
1861  break;
1862  case APPCOMMAND_HELP:
1863  key = Qt::Key_Help;
1864  break;
1865  case APPCOMMAND_FIND:
1866  key = Qt::Key_Search;
1867  break;
1868  default:
1869  break;
1870  }
1871  if (key) {
1872  bool res = false;
1874  if (g)
1875  widget = (QETWidget*)g;
1876  else if (QApplication::focusWidget())
1877  widget = (QETWidget*)QApplication::focusWidget();
1878  else
1879  widget = (QETWidget*)widget->window();
1880  if (widget->isEnabled()) {
1881  res = QKeyMapper::sendKeyEvent(widget, g != 0, QEvent::KeyPress, key,
1882  Qt::KeyboardModifier(state),
1883  QString(), false, 0, 0, 0, 0);
1884  }
1885  if (res)
1886  return true;
1887  }
1888  }
1889  break;
1890 
1891  default:
1892  break;
1893  }
1894 
1895  result = false;
1896  }
1897  break;
1898 
1899 #ifndef Q_WS_WINCE
1900  case WM_NCHITTEST:
1901  if (widget->isWindow()) {
1902  QPoint pos = widget->mapFromGlobal(QPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
1903  // don't show resize-cursors for fixed-size widgets
1904  QRect fs = widget->frameStrut();
1905  if (!widget->isMinimized()) {
1906  if (widget->minimumHeight() == widget->maximumHeight()) {
1907  if (pos.y() < -(fs.top() - fs.left()))
1908  return HTCAPTION;
1909  if (pos.y() >= widget->height())
1910  return HTBORDER;
1911  }
1912  if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width()))
1913  return HTBORDER;
1914  }
1915  }
1916 
1917  result = false;
1918  break;
1919 #endif
1920 
1921  case WM_SYSCOMMAND: {
1922 #ifndef Q_WS_WINCE
1923  bool window_state_change = false;
1924  Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state);
1925  // MSDN:In WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are
1926  // used internally by the system. To obtain the correct result when testing the value of
1927  // wParam, an application must combine the value 0xFFF0 with the wParam value by using
1928  // the bitwise AND operator.
1929  switch(0xfff0 & wParam) {
1930  case SC_CONTEXTHELP:
1931 #ifndef QT_NO_WHATSTHIS
1933 #endif
1934  DefWindowProc(hwnd, WM_NCPAINT, 1, 0);
1935  break;
1936 #if defined(QT_NON_COMMERCIAL)
1937  QT_NC_SYSCOMMAND
1938 #endif
1939  case SC_MINIMIZE:
1940  window_state_change = true;
1942  if (widget->isVisible()) {
1943  QHideEvent e;
1944  qt_sendSpontaneousEvent(widget, &e);
1945  widget->hideChildren(true);
1946  const QString title = widget->windowIconText();
1947  if (!title.isEmpty())
1948  widget->setWindowTitle_helper(title);
1949  }
1950  result = false;
1951  break;
1952  case SC_MAXIMIZE:
1953  if(widget->isWindow())
1954  widget->topData()->normalGeometry = widget->geometry();
1955  case SC_RESTORE:
1956  window_state_change = true;
1957  if ((0xfff0 & wParam) == SC_MAXIMIZE)
1959  else if (!widget->isMinimized())
1960  widget->dataPtr()->window_state &= ~Qt::WindowMaximized;
1961 
1962  if (widget->isMinimized()) {
1963  widget->dataPtr()->window_state &= ~Qt::WindowMinimized;
1964  widget->showChildren(true);
1965  QShowEvent e;
1966  qt_sendSpontaneousEvent(widget, &e);
1967  const QString title = widget->windowTitle();
1968  if (!title.isEmpty())
1969  widget->setWindowTitle_helper(title);
1970  }
1971  result = false;
1972  break;
1973  default:
1974  result = false;
1975  break;
1976  }
1977 
1978  if (window_state_change) {
1979  QWindowStateChangeEvent e(oldstate);
1980  qt_sendSpontaneousEvent(widget, &e);
1981  }
1982 #endif // #ifndef Q_OS_WINCE
1983 
1984  break;
1985  }
1986 
1987  case WM_SETTINGCHANGE:
1989  break;
1990 
1991  if (!msg.wParam) {
1992 #ifdef Q_WS_WINCE
1993  // On Windows CE, lParam parameter is a constant, not a char pointer.
1994  if (msg.lParam == INI_INTL) {
1995 #else
1996  QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
1997  if (area == QLatin1String("intl")) {
1998 #endif
2000  if (!widget->testAttribute(Qt::WA_SetLocale))
2001  widget->dptr()->setLocale_helper(QLocale(), true);
2004  }
2005  }
2006  else if (msg.wParam == SPI_SETICONTITLELOGFONT) {
2008  widget = (QETWidget*)QWidget::find(hwnd);
2009  if (widget && !widget->parentWidget()) {
2011  }
2012  }
2013  }
2014  else if (msg.wParam == SPI_SETNONCLIENTMETRICS) {
2015  widget = (QETWidget*)QWidget::find(hwnd);
2016  if (widget && !widget->parentWidget()) {
2019  QApplication::sendEvent(widget, &e);
2020  }
2021  }
2022 
2023  break;
2024 
2025  case WM_PAINT: // paint event
2026  case WM_ERASEBKGND: // erase window background
2027  result = widget->translatePaintEvent(msg);
2028  break;
2029 
2030 #ifndef Q_WS_WINCE
2031  case WM_ENTERSIZEMOVE:
2032  autoCaptureWnd = hwnd;
2033  break;
2034  case WM_EXITSIZEMOVE:
2035  autoCaptureWnd = 0;
2036  break;
2037 #endif
2038  case WM_MOVE: // move window
2039  case WM_SIZE: // resize window
2040  result = widget->translateConfigEvent(msg);
2041  break;
2042 
2043  case WM_ACTIVATEAPP:
2044  if (wParam == FALSE) {
2046  // Another application was activated while our popups are open,
2047  // then close all popups. In case some popup refuses to close,
2048  // we give up after 1024 attempts (to avoid an infinite loop).
2049  int maxiter = 1024;
2050  QWidget *popup;
2051  while ((popup=QApplication::activePopupWidget()) && maxiter--)
2052  popup->close();
2053  }
2054  break;
2055 
2056  case WM_ACTIVATE:
2058  break;
2059 
2060  if (ptrWTOverlap && ptrWTEnable) {
2061  // cooperate with other tablet applications, but when
2062  // we get focus, I want to use the tablet...
2063  if (qt_tablet_context && GET_WM_ACTIVATE_STATE(wParam, lParam)) {
2064  if (ptrWTEnable(qt_tablet_context, true))
2066  }
2067  }
2068  if (QApplication::activePopupWidget() && LOWORD(wParam) == WA_INACTIVE &&
2069  QWidget::find((HWND)lParam) == 0) {
2070  // Another application was activated while our popups are open,
2071  // then close all popups. In case some popup refuses to close,
2072  // we give up after 1024 attempts (to avoid an infinite loop).
2073  int maxiter = 1024;
2074  QWidget *popup;
2075  while ((popup=QApplication::activePopupWidget()) && maxiter--)
2076  popup->close();
2077  }
2078 
2079  if (LOWORD(wParam) != WA_INACTIVE) {
2080  // WM_ACTIVATEAPP handles the "true" false case, as this is only when the application
2081  // loses focus. Doing it here would result in the widget getting focus to not know
2082  // where it got it from; it would simply get a 0 value as the old focus widget.
2083 #ifdef Q_WS_WINCE
2084  {
2085 #ifdef Q_WS_WINCE_WM
2086  // On Windows mobile we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages.
2087  // Thus we have to unset the minimized state explicitly. We must do this for all
2088  // top-level widgets, because we get the HWND of a random widget here.
2089  foreach (QWidget* tlw, QApplication::topLevelWidgets()) {
2090  if (tlw->isMinimized())
2092  }
2093 #else
2094  // On Windows CE we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages.
2095  // Thus we have to unset the minimized state explicitly.
2096  if (widget->windowState() & Qt::WindowMinimized)
2097  widget->setWindowState(widget->windowState() & ~Qt::WindowMinimized);
2098 #endif // Q_WS_WINCE_WM
2099 
2100 #else
2101  if (!(widget->windowState() & Qt::WindowMinimized)) {
2102 #endif
2103  // Ignore the activate message send by WindowsXP to a minimized window
2104 #ifdef Q_WS_WINCE_WM
2105  if (widget->windowState() & Qt::WindowFullScreen)
2106  qt_wince_hide_taskbar(widget->winId());
2107 #endif
2108  qApp->winFocus(widget, true);
2109  // reset any window alert flashes
2110  alert_widget(widget, -1);
2111  }
2112  }
2113 
2114  // Windows tries to activate a modally blocked window.
2115  // This happens when restoring an application after "Show Desktop"
2116  if (app_do_modal && LOWORD(wParam) == WA_ACTIVE) {
2117  QWidget *top = 0;
2118  if (!QApplicationPrivate::tryModalHelper(widget, &top) && top && widget != top) {
2119  if (top->isVisible()) {
2120  top->activateWindow();
2121  } else {
2122  // This is the case when native file dialogs are shown
2123  QWidget *p = (top->parentWidget() ? top->parentWidget()->window() : 0);
2124  if (p && p->isVisible())
2125  p->activateWindow();
2126  }
2127  }
2128  }
2129  break;
2130 
2131 #ifndef Q_WS_WINCE
2132  case WM_MOUSEACTIVATE:
2133  if (widget->window()->windowType() == Qt::Tool) {
2134  QWidget *w = widget;
2135  if (!w->window()->focusWidget()) {
2136  while (w && (w->focusPolicy() & Qt::ClickFocus) == 0) {
2137  if (w->isWindow()) {
2138  QWidget *fw = w;
2139  while ((fw = fw->nextInFocusChain()) != w && fw->focusPolicy() == Qt::NoFocus)
2140  ;
2141  if (fw != w)
2142  break;
2143  QWidget *pw = w->parentWidget();
2144  while (pw) {
2145  pw = pw->window();
2146  if (pw && pw->isVisible() && pw->focusWidget()) {
2148  SetWindowPos(pw->internalWinId(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
2149  break;
2150  }
2151  pw = pw->parentWidget();
2152  }
2153  RETURN(MA_NOACTIVATE);
2154  }
2155  w = w->parentWidget();
2156  }
2157  }
2158  }
2159  RETURN(MA_ACTIVATE);
2160  break;
2161 #endif
2162  case WM_SHOWWINDOW:
2163  if (lParam == SW_PARENTOPENING) {
2164  if (widget->testAttribute(Qt::WA_WState_Hidden))
2165  RETURN(0);
2166  }
2167  if (widget->isWindow() && widget->testAttribute(Qt::WA_WState_Visible)
2168  && !widget->testWindowState(Qt::WindowMinimized)) {
2169  if (lParam == SW_PARENTOPENING) {
2170  QShowEvent e;
2171  qt_sendSpontaneousEvent(widget, &e);
2172  widget->showChildren(true);
2173  } else if (lParam == SW_PARENTCLOSING) {
2174  QHideEvent e;
2175  qt_sendSpontaneousEvent(widget, &e);
2176  widget->hideChildren(true);
2177  }
2178  }
2179  if (!wParam && autoCaptureWnd == widget->internalWinId())
2181  result = false;
2182  break;
2183 
2184  case WM_PALETTECHANGED: // our window changed palette
2185  if (QColormap::hPal() && (WId)wParam == widget->internalWinId())
2186  RETURN(0); // otherwise: FALL THROUGH!
2187  // FALL THROUGH
2188  case WM_QUERYNEWPALETTE: // realize own palette
2189  if (QColormap::hPal()) {
2191  HDC hdc = GetDC(widget->internalWinId());
2192  HPALETTE hpalOld = SelectPalette(hdc, QColormap::hPal(), FALSE);
2193  uint n = RealizePalette(hdc);
2194  if (n)
2195  InvalidateRect(widget->internalWinId(), 0, TRUE);
2196  SelectPalette(hdc, hpalOld, TRUE);
2197  RealizePalette(hdc);
2198  ReleaseDC(widget->internalWinId(), hdc);
2199  RETURN(n);
2200  }
2201  break;
2202  case WM_CLOSE: // close window
2203  widget->translateCloseEvent(msg);
2204  RETURN(0); // always handled
2205 
2206  case WM_DESTROY: // destroy window
2207  if (hwnd == curWin) {
2208  QWidget *enter = QWidget::mouseGrabber();
2209  if (enter == widget)
2210  enter = 0;
2212  curWin = enter ? enter->effectiveWinId() : 0;
2213  qt_last_mouse_receiver = enter;
2214  }
2215  if (widget == popupButtonFocus)
2216  popupButtonFocus = 0;
2217  result = false;
2218  break;
2219 
2220 #ifndef Q_WS_WINCE
2221  case WM_WINDOWPOSCHANGING:
2222  {
2223  result = false;
2224  if (widget->isWindow()) {
2225  WINDOWPOS *winPos = (WINDOWPOS *)lParam;
2226  if (widget->layout() && widget->layout()->hasHeightForWidth()
2227  && !(winPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE))) {
2228  QRect fs = widget->frameStrut();
2229  QRect rect = widget->geometry();
2230  QRect newRect = QRect(winPos->x + fs.left(),
2231  winPos->y + fs.top(),
2232  winPos->cx - fs.left() - fs.right(),
2233  winPos->cy - fs.top() - fs.bottom());
2234 
2235  QSize newSize = QLayout::closestAcceptableSize(widget, newRect.size());
2236 
2237  int dh = newSize.height() - newRect.height();
2238  int dw = newSize.width() - newRect.width();
2239  if (!dw && ! dh)
2240  break; // Size OK
2241 
2242  if (rect.y() != newRect.y()) {
2243  newRect.setTop(newRect.top() - dh);
2244  } else {
2245  newRect.setBottom(newRect.bottom() + dh);
2246  }
2247 
2248  if (rect.x() != newRect.x()) {
2249  newRect.setLeft(newRect.left() - dw);
2250  } else {
2251  newRect.setRight(newRect.right() + dw);
2252  }
2253 
2254  winPos->x = newRect.x() - fs.left();
2255  winPos->y = newRect.y() - fs.top();
2256  winPos->cx = newRect.width() + fs.left() + fs.right();
2257  winPos->cy = newRect.height() + fs.top() + fs.bottom();
2258 
2259  RETURN(0);
2260  }
2261  if (widget->windowFlags() & Qt::WindowStaysOnBottomHint) {
2262  winPos->hwndInsertAfter = HWND_BOTTOM;
2263  }
2264  }
2265  }
2266  break;
2267 
2268  case WM_GETMINMAXINFO:
2269  if (widget->xtra()) {
2270  MINMAXINFO *mmi = (MINMAXINFO *)lParam;
2271  QWExtra *x = widget->xtra();
2272  QRect fs = widget->frameStrut();
2273  if ( x->minw > 0 )
2274  mmi->ptMinTrackSize.x = x->minw + fs.right() + fs.left();
2275  if ( x->minh > 0 )
2276  mmi->ptMinTrackSize.y = x->minh + fs.top() + fs.bottom();
2277  qint32 maxw = (x->maxw >= x->minw) ? x->maxw : x->minw;
2278  qint32 maxh = (x->maxh >= x->minh) ? x->maxh : x->minh;
2279  if ( maxw < QWIDGETSIZE_MAX ) {
2280  mmi->ptMaxTrackSize.x = maxw + fs.right() + fs.left();
2281  // windows with title bar have an implicit size limit of 112 pixels
2282  if (widget->windowFlags() & Qt::WindowTitleHint)
2283  mmi->ptMaxTrackSize.x = qMax<long>(mmi->ptMaxTrackSize.x, 112);
2284  }
2285  if ( maxh < QWIDGETSIZE_MAX )
2286  mmi->ptMaxTrackSize.y = maxh + fs.top() + fs.bottom();
2287  RETURN(0);
2288  }
2289  break;
2290 
2291 #ifndef QT_NO_CONTEXTMENU
2292  case WM_CONTEXTMENU:
2293  {
2294  // it's not VK_APPS or Shift+F10, but a click in the NC area
2295  if (lParam != (int)0xffffffff) {
2296  result = false;
2297  break;
2298  }
2299 
2301  if (!fw) {
2306  else if (QApplication::focusWidget())
2308  else if (widget)
2309  fw = widget->window();
2310  }
2311  if (fw && fw->isEnabled()) {
2315  result = qt_sendSpontaneousEvent(fw, &e);
2316  }
2317  }
2318  break;
2319 #endif
2320 #endif
2321 
2322 #ifndef QT_NO_IM
2323  case WM_IME_STARTCOMPOSITION:
2324  case WM_IME_ENDCOMPOSITION:
2325  case WM_IME_COMPOSITION: {
2328  if (fw && im) {
2329  if(message == WM_IME_STARTCOMPOSITION)
2330  result = im->startComposition();
2331  else if (message == WM_IME_ENDCOMPOSITION)
2332  result = im->endComposition();
2333  else if (message == WM_IME_COMPOSITION)
2334  result = im->composition(lParam);
2335  }
2336  break;
2337  }
2338  case WM_IME_REQUEST: {
2341  if (fw && im) {
2342  if(wParam == IMR_RECONVERTSTRING) {
2343  int ret = im->reconvertString((RECONVERTSTRING *)lParam);
2344  if (ret == -1) {
2345  result = false;
2346  } else {
2347  return ret;
2348  }
2349  } else if (wParam == IMR_CONFIRMRECONVERTSTRING) {
2350  RETURN(TRUE);
2351  } else {
2352  // in all other cases, call DefWindowProc()
2353  result = false;
2354  }
2355  }
2356  break;
2357  }
2358 #endif // QT_NO_IM
2359 #ifndef Q_WS_WINCE
2360  case WM_CHANGECBCHAIN:
2361  case WM_DRAWCLIPBOARD:
2362 #endif
2363  case WM_RENDERFORMAT:
2364  case WM_RENDERALLFORMATS:
2365 #ifndef QT_NO_CLIPBOARD
2366  case WM_DESTROYCLIPBOARD:
2367  if (qt_clipboard) {
2368  QClipboardEvent e(reinterpret_cast<QEventPrivate *>(&msg));
2370  RETURN(0);
2371  }
2372  result = false;
2373  break;
2374 #endif //QT_NO_CLIPBOARD
2375 #ifndef QT_NO_ACCESSIBILITY
2376  case WM_GETOBJECT:
2377  {
2378 #if !defined(Q_OS_WINCE)
2379  /* On Win64, lParam can be 0x00000000fffffffc or 0xfffffffffffffffc (!),
2380  but MSDN says that lParam should be converted to a DWORD
2381  before its compared against OBJID_CLIENT
2382  */
2383  const DWORD dwObjId = (DWORD)lParam;
2384  // Ignoring all requests while starting up
2385  if (QApplication::startingUp() || QApplication::closingDown() || dwObjId != OBJID_CLIENT) {
2386  result = false;
2387  break;
2388  }
2389 
2390  typedef LRESULT (WINAPI *PtrLresultFromObject)(REFIID, WPARAM, LPUNKNOWN);
2391  static PtrLresultFromObject ptrLresultFromObject = 0;
2392  static bool oleaccChecked = false;
2393  if (!oleaccChecked) {
2394  QSystemLibrary oleacclib(QLatin1String("oleacc"));
2395  ptrLresultFromObject = (PtrLresultFromObject)oleacclib.resolve("LresultFromObject");
2396  oleaccChecked = true;
2397  }
2398  if (ptrLresultFromObject) {
2400  if (!acc) {
2401  result = false;
2402  break;
2403  }
2404 
2405  // and get an instance of the IAccessibile implementation
2406  IAccessible *iface = qt_createWindowsAccessible(acc);
2407  res = ptrLresultFromObject(IID_IAccessible, wParam, iface); // ref == 2
2408  iface->Release(); // the client will release the object again, and then it will destroy itself
2409 
2410  if (res > 0)
2411  RETURN(res);
2412  }
2413 #endif
2414  }
2415  result = false;
2416  break;
2417  case WM_GETTEXT:
2418  if (!widget->isWindow()) {
2419  int ret = 0;
2421  if (acc) {
2422  QString text = acc->text(QAccessible::Name, 0);
2423  if (text.isEmpty())
2424  text = widget->objectName();
2425  ret = qMin<int>(wParam - 1, text.size());
2426  text.resize(ret);
2427  memcpy((void *)lParam, text.utf16(), (text.size() + 1) * sizeof(ushort));
2428  delete acc;
2429  }
2430  if (!ret) {
2431  result = false;
2432  break;
2433  }
2434  RETURN(ret);
2435  }
2436  result = false;
2437  break;
2438 #endif
2439  case WT_PACKET:
2440  if (ptrWTPacketsGet) {
2442  result = widget->translateTabletEvent(msg, localPacketBuf, nPackets);
2443  }
2444  }
2445  break;
2446  case WT_PROXIMITY:
2447 
2448  #ifndef QT_NO_TABLETEVENT
2449  if (ptrWTPacketsGet && ptrWTInfo) {
2450  const bool enteredProximity = LOWORD(lParam) != 0;
2451  PACKET proximityBuffer[1]; // we are only interested in the first packet in this case
2452  const int totalPacks = ptrWTPacketsGet(qt_tablet_context, 1, proximityBuffer);
2453  if (totalPacks > 0) {
2454  const UINT currentCursor = proximityBuffer[0].pkCursor;
2455 
2456  UINT csr_physid;
2457  ptrWTInfo(WTI_CURSORS + currentCursor, CSR_PHYSID, &csr_physid);
2458  UINT csr_type;
2459  ptrWTInfo(WTI_CURSORS + currentCursor, CSR_TYPE, &csr_type);
2460  const UINT deviceIdMask = 0xFF6; // device type mask && device color mask
2461  quint64 uniqueId = (csr_type & deviceIdMask);
2462  uniqueId = (uniqueId << 32) | csr_physid;
2463 
2464  // initialising and updating the cursor should be done in response to
2465  // WT_CSRCHANGE. We do it in WT_PROXIMITY because some wintab never send
2466  // the event WT_CSRCHANGE even if asked with CXO_CSRMESSAGES
2467  const QTabletCursorInfo *const globalCursorInfo = tCursorInfo();
2468  if (!globalCursorInfo->contains(uniqueId))
2469  tabletInit(uniqueId, csr_type, qt_tablet_context);
2470 
2471  currentTabletPointer = globalCursorInfo->value(uniqueId);
2472  tabletUpdateCursor(currentTabletPointer, currentCursor);
2473  }
2474  qt_tabletChokeMouse = false;
2475 
2476  QTabletEvent tabletProximity(enteredProximity ? QEvent::TabletEnterProximity
2478  QPoint(), QPoint(), QPointF(), currentTabletPointer.currentDevice, currentTabletPointer.currentPointerType, 0, 0,
2479  0, 0, 0, 0, 0, currentTabletPointer.llId);
2480  QApplication::sendEvent(qApp, &tabletProximity);
2481  }
2482  #endif // QT_NO_TABLETEVENT
2483 
2484  break;
2485 #ifdef Q_WS_WINCE_WM
2486  case WM_SETFOCUS: {
2487  HIMC hC;
2488  hC = ImmGetContext(hwnd);
2489  ImmSetOpenStatus(hC, TRUE);
2490  ImmEscape(NULL, hC, IME_ESC_SET_MODE, (LPVOID)IM_SPELL);
2491  result = false;
2492  }
2493  break;
2494 #endif
2495  case WM_KILLFOCUS:
2496  if (!QWidget::find((HWND)wParam)) { // we don't get focus, so unset it now
2497  if (!widget->hasFocus()) // work around Windows bug after minimizing/restoring
2498  widget = (QETWidget*)QApplication::focusWidget();
2499  HWND focus = ::GetFocus();
2500  //if there is a current widget and the new widget belongs to the same toplevel window
2501  //or if the current widget was embedded into non-qt window (i.e. we won't get WM_ACTIVATEAPP)
2502  //then we clear the focus on the widget
2503  //in case the new widget belongs to a different widget hierarchy, clearing the focus
2504  //will be handled because the active window will change
2505  const bool embedded = widget && ((QETWidget*)widget->window())->topData()->embedded;
2506  if (widget && (embedded || ::IsChild(widget->window()->internalWinId(), focus))) {
2507  widget->clearFocus();
2508  result = true;
2509  } else {
2510  result = false;
2511  }
2512  } else {
2513  result = false;
2514  }
2515  break;
2516  case WM_THEMECHANGED:
2517  if ((widget->windowType() == Qt::Desktop) || !qApp || QApplication::closingDown()
2519  break;
2520 
2522  QApplication::style()->unpolish(widget);
2523 
2525  QApplication::style()->polish(widget);
2526  widget->repolishStyle(*QApplication::style());
2527  if (widget->isVisible())
2528  widget->update();
2529  break;
2530 
2531 #ifndef Q_WS_WINCE
2532  case WM_INPUTLANGCHANGE: {
2533  wchar_t info[7];
2534  if (!GetLocaleInfo(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
2535  inputcharset = CP_ACP;
2536  } else {
2538  }
2540  break;
2541  }
2542 #else
2543  case WM_COMMAND: {
2544  bool OkCommand = (LOWORD(wParam) == 0x1);
2545  bool CancelCommand = (LOWORD(wParam) == 0x2);
2546  if (OkCommand)
2548  if (CancelCommand)
2549  widget->showMinimized();
2550  else
2551 #ifndef QT_NO_MENUBAR
2552  QMenuBar::wceCommands(LOWORD(wParam));
2553 #endif
2554  result = true;
2555  }
2556  break;
2557  case WM_HELP:
2559  result = true;
2560  break;
2561 #endif
2562 
2563  case WM_MOUSELEAVE:
2564  // We receive a mouse leave for curWin, meaning
2565  // the mouse was moved outside our widgets
2566  if (widget->internalWinId() == curWin) {
2567  bool dispatch = !widget->underMouse();
2568  // hasMouse is updated when dispatching enter/leave,
2569  // so test if it is actually up-to-date
2570  if (!dispatch) {
2571  QRect geom = widget->geometry();
2572  if (widget->parentWidget() && !widget->isWindow()) {
2573  QPoint gp = widget->parentWidget()->mapToGlobal(widget->pos());
2574  geom.setX(gp.x());
2575  geom.setY(gp.y());
2576  }
2577  QPoint cpos = QCursor::pos();
2578  dispatch = !geom.contains(cpos);
2579  if ( !dispatch && !QWidget::mouseGrabber()) {
2580  QWidget *hittest = QApplication::widgetAt(cpos);
2581  dispatch = !hittest || hittest->internalWinId() != curWin;
2582  }
2583  if (!dispatch) {
2584  HRGN hrgn = qt_tryCreateRegion(QRegion::Rectangle, 0,0,0,0);
2585  if (GetWindowRgn(curWin, hrgn) != ERROR) {
2586  QPoint lcpos = widget->mapFromGlobal(cpos);
2587  dispatch = !PtInRegion(hrgn, lcpos.x(), lcpos.y());
2588  }
2589  DeleteObject(hrgn);
2590  }
2591  }
2592  if (dispatch) {
2595  else
2597  curWin = 0;
2599  }
2600  }
2601  break;
2602 
2603  case WM_CANCELMODE:
2604  {
2605  // this goes through QMenuBar's event filter
2608  }
2609  break;
2610 
2611  case WM_IME_NOTIFY:
2612  // special handling for ime, only for widgets in a popup
2613  if (wParam == IMN_OPENCANDIDATE) {
2614  imeParentWnd = hwnd;
2616  // temporarily disable the mouse grab to allow mouse input in
2617  // the ime candidate window. The actual handle is untouched
2618  if (autoCaptureWnd)
2619  ReleaseCapture();
2620  }
2621  } else if (wParam == IMN_CLOSECANDIDATE) {
2622  imeParentWnd = 0;
2624  // undo the action above, when candidate window is closed
2625  if (autoCaptureWnd)
2626  SetCapture(autoCaptureWnd);
2627  }
2628  }
2629  result = false;
2630  break;
2631 #ifndef QT_NO_GESTURES
2632 #if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
2633  case WM_GESTURE: {
2634  GESTUREINFO gi;
2635  memset(&gi, 0, sizeof(GESTUREINFO));
2636  gi.cbSize = sizeof(GESTUREINFO);
2637 
2639  BOOL bResult = false;
2640  if (qAppPriv->GetGestureInfo)
2641  bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
2642  if (bResult) {
2643  if (gi.dwID == GID_BEGIN) {
2644  // find the alien widget for the gesture position.
2645  // This might not be accurate as the position is the center
2646  // point of two fingers for multi-finger gestures.
2647  QPoint pt(gi.ptsLocation.x, gi.ptsLocation.y);
2648  QWidget *w = widget->childAt(widget->mapFromGlobal(pt));
2649  qAppPriv->gestureWidget = w ? w : widget;
2650  }
2651  if (qAppPriv->gestureWidget)
2652  static_cast<QETWidget*>(qAppPriv->gestureWidget)->translateGestureEvent(msg, gi);
2653  if (qAppPriv->CloseGestureInfoHandle)
2654  qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
2655  if (gi.dwID == GID_END)
2656  qAppPriv->gestureWidget = 0;
2657  } else {
2658  DWORD dwErr = GetLastError();
2659  if (dwErr > 0)
2660  qWarning() << "translateGestureEvent: error = " << dwErr;
2661  }
2662  result = true;
2663  break;
2664  }
2665 #endif // !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
2666 #endif // QT_NO_GESTURES
2667 #ifndef QT_NO_CURSOR
2668  case WM_SETCURSOR: {
2670  if (ovr) {
2671  SetCursor(ovr->handle());
2672  RETURN(TRUE);
2673  }
2674  result = false;
2675  break;
2676  }
2677 #endif
2678  default:
2679  result = false; // event was not processed
2680  break;
2681  }
2682  }
2683 
2684  if (evt_type != QEvent::None) { // simple event
2685  QEvent e(evt_type);
2686  result = qt_sendSpontaneousEvent(widget, &e);
2687  }
2688 
2689  if (result)
2690  RETURN(false);
2691 
2692 do_default:
2693 #ifndef QT_NO_IM
2694  RETURN(QWinInputContext::DefWindowProc(hwnd,message,wParam,lParam))
2695 #else
2696  RETURN(TRUE);
2697 #endif
2698 }
#define GID_BEGIN
static void qt_set_windows_font_resources()
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QPoint pos() const
#define WM_MOUSEWHEEL
Definition: qt_windows.h:116
static void updateSystemPrivate()
Definition: qlocale.cpp:478
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
#define CSR_TYPE
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
static HWND autoCaptureWnd
void hideChildren(bool spontaneous)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int minimumHeight() const
int reconvertString(RECONVERTSTRING *reconv)
unsigned long WId
Definition: qwindowdefs.h:119
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
#define WM_GETOBJECT
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
HCTX qt_tablet_context
static mach_timebase_info_data_t info
#define WM_TOUCH
int qint32
Definition: qglobal.h:937
QSize size() const
QPointer< QWidget > widget
QTabletDeviceData currentTabletPointer
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
static bool sm_cancel
static bool qt_is_translatable_mouse_event(UINT message)
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
static PtrWTEnable ptrWTEnable
#define WM_MOUSEHWHEEL
Definition: qt_windows.h:119
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define WM_THEMECHANGED
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
#define WM_DRAWCLIPBOARD
bool isVisible() const
Definition: qwidget.h:1005
void markFrameStrutDirty()
Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent
static HPALETTE hPal()
void qt_wince_hide_taskbar(HWND hwnd)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define FAPPCOMMAND_KEY
QString windowIconText() const
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
uint window_state
Definition: qwidget.h:120
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setLocale_helper(const QLocale &l, bool forceUpdate=false)
Definition: qwidget.cpp:6128
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
bool winEvent(MSG *m, long *r)
This special event handler can be reimplemented in a subclass to receive native Windows events which ...
static void wceCommands(uint command)
This function sends native Windows CE commands to Qt menu bars and all their child menus...
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QWidget * nextInFocusChain() const
Returns the next widget in this widget&#39;s focus chain.
Definition: qwidget.cpp:6873
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QApplicationPrivate * instance()
bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets)
#define SPI_SETNONCLIENTMETRICS
static QStyle * style()
Returns the application&#39;s style object.
bool underMouse() const
Returns true if the widget is under the mouse cursor; otherwise returns false.
Definition: qwidget.h:996
KeyboardModifier
Definition: qnamespace.h:127
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool hasFocus() const
Definition: qwidget.cpp:6583
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
#define APPCOMMAND_TREBLE_DOWN
QClipboard * qt_clipboard
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QWidget * qt_get_tablet_widget()
static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab)
void updateKeyMap(const MSG &msg)
static void resolveAygLibs()
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define APPCOMMAND_BASS_UP
int height() const
static QSize closestAcceptableSize(const QWidget *w, const QSize &s)
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is ...
Definition: qlayout.cpp:1586
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
PtrGetGestureInfo GetGestureInfo
#define WM_SETCURSOR
qint32 minw
Definition: qwidget_p.h:264
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static HWND curWin
void showChildren(bool spontaneous)
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
#define SW_PARENTOPENING
void clearFocus()
Takes keyboard input focus from the widget.
Definition: qwidget.cpp:6757
static void quit()
Tells the application to exit with return code 0 (success).
void setWindowTitle_helper(const QString &title)
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
static bool inLoop
static QThreadData * get2(QThread *thread)
Definition: qthread_p.h:219
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
QRect normalGeometry
Definition: qwidget_p.h:181
QTLWExtra * topData()
#define SHRG_RETURNCMD
QDesktopWidget * qt_desktopWidget
static AygRecognizeGesture ptrRecognizeGesture
#define APPCOMMAND_HELP
static PACKET localPacketBuf[QT_TABLET_NPACKETQSIZE]
unsigned __int64 quint64
Definition: qglobal.h:943
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
static QCursorData * currentCursor
Definition: qcursor_mac.mm:106
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
qint32 maxw
Definition: qwidget_p.h:266
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QPointer< QWidget > qt_last_mouse_receiver
#define qApp
struct tagGESTUREINFO GESTUREINFO
int width() const
bool translateWheelEvent(const QWSMouseEvent *me)
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
#define APPCOMMAND_FIND
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static bool qt_try_modal(QWidget *, MSG *, int &ret)
qint32 maxh
Definition: qwidget_p.h:267
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
Qt::KeyboardModifiers qt_win_getKeyboardModifiers()
#define WM_XBUTTONUP
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
static HWND imeParentWnd
Q_CORE_EXPORT void qWarning(const char *,...)
#define GET_X_LPARAM(lp)
unsigned int uint
Definition: qglobal.h:996
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
QString windowTitle() const
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
#define GET_DEVICE_LPARAM(lParam)
#define APPCOMMAND_BASS_DOWN
#define IMR_CONFIRMRECONVERTSTRING
#define WM_GESTURE
#define SPI_SETICONTITLELOGFONT
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.
#define WM_CHANGECBCHAIN
Qt::ContextMenuPolicy contextMenuPolicy
how the widget shows a context menu
Definition: qwidget.h:189
#define GID_END
void * HANDLE
Definition: qnamespace.h:1671
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor)
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
#define IMR_RECONVERTSTRING
static void releaseAutoCapture()
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
QWidgetPrivate * dptr()
void showMinimized()
Shows the widget minimized, as an icon.
Definition: qwidget.cpp:3038
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
bool isEnabled() const
Definition: qwidget.h:948
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
static bool startingUp()
Returns true if an application object has not been created yet; otherwise returns false...
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
static bool sm_smActive
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
static PtrWTPacketsGet ptrWTPacketsGet
bool composition(LPARAM lparam)
QWExtra * xtra()
struct tagMSG MSG
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
uint testWindowState(uint teststate)
static QWidget * activePopupWidget()
Returns the active popup widget.
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
static bool app_do_modal
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
WId
Platform dependent window identifier.
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
#define SPI_SETFONTSMOOTHINGTYPE
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
#define APPCOMMAND_TREBLE_UP
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
unsigned short ushort
Definition: qglobal.h:995
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
static void changeKeyboard()
Definition: qkeymapper.cpp:90
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
static PtrWTInfo ptrWTInfo
PtrCloseGestureInfoHandle CloseGestureInfoHandle
#define GET_APPCOMMAND_LPARAM(lParam)
static void qt_win_read_cleartype_settings()
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
virtual QString text(Text t, int child) const =0
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
int maximumHeight() const
QString objectName() const
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
bool translateTouchEvent(const MSG &msg)
bool translatePaintEvent(const MSG &msg)
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
#define GN_CONTEXTMENU
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
quint16 index
static PtrWTOverlap ptrWTOverlap
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
static bool sendKeyEvent(QWidget *widget, bool grab, QEvent::Type type, int code, Qt::KeyboardModifiers modifiers, const QString &text, bool autorepeat, int count, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, bool *unusedExceptForCocoa=0)
qint32 minh
Definition: qwidget_p.h:265
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
bool translateMouseEvent(const QWSMouseEvent *, int oldstate)
The QClipboardEvent class provides the parameters used in a clipboard event.
Definition: qevent.h:695
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
#define WM_APPCOMMAND
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
#define GET_Y_LPARAM(lp)
#define WM_XBUTTONDBLCLK
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
#define SHRG_NOANIMATION
#define RETURN(x)
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
void repolishStyle(QStyle &style)
QWidgetData * dataPtr()
#define GET_KEYSTATE_LPARAM(lParam)
const QRect & geometry() const
QSessionManager * qt_session_manager_self
static void alert_widget(QWidget *widget, int duration)
static QPointer< QWidget > popupButtonFocus
#define SPI_SETSIPINFO
static bool sm_blockUserInput
QRect frameStrut() const
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom)
Definition: qregion_win.cpp:55
int minimumWidth() const
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
IAccessible * qt_createWindowsAccessible(QAccessibleInterface *object)
static int inputcharset
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
static int translateButtonState(int s, int type, int button)
static void qt_set_windows_updateScrollBar(QWidget *widget)
#define APPCOMMAND_BASS_BOOST
bool translateConfigEvent(const MSG &msg)
static void enterWhatsThisMode()
This function switches the user interface into "What&#39;s This?" mode.
Definition: qwhatsthis.cpp:633
QWidget * qt_button_down
static void qt_set_windows_color_resources()
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
#define text
Definition: qobjectdefs.h:80
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
#define WM_ACTIVATEAPP
#define WM_MOUSELEAVE
#define SW_PARENTCLOSING
#define WM_XBUTTONDOWN
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
static int area(const QSize &s)
Definition: qicon.cpp:155
bool translateCloseEvent(const MSG &msg)
bool qt_tabletChokeMouse
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
int maximumWidth() const

◆ setKbdState()

void setKbdState ( unsigned char *  kbd,
bool  shift,
bool  ctrl,
bool  alt 
)
inline

Definition at line 657 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::updatePossibleKeyCodes().

658 {
659  kbd[VK_LSHIFT ] = (shift ? 0x80 : 0);
660  kbd[VK_SHIFT ] = (shift ? 0x80 : 0);
661  kbd[VK_LCONTROL] = (ctrl ? 0x80 : 0);
662  kbd[VK_CONTROL ] = (ctrl ? 0x80 : 0);
663  kbd[VK_RMENU ] = (alt ? 0x80 : 0);
664  kbd[VK_MENU ] = (alt ? 0x80 : 0);
665 }
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
Definition: qbezier.cpp:289

◆ ToAscii()

int ToAscii ( UINT  vk,
int  scancode,
unsigned char *  kbdBuffer,
LPWORD  unicodeBuffer,
int  flag 
)

Definition at line 479 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::updatePossibleKeyCodes().

480 {
481  return ToUnicode(vk, scancode, kbdBuffer, (LPWSTR) unicodeBuffer, 0, flag);
482 
483 }
int ToUnicode(UINT vk, int, unsigned char *, LPWSTR unicodeBuffer, int, int)

◆ toKeyOrUnicode()

static int toKeyOrUnicode ( int  vk,
int  scancode,
unsigned char *  kbdBuffer,
bool *  isDeadkey = 0 
)
inlinestatic

Definition at line 489 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::updatePossibleKeyCodes().

490 {
491  Q_ASSERT(vk > 0 && vk < 256);
492  int code = 0;
493  QChar unicodeBuffer[5];
494  int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
495  // When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the
496  // right key the control modifier is removed for just that function if the previous call failed.
497  if (res == 0 && kbdBuffer[VK_CONTROL]) {
498  const unsigned char controlState = kbdBuffer[VK_CONTROL];
499  kbdBuffer[VK_CONTROL] = 0;
500  res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
501  kbdBuffer[VK_CONTROL] = controlState;
502  }
503  if (res)
504  code = unicodeBuffer[0].toUpper().unicode();
505 
506  // Qt::Key_*'s are not encoded below 0x20, so try again, and DEL keys (0x7f) is encoded with a
507  // proper Qt::Key_ code
508  if (code < 0x20 || code == 0x7f) // Handles res==0 too
509  code = winceKeyBend(vk);
510 
511  if (isDeadkey)
512  *isDeadkey = (res == -1);
513 
514  return code == Qt::Key_unknown ? 0 : code;
515 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
int ToUnicode(UINT vk, int, unsigned char *, LPWSTR unicodeBuffer, int, int)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int winceKeyBend(int keyCode)
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287

◆ ToUnicode()

int ToUnicode ( UINT  vk,
int  ,
unsigned char *  ,
LPWSTR  unicodeBuffer,
int  ,
int   
)

Definition at line 468 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey(), ToAscii(), and toKeyOrUnicode().

469 {
471  QChar* buf = reinterpret_cast< QChar*>(unicodeBuffer);
472  if (KeyTbl[vk] == 0) {
473  buf[0] = vk;
474  return 1;
475  }
476  return 0;
477 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const uint KeyTbl[]
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
Definition: qglobal.h:88

◆ winceKeyBend()

int winceKeyBend ( int  keyCode)
inline

Remap return or action key to select key for windows mobile.

Definition at line 448 of file qkeymapper_win.cpp.

Referenced by qt_translateKeyCode(), toKeyOrUnicode(), and QKeyMapperPrivate::updatePossibleKeyCodes().

449 {
450 #if defined(Q_OS_WINCE_WM) && defined(QT_KEYPAD_NAVIGATION)
451  // remap return or action key to select key for windows mobile.
452  // will be changed to a table remapping function in the next version (4.6/7).
453  if (keyCode == VK_RETURN && QApplication::keypadNavigationEnabled())
454  return Qt::Key_Select;
455  else
456  return KeyTbl[keyCode];
457 #else
458  return KeyTbl[keyCode];
459 #endif
460 }
static const uint KeyTbl[]

Variable Documentation

◆ key_recorder

KeyRecorder key_recorder
static

Definition at line 119 of file qkeymapper_win.cpp.

◆ KeyTbl

const uint KeyTbl[]
static

Definition at line 168 of file qkeymapper_win.cpp.

Referenced by ToUnicode(), and winceKeyBend().

◆ ModsTbl

const Qt::KeyboardModifiers ModsTbl[]
static
Initial value:

Definition at line 433 of file qkeymapper_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().

◆ QT_MAX_KEY_RECORDINGS

const int QT_MAX_KEY_RECORDINGS = 64
static

Definition at line 106 of file qkeymapper_win.cpp.

Referenced by KeyRecorder::storeKey().

◆ qt_use_rtl_extensions

bool qt_use_rtl_extensions

Definition at line 266 of file qapplication_win.cpp.

Referenced by QKeyMapperPrivate::isADeadKey().