Exemple #1
0
DBusInterface::~DBusInterface()
{
    QDBusConnection::sessionBus().unregisterService(m_serviceName);
    // KApplication automatically also grabs org.kde.kwin, so it's often been used externally - ensure to free it as well
    QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.kwin"));
    xcb_delete_property(connection(), rootWindow(), atoms->kwin_dbus_service);
}
Exemple #2
0
EAPI void
ecore_x_window_prop_property_del(Ecore_X_Window win,
                                 Ecore_X_Atom   property)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   xcb_delete_property(_ecore_xcb_conn, win, property);
}
Exemple #3
0
/** Set opacity of a window.
 * \param win The window.
 * \param opacity Opacity of the window, between 0 and 1.
 */
void
xwindow_set_opacity(xcb_window_t win, double opacity)
{
    if(win)
    {
        if(opacity >= 0 && opacity <= 1)
        {
            uint32_t real_opacity = opacity * 0xffffffff;
            xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, win,
                                _NET_WM_WINDOW_OPACITY, XCB_ATOM_CARDINAL, 32, 1L, &real_opacity);
        }
        else
            xcb_delete_property(globalconf.connection, win, _NET_WM_WINDOW_OPACITY);
    }
}
Exemple #4
0
void XServerPinger::die(int)
{
    const char *wmcheck = "_NET_SUPPORTING_WM_CHECK";

    xcb_delete_property(xcb,
                        xcb_setup_roots_iterator(xcb_get_setup(xcb)).data->root,
                        xcb_intern_atom_reply(xcb,
                                              xcb_intern_atom(xcb,
                                                              False,
                                                              strlen(wmcheck),
                                                              wmcheck),
                                              NULL)->atom);
    xcb_flush(xcb);
    QCoreApplication::quit();
}
Exemple #5
0
static int
writable_callback(int fd, uint32_t mask, void *data)
{
	struct weston_wm *wm = data;
	unsigned char *property;
	int len, remainder;

	property = xcb_get_property_value(wm->property_reply);
	remainder = xcb_get_property_value_length(wm->property_reply) -
		wm->property_start;

	len = write(fd, property + wm->property_start, remainder);
	if (len == -1) {
		free(wm->property_reply);
		wm->property_reply = NULL;
		if (wm->property_source)
			wl_event_source_remove(wm->property_source);
		wm->property_source = NULL;
		close(fd);
		weston_log("write error to target fd: %m\n");
		return 1;
	}

	weston_log("wrote %d (chunk size %d) of %d bytes\n",
		wm->property_start + len,
		len, xcb_get_property_value_length(wm->property_reply));

	wm->property_start += len;
	if (len == remainder) {
		free(wm->property_reply);
		wm->property_reply = NULL;
		if (wm->property_source)
			wl_event_source_remove(wm->property_source);
		wm->property_source = NULL;

		if (wm->incr) {
			xcb_delete_property(wm->conn,
					    wm->selection_window,
					    wm->atom.wl_selection);
		} else {
			weston_log("transfer complete\n");
			close(fd);
		}
	}

	return 1;
}
Exemple #6
0
int
window_set_xproperty(lua_State *L, xcb_window_t window, int prop_idx, int value_idx)
{
    xproperty_t *prop = luaA_find_xproperty(L, prop_idx);
    xcb_atom_t type;
    uint8_t format;
    size_t len;
    uint32_t number;
    const void *data;

    if(lua_isnil(L, value_idx))
    {
        xcb_delete_property(globalconf.connection, window, prop->atom);
    } else {
        if(prop->type == PROP_STRING)
        {
            data = luaL_checklstring(L, value_idx, &len);
            type = UTF8_STRING;
            format = 8;
        } else if(prop->type == PROP_NUMBER || prop->type == PROP_BOOLEAN)
        {
            if (prop->type == PROP_NUMBER)
                number = luaA_checkinteger_range(L, value_idx, 0, UINT32_MAX);
            else
                number = luaA_checkboolean(L, value_idx);
            data = &number;
            len = 1;
            type = XCB_ATOM_CARDINAL;
            format = 32;
        } else
            fatal("Got an xproperty with invalid type");

        xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, window,
                            prop->atom, type, format, len, data);
    }
    return 0;
}
Exemple #7
0
/** Get the current X selection buffer.
 * \param L The Lua VM state.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lreturn A string with the current X selection buffer.
 */
