📄 qwindowsystem_qws.cpp
字号:
while (!pendingDoClients.isEmpty()) { doClient(pendingDoClients.takeFirst()); } doClientIsActive = false;}#endif // QT_NO_QWS_MULTIPROCESSvoid QWSServerPrivate::doClient(QWSClient *client){ QWSCommand* command=client->readMoreCommand(); while (command) { QWSCommandStruct *cs = new QWSCommandStruct(command, client); commandQueue.append(cs); // Try for some more... command=client->readMoreCommand(); } while (!commandQueue.isEmpty()) { QWSCommandStruct *cs = commandQueue.takeAt(0); switch (cs->command->type) { case QWSCommand::Identify: invokeIdentify((QWSIdentifyCommand*)cs->command, cs->client); break; case QWSCommand::Create: invokeCreate((QWSCreateCommand*)cs->command, cs->client); break;#ifndef QT_NO_QWS_MULTIPROCESS case QWSCommand::Shutdown: cs->client->d_func()->shutdown = true; break;#endif case QWSCommand::RegionName: invokeRegionName((QWSRegionNameCommand*)cs->command, cs->client); break; case QWSCommand::Region: invokeRegion((QWSRegionCommand*)cs->command, cs->client); cs->client->d_func()->unlockCommunication(); break; case QWSCommand::RegionMove: invokeRegionMove((QWSRegionMoveCommand*)cs->command, cs->client); cs->client->d_func()->unlockCommunication(); break; case QWSCommand::RegionDestroy: invokeRegionDestroy((QWSRegionDestroyCommand*)cs->command, cs->client); break;#ifndef QT_NO_QWS_PROPERTIES case QWSCommand::AddProperty: invokeAddProperty((QWSAddPropertyCommand*)cs->command); break; case QWSCommand::SetProperty: invokeSetProperty((QWSSetPropertyCommand*)cs->command); break; case QWSCommand::RemoveProperty: invokeRemoveProperty((QWSRemovePropertyCommand*)cs->command); break; case QWSCommand::GetProperty: invokeGetProperty((QWSGetPropertyCommand*)cs->command, cs->client); break;#endif case QWSCommand::SetSelectionOwner: invokeSetSelectionOwner((QWSSetSelectionOwnerCommand*)cs->command); break; case QWSCommand::RequestFocus: invokeSetFocus((QWSRequestFocusCommand*)cs->command, cs->client); break; case QWSCommand::ChangeAltitude: invokeSetAltitude((QWSChangeAltitudeCommand*)cs->command, cs->client); cs->client->d_func()->unlockCommunication(); break; case QWSCommand::SetOpacity: invokeSetOpacity((QWSSetOpacityCommand*)cs->command, cs->client); break;#ifndef QT_NO_QWS_CURSOR case QWSCommand::DefineCursor: invokeDefineCursor((QWSDefineCursorCommand*)cs->command, cs->client); break; case QWSCommand::SelectCursor: invokeSelectCursor((QWSSelectCursorCommand*)cs->command, cs->client); break; case QWSCommand::PositionCursor: invokePositionCursor((QWSPositionCursorCommand*)cs->command, cs->client); break;#endif case QWSCommand::GrabMouse: invokeGrabMouse((QWSGrabMouseCommand*)cs->command, cs->client); break; case QWSCommand::GrabKeyboard: invokeGrabKeyboard((QWSGrabKeyboardCommand*)cs->command, cs->client); break;#if !defined(QT_NO_SOUND) && !defined(Q_OS_DARWIN) case QWSCommand::PlaySound: invokePlaySound((QWSPlaySoundCommand*)cs->command, cs->client); break;#endif#ifndef QT_NO_COP case QWSCommand::QCopRegisterChannel: invokeRegisterChannel((QWSQCopRegisterChannelCommand*)cs->command, cs->client); break; case QWSCommand::QCopSend: invokeQCopSend((QWSQCopSendCommand*)cs->command, cs->client); break;#endif#ifndef QT_NO_QWS_INPUTMETHODS case QWSCommand::IMUpdate: invokeIMUpdate((QWSIMUpdateCommand*)cs->command, cs->client); break; case QWSCommand::IMResponse: invokeIMResponse((QWSIMResponseCommand*)cs->command, cs->client); break; case QWSCommand::IMMouse: { if (current_IM) { QWSIMMouseCommand *cmd = (QWSIMMouseCommand *) cs->command; current_IM->mouseHandler(cmd->simpleData.index, cmd->simpleData.state); } } break;#endif case QWSCommand::Font: invokeFont((QWSFontCommand *)cs->command, cs->client); break; case QWSCommand::RepaintRegion: invokeRepaintRegion((QWSRepaintRegionCommand*)cs->command, cs->client); cs->client->d_func()->unlockCommunication(); break;#ifndef QT_NO_QWSEMBEDWIDGET case QWSCommand::Embed: invokeEmbed(static_cast<QWSEmbedCommand*>(cs->command), cs->client); break;#endif } delete cs; }}void QWSServerPrivate::showCursor(){#ifndef QT_NO_QWS_CURSOR qt_screencursor->show();#endif}void QWSServerPrivate::hideCursor(){#ifndef QT_NO_QWS_CURSOR qt_screencursor->hide();#endif}/*! \fn void QWSServer::enablePainting(bool enable) Enables painting onto the screen if \a enable is true; otherwise painting is disabled. \sa {Qtopia Core Architecture#Drawing on Screen}{Qtopia Core Architecture}*/void QWSServer::enablePainting(bool enable){ Q_D(QWSServer); if (d->disablePainting == !enable) return; d->disablePainting = !enable; if (enable) { // Reset the server side allocated regions to ensure update_regions() // will send out region events. for (int i = 0; i < d->windows.size(); ++i) { QWSWindow *w = d->windows.at(i); w->setAllocatedRegion(QRegion()); } d->update_regions(); d->showCursor(); } else { // Disable painting by clients by taking away their allocated region. // To ensure mouse events are still delivered to the correct windows, // the allocated regions are not modified on the server. for (int i = 0; i < d->windows.size(); ++i) { QWSWindow *w = d->windows.at(i); w->client()->sendRegionEvent(w->winId(), QRegion(), QWSRegionEvent::Allocation); } d->hideCursor(); }}/*! Refreshes the display by making the screen driver update the entire display. \sa QScreen::exposeRegion()*/void QWSServer::refresh(){ Q_D(QWSServer); d->exposeRegion(QRegion(0, 0, d->swidth, d->sheight));//### send repaint to non-buffered windows}/*! \fn void QWSServer::refresh(QRegion & region) \overload Refreshes the given \a region of the display.*/void QWSServer::refresh(QRegion & r){ Q_D(QWSServer); d->exposeRegion(r);//### send repaint to non-buffered windows}/*! \fn void QWSServer::setMaxWindowRect(const QRect& rectangle) Sets the maximum area of the screen that \l {Qtopia Core} applications can use, to be the given \a rectangle. Note that this function can only be used in the server process. \sa QWidget::showMaximized()*/void QWSServer::setMaxWindowRect(const QRect &rect){ QList<QScreen*> subScreens = qt_screen->subScreens(); if (subScreens.isEmpty() && qt_screen != 0) subScreens.append(qt_screen); for (int i = 0; i < subScreens.size(); ++i) { const QScreen *screen = subScreens.at(i); const QRect r = (screen->region() & rect).boundingRect(); if (r.isEmpty()) continue; QApplicationPrivate *ap = QApplicationPrivate::instance(); if (ap->maxWindowRect(screen) != r) { ap->setMaxWindowRect(screen, i, r); qwsServerPrivate->sendMaxWindowRectEvents(r); } }}/*! \internal*/void QWSServerPrivate::sendMaxWindowRectEvents(const QRect &rect){ QMap<int,QWSClient*>::const_iterator it = clientMap.constBegin(); for (; it != clientMap.constEnd(); ++it) (*it)->sendMaxWindowRectEvent(rect);}/*! \fn void QWSServer::setDefaultMouse(const char *mouseDriver) Sets the mouse driver that will be used if the QWS_MOUSE_PROTO environment variable is not defined, to be the given \a mouseDriver. Note that the default is platform-dependent. This function can only be used in the server process. \sa setMouseHandler(), {Qtopia Core Pointer Handling}*/void QWSServer::setDefaultMouse(const char *m){ *defaultMouse() = QString::fromAscii(m);}/*! \fn void QWSServer::setDefaultKeyboard(const char *keyboardDriver) Sets the keyboard driver that will be used if the QWS_KEYBOARD environment variable is not defined, to be the given \a keyboardDriver. Note that the default is platform-dependent. This function can only be used in the server process. \sa setKeyboardHandler(), {Qtopia Core Character Input}*/void QWSServer::setDefaultKeyboard(const char *k){ *defaultKeyboard() = QString::fromAscii(k);}#ifndef QT_NO_QWS_CURSORstatic bool prevWin;#endifextern int *qt_last_x,*qt_last_y;/*! \internal Send a mouse event. \a pos is the screen position where the mouse event occurred and \a state is a mask indicating which buttons are pressed. \a pos is in device coordinates*/void QWSServer::sendMouseEvent(const QPoint& pos, int state, int wheel){ bool block = qwsServerPrivate->screensaverblockevent(MOUSE, qwsServerPrivate->screensaverinterval, state);#ifdef EVENT_BLOCK_DEBUG qDebug() << "sendMouseEvent" << pos.x() << pos.y() << state << (block?"block":"pass");#endif if (state) qwsServerPrivate->_q_screenSaverWake(); if ( block ) return; QPoint tpos; // transformations if (qt_screen->isTransformed()) { QSize s = QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()); tpos = qt_screen->mapFromDevice(pos, s); } else { tpos = pos; } if (qt_last_x) { *qt_last_x = tpos.x(); *qt_last_y = tpos.y(); } QWSServer::mousePosition = tpos; qwsServerPrivate->mouseState = state;#ifndef QT_NO_QWS_INPUTMETHODS const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton; int stroke_count; // number of strokes to keep shown. if (force_reject_strokeIM || !current_IM) { stroke_count = 0; } else { stroke_count = current_IM->filter(tpos, state, wheel); } if (stroke_count == 0) { if (state&btnMask) force_reject_strokeIM = true; QWSServerPrivate::sendMouseEventUnfiltered(tpos, state, wheel); } // stop force reject after stroke ends. if (state&btnMask && force_reject_strokeIM) force_reject_strokeIM = false; // on end of stroke, force_rejct // and once a stroke is rejected, do not try again till pen is lifted#else QWSServerPrivate::sendMouseEventUnfiltered(tpos, state, wheel);#endif // end QT_NO_QWS_FSIM}void QWSServerPrivate::sendMouseEventUnfiltered(const QPoint &pos, int state, int wheel){ const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton; QWSMouseEvent event; QWSWindow *win = qwsServer->windowAt(pos); QWSClient *serverClient = qwsServerPrivate->clientMap.value(-1); QWSClient *winClient = win ? win->client() : 0; bool imMouse = false;#ifndef QT_NO_QWS_INPUTMETHODS // check for input method window if (current_IM && current_IM_winId != -1) { QWSWindow *kbw = keyboardGrabber ? keyboardGrabber : qwsServerPrivate->focusw; imMouse = kbw == win; if ( !imMouse ) { QWidget *target = winClient == serverClient ? QApplication::widgetAt(pos) : 0; imMouse = target && (target->testAttribute(Qt::WA_InputMethodTransparent)); } }#endif //If grabbing window disappears, grab is still active until //after mouse release. if ( qwsServerPrivate->mouseGrabber && !imMouse ) { win = qwsServerPrivate->mouseGrabber; winClient = win ? win->client() : 0; } event.simpleData.window = win ? win->id : 0;#ifndef QT_NO_QWS_CURSOR qt_screencursor->move(pos.x(),pos.y()); // Arrow cursor over desktop // prevWin remembers if the last event was over a window if (!win && prevWin) { if (!qwsServerPrivate->mouseGrabber) qwsServerPrivate->setCursor(QWSCursor::systemCursor(Qt::ArrowCursor)); else qwsServerPrivate->nextCursor = QWSCursor::systemCursor(Qt::ArrowCursor); prevWin = false; } // reset prevWin if (win && !prevWin) prevWin = true;#endif if ((state&btnMask) && !qwsServerPrivate->mouseGrabbing) { qwsServerPrivate->mouseGrabber = win; } event.simpleData.x_root=pos.x(); event.simpleData.y_root=pos.y(); event.simpleData.state=state | qws_keyModifiers; event.simpleData.delta = wheel; event.simpleData.time=qwsServerPrivate->timer.elapsed(); static int oldstate = 0;#ifndef QT_NO_QWS_INPUTMETHODS //tell the input method if we click on a different window that is not IM transparent bool isPress = state > oldstate; if (isPress && !imMouse && current_IM && current_IM_winId != -1) current_IM->mouseHandler(-1, QWSServer::MouseOutside);#endif if (serverClient) serverClient->sendEvent(&event); if (winClient && winClient != serverClient) winClient->sendEvent(&event); if ( !imMouse ) { // Make sure that if we leave a window, that window gets one last mouse // event so that it knows the mouse has left. QWSClient *oldClient = qwsServer->d_func()->cursorClient; if (oldClient && oldClient != winClient && oldClient != serverClient) { event.simpleData.state = oldstate | qws_keyModifiers; oldClient->sendEvent(&event); } } oldstate = state; if ( !imMouse ) qwsServer->d_func()->cursorClient = winClient;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -