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

📄 qapplication_x11.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                                       effects.contains(QLatin1String("fadetooltip")));        QApplication::setEffectEnabled(Qt::UI_AnimateToolBox,                                       effects.contains(QLatin1String("animatetoolbox")));    }}// update the supported arraystatic void qt_get_net_supported(){    Atom type;    int format;    long offset = 0;    unsigned long nitems, after;    unsigned char *data = 0;    int e = XGetWindowProperty(X11->display, QX11Info::appRootWindow(),                               ATOM(_NET_SUPPORTED), 0, 0,                               False, XA_ATOM, &type, &format, &nitems, &after, &data);    if (data)        XFree(data);    if (X11->net_supported_list)        delete [] X11->net_supported_list;    X11->net_supported_list = 0;    if (e == Success && type == XA_ATOM && format == 32) {        QBuffer ts;        ts.open(QIODevice::WriteOnly);        while (after > 0) {            XGetWindowProperty(X11->display, QX11Info::appRootWindow(),                               ATOM(_NET_SUPPORTED), offset, 1024,                               False, XA_ATOM, &type, &format, &nitems, &after, &data);            if (type == XA_ATOM && format == 32) {                ts.write(reinterpret_cast<char *>(data), nitems * sizeof(long));                offset += nitems;            } else                after = 0;            if (data)                XFree(data);        }        // compute nitems        QByteArray buffer(ts.buffer());        nitems = buffer.size() / sizeof(Atom);        X11->net_supported_list = new Atom[nitems + 1];        Atom *a = (Atom *) buffer.data();        uint i;        for (i = 0; i < nitems; i++)            X11->net_supported_list[i] = a[i];        X11->net_supported_list[nitems] = 0;    }}bool QX11Data::isSupportedByWM(Atom atom){    if (!X11->net_supported_list)        return false;    bool supported = false;    int i = 0;    while (X11->net_supported_list[i] != 0) {        if (X11->net_supported_list[i++] == atom) {            supported = true;            break;        }    }    return supported;}// update the virtual roots arraystatic void qt_get_net_virtual_roots(){    if (X11->net_virtual_root_list)        delete [] X11->net_virtual_root_list;    X11->net_virtual_root_list = 0;    if (!X11->isSupportedByWM(ATOM(_NET_VIRTUAL_ROOTS)))        return;    Atom type;    int format;    long offset = 0;    unsigned long nitems, after;    unsigned char *data;    int e = XGetWindowProperty(X11->display, QX11Info::appRootWindow(),                               ATOM(_NET_VIRTUAL_ROOTS), 0, 0,                               False, XA_ATOM, &type, &format, &nitems, &after, &data);    if (data)        XFree(data);    if (e == Success && type == XA_ATOM && format == 32) {        QBuffer ts;        ts.open(QIODevice::WriteOnly);        while (after > 0) {            XGetWindowProperty(X11->display, QX11Info::appRootWindow(),                               ATOM(_NET_VIRTUAL_ROOTS), offset, 1024,                               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){    Q_ASSERT(tlw->testAttribute(Qt::WA_WState_Created));    XChangeProperty(X11->display, tlw->internalWinId(), 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 *****************************************************************************/#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){    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_version = 0;    // XFIXES    X11->use_xfixes = false;    X11->xfixes_major = 0;    X11->xfixes_eventbase = 0;    X11->xfixes_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;    // Fontconfig    X11->has_fontconfig = false;#if !defined(QT_NO_FONTCONFIG)    if (qgetenv("QT_X11_NO_FONTCONFIG").isNull())        X11->has_fontconfig = FcInit();    X11->fc_antialias = true;#endif#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];

⌨️ 快捷键说明

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