int
luaA_selection_get(lua_State *L)
{
    if(selection_window == XCB_NONE)
    {
        xcb_screen_t *screen = xutil_screen_get(globalconf.connection, globalconf.default_screen);
        uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
        uint32_t values[] = { screen->black_pixel, 1, XCB_EVENT_MASK_PROPERTY_CHANGE };

        selection_window = xcb_generate_id(globalconf.connection);

        xcb_create_window(globalconf.connection, screen->root_depth, selection_window, screen->root,
                          0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT, screen->root_visual,
                          mask, values);
    }

    xcb_convert_selection(globalconf.connection, selection_window,
                          PRIMARY, UTF8_STRING, XSEL_DATA, XCB_CURRENT_TIME);
    xcb_flush(globalconf.connection);

    xcb_generic_event_t *event;

    while(true)
    {
        event = xcb_wait_for_event(globalconf.connection);

        if(!event)
            return 0;

        if(XCB_EVENT_RESPONSE_TYPE(event) != XCB_SELECTION_NOTIFY)
        {
            /* \todo Eventually, this may be rewritten with adding a static
             * buffer, then a event handler for XCB_SELECTION_NOTIFY, then call
             * xcb_event_poll_for_event_loop() and awesome_refresh(),
             * then check if some static buffer has been filled with data.
             * If yes, that'd be the xsel data, otherwise, re-loop.
             * Anyway that's still brokes the socket or D-Bus, so maybe using
             * ev_loop() would be even better.
             */
            xcb_event_handle(&globalconf.evenths, event);
            p_delete(&event);
            awesome_refresh();
            continue;
        }

        xcb_selection_notify_event_t *event_notify =
            (xcb_selection_notify_event_t *) event;

        if(event_notify->selection == PRIMARY
           && event_notify->property != XCB_NONE)
        {
            xcb_get_text_property_reply_t prop;
            xcb_get_property_cookie_t cookie =
                xcb_get_text_property(globalconf.connection,
                                      event_notify->requestor,
                                      event_notify->property);

            if(xcb_get_text_property_reply(globalconf.connection,
                                           cookie, &prop, NULL))
            {
                lua_pushlstring(L, prop.name, prop.name_len);

                xcb_get_text_property_reply_wipe(&prop);

                xcb_delete_property(globalconf.connection,
                                    event_notify->requestor,
                                    event_notify->property);

                p_delete(&event);

                return 1;
            }
            else
                break;
        }
    }

    p_delete(&event);
    return 0;
}
Exemple #8
0
EAPI void
ecore_x_window_prop_property_del(Ecore_X_Window window,
                                 Ecore_X_Atom   property)
{
   xcb_delete_property(_ecore_xcb_conn, window, property);
} /* ecore_x_window_prop_property_del */
Exemple #9
0
Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
{
    Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));

    setNetWmWindowTypes(flags);

    if (type == Qt::ToolTip)
        flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;
    if (type == Qt::Popup)
        flags |= Qt::X11BypassWindowManagerHint;

    bool topLevel = (flags & Qt::Window);
    bool popup = (type == Qt::Popup);
    bool dialog = (type == Qt::Dialog
                   || type == Qt::Sheet);
    bool desktop = (type == Qt::Desktop);
    bool tool = (type == Qt::Tool || type == Qt::SplashScreen
                 || type == Qt::ToolTip || type == Qt::Drawer);

    Q_UNUSED(topLevel);
    Q_UNUSED(dialog);
    Q_UNUSED(desktop);
    Q_UNUSED(tool);

    bool tooltip = (type == Qt::ToolTip);

    QtMWMHints mwmhints;
    mwmhints.flags = 0L;
    mwmhints.functions = 0L;
    mwmhints.decorations = 0;
    mwmhints.input_mode = 0L;
    mwmhints.status = 0L;

    if (type != Qt::SplashScreen) {
        mwmhints.flags |= MWM_HINTS_DECORATIONS;

        bool customize = flags & Qt::CustomizeWindowHint;
        if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
            mwmhints.decorations |= MWM_DECOR_BORDER;
            mwmhints.decorations |= MWM_DECOR_RESIZEH;

            if (flags & Qt::WindowTitleHint)
                mwmhints.decorations |= MWM_DECOR_TITLE;

            if (flags & Qt::WindowSystemMenuHint)
                mwmhints.decorations |= MWM_DECOR_MENU;

            if (flags & Qt::WindowMinimizeButtonHint) {
                mwmhints.decorations |= MWM_DECOR_MINIMIZE;
                mwmhints.functions |= MWM_FUNC_MINIMIZE;
            }

            if (flags & Qt::WindowMaximizeButtonHint) {
                mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
                mwmhints.functions |= MWM_FUNC_MAXIMIZE;
            }

            if (flags & Qt::WindowCloseButtonHint)
                mwmhints.functions |= MWM_FUNC_CLOSE;
        }
    } else {
        // if type == Qt::SplashScreen
        mwmhints.decorations = MWM_DECOR_ALL;
    }

    if (mwmhints.functions != 0) {
        mwmhints.flags |= MWM_HINTS_FUNCTIONS;
        mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
    } else {
        mwmhints.functions = MWM_FUNC_ALL;
    }

    if (!(flags & Qt::FramelessWindowHint)
            && flags & Qt::CustomizeWindowHint
            && flags & Qt::WindowTitleHint
            && !(flags &
                 (Qt::WindowMinimizeButtonHint
                  | Qt::WindowMaximizeButtonHint
                  | Qt::WindowCloseButtonHint)))
    {
        // a special case - only the titlebar without any button
        mwmhints.flags = MWM_HINTS_FUNCTIONS;
        mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
        mwmhints.decorations = 0;
    }

    if (mwmhints.flags != 0l) {
        Q_XCB_CALL(xcb_change_property(xcb_connection(),
                                       XCB_PROP_MODE_REPLACE,
                                       m_window,
                                       atom(QXcbAtom::_MOTIF_WM_HINTS),
                                       atom(QXcbAtom::_MOTIF_WM_HINTS),
                                       32,
                                       5,
                                       &mwmhints));
    } else {
        Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS)));
    }

    if (popup || tooltip) {
        const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER;
        const quint32 values[] = { true, true };

        Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
    }

    return QPlatformWindow::setWindowFlags(flags);
}
Exemple #10
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setApplicationDisplayName(QStringLiteral("Screen Edge Show Test App"));

    QScopedPointer<QWidget> widget(new QWidget(nullptr, Qt::FramelessWindowHint));

    KWin::Xcb::Atom atom(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"));

    uint32_t value = 2;
    QPushButton *hideWindowButton = new QPushButton(QStringLiteral("Hide"), widget.data());
    QObject::connect(hideWindowButton, &QPushButton::clicked, [&widget, &atom, &value]() {
        xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, widget->winId(), atom, XCB_ATOM_CARDINAL, 32, 1, &value);
    });
    QPushButton *hideAndRestoreButton = new QPushButton(QStringLiteral("Hide and Restore after 10 sec"), widget.data());
    QTimer *restoreTimer = new QTimer(hideAndRestoreButton);
    restoreTimer->setSingleShot(true);
    QObject::connect(hideAndRestoreButton, &QPushButton::clicked, [&widget, &atom, &value, restoreTimer]() {
        xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, widget->winId(), atom, XCB_ATOM_CARDINAL, 32, 1, &value);
        restoreTimer->start(10000);
    });
    QObject::connect(restoreTimer, &QTimer::timeout, [&widget, &atom]() {
        xcb_delete_property(QX11Info::connection(), widget->winId(), atom);
    });

    QToolButton *edgeButton = new QToolButton(widget.data());
    edgeButton->setText(QStringLiteral("Edge"));
    edgeButton->setPopupMode(QToolButton::MenuButtonPopup);
    QMenu *edgeButtonMenu = new QMenu(edgeButton);
    QObject::connect(edgeButtonMenu->addAction("Top"), &QAction::triggered, [&widget, &value]() {
        const QRect geo = QGuiApplication::primaryScreen()->geometry();
        widget->setGeometry(geo.x(), geo.y(), geo.width(), 100);
        value = 0;
    });
    QObject::connect(edgeButtonMenu->addAction("Right"), &QAction::triggered, [&widget, &value]() {
        const QRect geo = QGuiApplication::primaryScreen()->geometry();
        widget->setGeometry(geo.x() + geo.width() - 100, geo.y(), 100, geo.height());
        value = 1;
    });
    QObject::connect(edgeButtonMenu->addAction("Bottom"), &QAction::triggered, [&widget, &value]() {
        const QRect geo = QGuiApplication::primaryScreen()->geometry();
        widget->setGeometry(geo.x(), geo.y() + geo.height() - 100, geo.width(), 100);
        value = 2;
    });
    QObject::connect(edgeButtonMenu->addAction("Left"), &QAction::triggered, [&widget, &value]() {
        const QRect geo = QGuiApplication::primaryScreen()->geometry();
        widget->setGeometry(geo.x(), geo.y(), 100, geo.height());
        value = 3;
    });
    edgeButtonMenu->addSeparator();
    QObject::connect(edgeButtonMenu->addAction("Floating"), &QAction::triggered, [&widget, &value]() {
        const QRect geo = QGuiApplication::primaryScreen()->geometry();
        widget->setGeometry(QRect(geo.center(), QSize(100, 100)));
        value = 4;
    });
    edgeButton->setMenu(edgeButtonMenu);

    QHBoxLayout *layout = new QHBoxLayout(widget.data());
    layout->addWidget(hideWindowButton);
    layout->addWidget(hideAndRestoreButton);
    layout->addWidget(edgeButton);
    widget->setLayout(layout);

    const QRect geo = QGuiApplication::primaryScreen()->geometry();
    widget->setGeometry(geo.x(), geo.y() + geo.height() - 100, geo.width(), 100);
    widget->show();

    return app.exec();
}