⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwidget_x11.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            || !QX11Info::appDefaultColormap(xinfo.screen())) {            // non-default visual/colormap, use 1bpp bitmap            if (!forceReset || !topData->iconPixmap)                topData->iconPixmap = new QBitmap(pixmap);            h->icon_pixmap = topData->iconPixmap->handle();        } else {            // default depth, use a normal pixmap (even though this            // violates the ICCCM)            if (!forceReset || !topData->iconPixmap)                topData->iconPixmap = new QPixmap(pixmap);            h->icon_pixmap = topData->iconPixmap->data->x11ConvertToDefaultDepth();        }        h->flags |= IconPixmapHint;        QBitmap mask = topData->iconPixmap->mask();        if (!mask.isNull()) {            if (!topData->iconMask)                topData->iconMask = new QBitmap;            *topData->iconMask = mask;            h->icon_mask = topData->iconMask->handle();            h->flags |= IconMaskHint;        }    } else {        h->flags &= ~(IconPixmapHint | IconMaskHint);    }    XSetWMHints(X11->display, q->winId(), h);    if (h != &wm_hints)        XFree((char *)h);}void QWidgetPrivate::setWindowIconText_sys(const QString &iconText){    Q_Q(QWidget);    XSetWMIconName(X11->display, q->winId(), qstring_to_xtp(iconText));    QByteArray icon_name = iconText.toUtf8();    XChangeProperty(X11->display, q->winId(), ATOM(_NET_WM_ICON_NAME), ATOM(UTF8_STRING), 8,                    PropModeReplace, (unsigned char *) icon_name.constData(), icon_name.size());}/*!    Grabs the mouse input.    This widget receives all mouse events until releaseMouse() is    called; other widgets get no mouse events at all. Keyboard    events are not affected. Use grabKeyboard() if you want to grab    that.    \warning Bugs in mouse-grabbing applications very often lock the    terminal. Use this function with extreme caution, and consider    using the \c -nograb command line option while debugging.    It is almost never necessary to grab the mouse when using Qt, as    Qt grabs and releases it sensibly. In particular, Qt grabs the    mouse when a mouse button is pressed and keeps it until the last    button is released.    Note that only visible widgets can grab mouse input. If    isVisible() returns false for a widget, that widget cannot call    grabMouse().    \sa releaseMouse() grabKeyboard() releaseKeyboard() grabKeyboard()    focusWidget()*/void QWidget::grabMouse(){    if (isVisible() && !qt_nograb()) {        if (mouseGrb)            mouseGrb->releaseMouse();#ifndef QT_NO_DEBUG        int status =#endif            XGrabPointer(X11->display, winId(), False,                          (uint)(ButtonPressMask | ButtonReleaseMask |                                  PointerMotionMask | EnterWindowMask |                                  LeaveWindowMask),                          GrabModeAsync, GrabModeAsync,                          XNone, XNone, X11->time);#ifndef QT_NO_DEBUG        if (status) {            const char *s =                status == GrabNotViewable ? "\"GrabNotViewable\"" :                status == AlreadyGrabbed  ? "\"AlreadyGrabbed\"" :                status == GrabFrozen      ? "\"GrabFrozen\"" :                status == GrabInvalidTime ? "\"GrabInvalidTime\"" :                "<?>";            qWarning("Grabbing the mouse failed with %s", s);        }#endif        mouseGrb = this;    }}/*!    \overload    Grabs the mouse input and changes the cursor shape.    The cursor will assume shape \a cursor (for as long as the mouse    focus is grabbed) and this widget will be the only one to receive    mouse events until releaseMouse() is called().    \warning Grabbing the mouse might lock the terminal.    \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()*/void QWidget::grabMouse(const QCursor &cursor){    if (!qt_nograb()) {        if (mouseGrb)            mouseGrb->releaseMouse();#ifndef QT_NO_DEBUG        int status =#endif        XGrabPointer(X11->display, winId(), False,                      (uint)(ButtonPressMask | ButtonReleaseMask |                             PointerMotionMask | EnterWindowMask | LeaveWindowMask),                      GrabModeAsync, GrabModeAsync,                      XNone, cursor.handle(), X11->time);#ifndef QT_NO_DEBUG        if (status) {            const char *s =                status == GrabNotViewable ? "\"GrabNotViewable\"" :                status == AlreadyGrabbed  ? "\"AlreadyGrabbed\"" :                status == GrabFrozen      ? "\"GrabFrozen\"" :                status == GrabInvalidTime ? "\"GrabInvalidTime\"" :                                            "<?>";            qWarning("Grabbing the mouse failed with %s", s);        }#endif        mouseGrb = this;    }}/*!    Releases the mouse grab.    \sa grabMouse(), grabKeyboard(), releaseKeyboard()*/void QWidget::releaseMouse(){    if (!qt_nograb() && mouseGrb == this) {        XUngrabPointer(X11->display, X11->time);        XFlush(X11->display);        mouseGrb = 0;    }}/*!    Grabs the keyboard input.    This widget receives all keyboard events until releaseKeyboard()    is called; other widgets get no keyboard events at all. Mouse    events are not affected. Use grabMouse() if you want to grab that.    The focus widget is not affected, except that it doesn't receive    any keyboard events. setFocus() moves the focus as usual, but the    new focus widget receives keyboard events only after    releaseKeyboard() is called.    If a different widget is currently grabbing keyboard input, that    widget's grab is released first.    \sa releaseKeyboard() grabMouse() releaseMouse() focusWidget()*/void QWidget::grabKeyboard(){    if (!qt_nograb()) {        if (keyboardGrb)            keyboardGrb->releaseKeyboard();        XGrabKeyboard(X11->display, data->winid, False, GrabModeAsync, GrabModeAsync,                      X11->time);        keyboardGrb = this;    }}/*!    Releases the keyboard grab.    \sa grabKeyboard(), grabMouse(), releaseMouse()*/void QWidget::releaseKeyboard(){    if (!qt_nograb() && keyboardGrb == this) {        XUngrabKeyboard(X11->display, X11->time);        keyboardGrb = 0;    }}/*!    Returns the widget that is currently grabbing the mouse input.    If no widget in this application is currently grabbing the mouse,    0 is returned.    \sa grabMouse(), keyboardGrabber()*/QWidget *QWidget::mouseGrabber(){    return mouseGrb;}/*!    Returns the widget that is currently grabbing the keyboard input.    If no widget in this application is currently grabbing the    keyboard, 0 is returned.    \sa grabMouse(), mouseGrabber()*/QWidget *QWidget::keyboardGrabber(){    return keyboardGrb;}/*!    Sets the top-level widget containing this widget to be the active    window.    An active window is a visible top-level window that has the    keyboard input focus.    This function performs the same operation as clicking the mouse on    the title bar of a top-level window. On X11, the result depends on    the Window Manager. If you want to ensure that the window is    stacked on top as well you should also call raise(). Note that the    window must be visible, otherwise activateWindow() has no effect.    On Windows, if you are calling this when the application is not    currently the active one then it will not make it the active    window.  It will change the color of the task bar entry to indicate    that the window has changed in some way. This is because Microsoft    do not allow an application to interrupt what the user is currently    doing in another application.    \sa isActiveWindow(), window(), show()*/void QWidget::activateWindow(){    Q_D(QWidget);    QWidget *tlw = window();    if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) {        XSetInputFocus(X11->display, tlw->winId(), XRevertToParent, X11->time); 	d->focusInputContext();    }}void QWidgetPrivate::dirtyWidget_sys(const QRegion &rgn){    Q_Q(QWidget);    if (!rgn.isEmpty()) {        dirtyOnScreen += rgn;        QApplication::postEvent(q, new QEvent(QEvent::UpdateRequest));    }}void QWidgetPrivate::cleanWidget_sys(const QRegion& rgn){    dirtyOnScreen -= rgn;}void QWidget::setWindowState(Qt::WindowStates newstate){    Q_D(QWidget);    bool needShow = false;    Qt::WindowStates oldstate = windowState();    if (oldstate == newstate)        return;    if (isWindow()) {        // Ensure the initial size is valid, since we store it as normalGeometry below.        if (!testAttribute(Qt::WA_Resized) && !isVisible())            adjustSize();        QTLWExtra *top = d->topData();        if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {            if (qt_net_supports(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ))                && qt_net_supports(ATOM(_NET_WM_STATE_MAXIMIZED_VERT))) {                if ((newstate & Qt::WindowMaximized) && !(oldstate & Qt::WindowFullScreen))                    top->normalGeometry = geometry();                qt_change_net_wm_state(this, (newstate & Qt::WindowMaximized),                                       ATOM(_NET_WM_STATE_MAXIMIZED_HORZ),                                       ATOM(_NET_WM_STATE_MAXIMIZED_VERT));            } else if (! (newstate & Qt::WindowFullScreen)) {                if (newstate & Qt::WindowMaximized) {                    // save original geometry                    const QRect normalGeometry = geometry();                    if (isVisible()) {                        d->updateFrameStrut();                        const QRect maxRect = QApplication::desktop()->availableGeometry(this);                        const QRect r = top->normalGeometry;                        setGeometry(maxRect.x() + top->fleft,                                    maxRect.y() + top->ftop,                                    maxRect.width() - top->fleft - top->fright,                                    maxRect.height() - top->ftop - top->fbottom);                        top->normalGeometry = r;                    }                    if (top->normalGeometry.width() < 0)                        top->normalGeometry = normalGeometry;                } else {                    // restore original geometry                    setGeometry(top->normalGeometry);                }            }        }        if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {            if (qt_net_supports(ATOM(_NET_WM_STATE_FULLSCREEN))) {                if (newstate & Qt::WindowFullScreen)                    top->normalGeometry = geometry();                qt_change_net_wm_state(this, (newstate & Qt::WindowFullScreen),                                       ATOM(_NET_WM_STATE_FULLSCREEN));            } else {                needShow = isVisible();                if (newstate & Qt::WindowFullScreen) {                    d->updateFrameStrut();                    const QRect normalGeometry = geometry();                    const QPoint fullScreenOffset = QPoint(top->fleft, top->ftop);                    top->savedFlags = windowFlags();                    setParent(0, Qt::Window | Qt::FramelessWindowHint);                    const QRect r = top->normalGeometry;                    setGeometry(qApp->desktop()->screenGeometry(this));                    top->normalGeometry = r;                    if (top->normalGeometry.width() < 0) {                        top->normalGeometry = normalGeometry;                        top->fullScreenOffset = fullScreenOffset;                    }                } else {                    setParent(0, top->savedFlags);                    if (newstate & Qt::WindowMaximized) {                        // from fullscreen to maximized                        d->updateFrameStrut();                        const QRect maxRect = QApplication::desktop()->availableGeometry(this);                        const QRect r = top->normalGeometry;                        setGeometry(maxRect.x() + top->fleft,                                    maxRect.y() + top->ftop,                                    maxRect.width() - top->fleft - top->fright,                                    maxRect.height() - top->ftop - top->fbottom);                        top->normalGeometry = r;                    } else {                        // restore original geometry                        setGeometry(top->normalGeometry.adjusted(-top->fullScreenOffset.x(),                                                                 -top->fullScreenOffset.y(),                                                                 -top->fullScreenOffset.x(),                                                                 -top->fullScreenOffset.y()));                    }                }            }        }        if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {            if (isVisible()) {                if (newstate & Qt::WindowMinimized) {                    XEvent e;                    e.xclient.type = ClientMessage;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -