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

📄 qapplication_x11.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                               False, XA_ATOM, &type, &format, &nitems, &after, &data);            if (type == XA_ATOM && format == 32) {                ts.write(reinterpret_cast<char *>(data), nitems * 4);                offset += nitems;            } else                after = 0;            if (data)                XFree(data);        }        // compute nitems        QByteArray buffer(ts.buffer());        nitems = buffer.size() / sizeof(Window);        X11->net_virtual_root_list = new Window[nitems + 1];        Window *a = (Window *) buffer.data();        uint i;        for (i = 0; i < nitems; i++)            X11->net_virtual_root_list[i] = a[i];        X11->net_virtual_root_list[nitems] = 0;    }}static void qt_net_update_user_time(QWidget *tlw){    XChangeProperty(X11->display, tlw->winId(), ATOM(_NET_WM_USER_TIME),                    XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &X11->userTime, 1);}static void qt_check_focus_model(){    Window fw = XNone;    int unused;    XGetInputFocus(X11->display, &fw, &unused);    if (fw == PointerRoot)        X11->focus_model = QX11Data::FM_PointerRoot;    else        X11->focus_model = QX11Data::FM_Other;}#ifndef QT_NO_TABLETstatic bool isXInputSupported(Display *dpy){    Bool exists;    XExtensionVersion *version;    exists = XQueryExtension(dpy, "XInputExtension", &X11->xinput_major,                             &X11->xinput_eventbase, &X11->xinput_errorbase);    if (!exists)        return false;    version = XGetExtensionVersion(dpy, "XInputExtension");    if (!version || version == reinterpret_cast<XExtensionVersion *>(NoSuchExtension))        return false;    XFree(version);    return true;}#endif/*****************************************************************************  qt_init() - initializes Qt for X11 *****************************************************************************/#define XK_MISCELLANY#define XK_LATIN1#define XK_KOREAN#define XK_XKB_KEYS#include <X11/keysymdef.h>#if !defined(QT_NO_FONTCONFIG)static void getXDefault(const char *group, const char *key, int *val){    char *str = XGetDefault(X11->display, group, key);    if (str) {        char *end = 0;        int v = strtol(str, &end, 0);        if (str != end)            *val = v;    }}static void getXDefault(const char *group, const char *key, double *val){    char *str = XGetDefault(X11->display, group, key);    if (str) {        char *end = 0;        double v = strtod(str, &end);        if (str != end)            *val = v;    }}static void getXDefault(const char *group, const char *key, bool *val){    char *str = XGetDefault(X11->display, group, key);    if (str) {        char c = str[0];        if (isupper((int)c))            c = tolower(c);        if (c == 't' || c == 'y' || c == '1')            *val = true;        else if (c == 'f' || c == 'n' || c == '0')            *val = false;        if (c == 'o') {            c = str[1];            if (isupper((int)c))                c = tolower(c);            if (c == 'n')                *val = true;            if (c == 'f')                *val = false;        }    }}#endif// ### This should be static but it isn't because of the friend declaration// ### in qpaintdevice.h which then should have a static too but can't have// ### it because "storage class specifiers invalid in friend function// ### declarations" :-) Ideas anyone?void qt_init(QApplicationPrivate *priv, int,	     Display *display, Qt::HANDLE visual, Qt::HANDLE colormap){    setlocale(LC_ALL, "");                // use correct char set mapping    setlocale(LC_NUMERIC, "C");        // make sprintf()/scanf() work    X11 = new QX11Data;    X11->display = display;    X11->displayName = 0;    X11->foreignDisplay = (display != 0);    X11->focus_model = -1;    // RANDR    X11->use_xrandr = false;    X11->xrandr_major = 0;    X11->xrandr_eventbase = 0;    X11->xrandr_errorbase = 0;    // RENDER    X11->use_xrender = false;    X11->xrender_major = 0;    X11->xrender_eventbase = 0;    X11->xrender_errorbase = 0;    // XInputExtension    X11->use_xinput = false;    X11->xinput_major = 0;    X11->xinput_eventbase = 0;    X11->xinput_errorbase = 0;    X11->sip_serial = 0;    X11->net_supported_list = 0;    X11->net_virtual_root_list = 0;    X11->wm_client_leader = 0;    X11->screens = 0;    X11->screenCount = 0;    X11->time = CurrentTime;    X11->userTime = CurrentTime;    X11->ignore_badwindow = false;    X11->seen_badwindow = false;    X11->motifdnd_active = false;    X11->default_im = QLatin1String("imsw-multi");    priv->inputContext = 0;    // colormap control    X11->visual_class = -1;    X11->visual_id = -1;    X11->color_count = 0;    X11->custom_cmap = false;    // outside visual/colormap    X11->visual = reinterpret_cast<Visual *>(visual);    X11->colormap = colormap;#ifndef QT_NO_XRENDER    memset(X11->solid_fills, 0, sizeof(X11->solid_fills));    for (int i = 0; i < X11->solid_fill_count; ++i)        X11->solid_fills[i].screen = -1;    memset(X11->pattern_fills, 0, sizeof(X11->pattern_fills));    for (int i = 0; i < X11->pattern_fill_count; ++i)        X11->pattern_fills[i].screen = -1;#endif    X11->startupId = 0;    int argc = priv->argc;    char **argv = priv->argv;    if (X11->display) {        // Qt part of other application        // Set application name and class        appName = qstrdup("Qt-subapplication");        char *app_class = 0;        if (argv) {            const char* p = strrchr(argv[0], '/');            app_class = qstrdup(p ? p + 1 : argv[0]);            if (app_class[0])                app_class[0] = toupper(app_class[0]);        }        appClass = app_class;    } else {        // Qt controls everything (default)        // Set application name and class        char *app_class = 0;        if (argv && argv[0]) {            const char *p = strrchr(argv[0], '/');            appName = p ? p + 1 : argv[0];            app_class = qstrdup(appName);            if (app_class[0])                app_class[0] = toupper(app_class[0]);        }        appClass = app_class;    }    // Install default error handlers    original_x_errhandler = XSetErrorHandler(qt_x_errhandler);    original_xio_errhandler = XSetIOErrorHandler(qt_xio_errhandler);    // Get command line params    int j = argc ? 1 : 0;    for (int i=1; i<argc; i++) {        if (argv[i] && *argv[i] != '-') {            argv[j++] = argv[i];            continue;        }        QByteArray arg(argv[i]);        if (arg == "-display") {            if (++i < argc && !X11->display)                X11->displayName = argv[i];        } else if (arg == "-fn" || arg == "-font") {            if (++i < argc)                appFont = argv[i];        } else if (arg == "-bg" || arg == "-background") {            if (++i < argc)                appBGCol = argv[i];        } else if (arg == "-btn" || arg == "-button") {            if (++i < argc)                appBTNCol = argv[i];        } else if (arg == "-fg" || arg == "-foreground") {            if (++i < argc)                appFGCol = argv[i];        } else if (arg == "-name") {            if (++i < argc)                appName = argv[i];        } else if (arg == "-title") {            if (++i < argc)                mwTitle = argv[i];        } else if (arg == "-geometry") {            if (++i < argc)                mwGeometry = argv[i];        } else if (arg == "-im") {            if (++i < argc)                qt_ximServer = argv[i];#if 0        } else if (arg == "-noxim") {            noxim=true;#endif        } else if (arg == "-iconic") {            mwIconic = !mwIconic;        } else if (arg == "-ncols") {   // xv and netscape use this name            if (++i < argc)                X11->color_count = qMax(0,atoi(argv[i]));        } else if (arg == "-visual") {  // xv and netscape use this name            if (++i < argc && !X11->visual) {                QString s = QString::fromLocal8Bit(argv[i]).toLower();                if (s == QLatin1String("staticgray"))                    X11->visual_class = StaticGray;                else if (s == QLatin1String("grayscale"))                    X11->visual_class = XGrayScale;                else if (s == QLatin1String("staticcolor"))                    X11->visual_class = StaticColor;                else if (s == QLatin1String("pseudocolor"))                    X11->visual_class = PseudoColor;                else if (s == QLatin1String("truecolor"))                    X11->visual_class = TrueColor;                else if (s == QLatin1String("directcolor"))                    X11->visual_class = DirectColor;                else                    X11->visual_id = static_cast<int>(strtol(argv[i], 0, 0));            }#ifndef QT_NO_XIM        } else if (arg == "-inputstyle/") {            if (++i < argc) {                QString s = QString::fromLocal8Bit(argv[i]).toLower();                if (s == QLatin1String("onthespot"))                    qt_xim_preferred_style = XIMPreeditCallbacks |                                             XIMStatusNothing;                else if (s == QLatin1String("overthespot"))                    qt_xim_preferred_style = XIMPreeditPosition |                                             XIMStatusNothing;                else if (s == QLatin1String("offthespot"))                    qt_xim_preferred_style = XIMPreeditArea |                                             XIMStatusArea;                else if (s == QLatin1String("root"))                    qt_xim_preferred_style = XIMPreeditNothing |                                             XIMStatusNothing;            }#endif        } else if (arg == "-cmap") {    // xv uses this name            if (!X11->colormap)                X11->custom_cmap = true;        }#if defined(QT_DEBUG)        else if (arg == "-sync")            appSync = !appSync;        else if (arg == "-nograb")            appNoGrab = !appNoGrab;        else if (arg == "-dograb")            appDoGrab = !appDoGrab;#endif        else            argv[j++] = argv[i];    }    priv->argc = j;#if defined(QT_DEBUG) && defined(Q_OS_LINUX)    if (!appNoGrab && !appDoGrab) {        QString s;        s.sprintf("/proc/%d/cmdline", getppid());        QFile f(s);        if (f.open(QIODevice::ReadOnly)) {            s.clear();            char c;            while (f.getChar(&c) && c) {                if (c == '/')                    s.clear();                else                    s += QLatin1Char(c);            }            if (s == QLatin1String("gdb")) {                appNoGrab = true;                qDebug("Qt: gdb: -nograb added to command-line options.\n"                       "\t Use the -dograb option to enforce grabbing.");            }            f.close();        }    }#endif    // Connect to X server    if (qt_is_gui_used && !X11->display) {        if ((X11->display = XOpenDisplay(X11->displayName)) == 0) {            qWarning("%s: cannot connect to X server %s", appName,                     XDisplayName(X11->displayName));            QApplicationPrivate::reset_instance_pointer();            exit(1);        }        if (appSync)                                // if "-sync" argument            XSynchronize(X11->display, true);    }    // Common code, regardless of whether display is foreign.    // Get X parameters

⌨️ 快捷键说明

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