Ejemplo n.º 1
0
QTC_EXPORT void
qtcX11ShadowInstallWithMargin(xcb_window_t win, const int margins[4])
{
    QTC_RET_IF_FAIL(win);
    if (qtcUnlikely(!margins)) {
        qtcX11ShadowInstall(win);
        return;
    }
    // In principle, I should check for _KDE_NET_WM_SHADOW in _NET_SUPPORTED.
    // However, it's complicated and we will gain nothing.
    xcb_atom_t atom = qtc_x11_kde_net_wm_shadow;
    if (qtc_disp) {
        unsigned long shadow_data[8 + 4];
        memcpy(shadow_data, shadow_data_xlib, 12 * sizeof(unsigned long));
        for (int i = 0;i < 4;i++) {
            shadow_data[i + 8] -= margins[i];
        }
        XChangeProperty(qtc_disp, win, atom, XA_CARDINAL, 32,
                        PropModeReplace, (unsigned char*)shadow_data, 12);
    } else {
        uint32_t shadow_data[8 + 4];
        memcpy(shadow_data, shadow_data_xcb, 12 * sizeof(uint32_t));
        for (int i = 0;i < 4;i++) {
            shadow_data[i + 8] -= margins[i];
        }
        qtcX11ChangeProperty(XCB_PROP_MODE_REPLACE, win, atom,
                             XCB_ATOM_CARDINAL, 32, 12, shadow_data);
        qtcX11Flush();
    }
}
Ejemplo n.º 2
0
bool
ShadowHelper::installX11Shadows(QWidget *widget)
{
    if (WId wid = qtcGetQWidgetWid(widget)) {
        qtcX11ShadowInstall(wid);
        return true;
    }
    return false;
}
Ejemplo n.º 3
0
bool
ShadowHelper::installX11Shadows(QWidget *widget)
{
    if (WId wid = qtcGetWid(widget)) {
        if (widget->windowType() == Qt::ToolTip &&
            widget->inherits("QBalloonTip")) {
            bool atTop = true;
            int margin = qtcGetBalloonMargin(widget, &atTop);
            int margins[4] = {0, 0, 0, 0};
            // KWin's shadows margin order is top, right, bottom, left..
            margins[atTop ? 0 : 2] = margin;
            qtcX11ShadowInstall(wid, margins);
        } else {
            qtcX11ShadowInstall(wid);
        }
        return true;
    }
    return false;
}
Ejemplo n.º 4
0
bool
ShadowHelper::installX11Shadows(QWidget *widget)
{
    // DO NOT condition compile on QTC_ENABLE_X11.
    // There's no direct linkage on X11 and the following code will just do
    // nothing if X11 is not enabled (either at compile time or at run time).
    QTC_RET_IF_FAIL(qtcX11Enabled(), false);
    if (WId wid = qtcGetWid(widget)) {
        if (widget->windowType() == Qt::ToolTip &&
            widget->inherits("QBalloonTip")) {
            bool atTop = true;
            int margin = qtcGetBalloonMargin(widget, &atTop);
            int margins[4] = {0, 0, 0, 0};
            // KWin's shadows margin order is top, right, bottom, left..
            margins[atTop ? 0 : 2] = margin;
            qtcX11ShadowInstall(wid, margins);
        } else {
            qtcX11ShadowInstall(wid);
        }
        return true;
    }
    return false;
}