bool DockApplet::init() { updateClientList(); updateActiveWindow(); for(int i = 0; i < m_dockItems.size(); i++) m_dockItems[i]->moveInstantly(); return true; }
bool Compositor::xcbEvent(const xcb_property_notify_event_t *e) { if (e->window == root_) { if (e->atom == ewmh_._NET_ACTIVE_WINDOW) { updateActiveWindow(); } return false; } return xcbDispatchEvent(e); }
void Blackbox::setFocusedWindow(BlackboxWindow *win) { if (focused_window && focused_window == win) // nothing to do return; if (win && !win->isIconic()) { // the active screen is the one with the newly focused window... active_screen = win->screen(); focused_window = win; } else { // nothing has focus focused_window = 0; assert(active_screen != 0); XSetInputFocus(XDisplay(), active_screen->noFocusWindow(), RevertToPointerRoot, XTime()); } updateActiveWindow(); }
void Compositor::addChildWindow(xcb_window_t window) { Q_ASSERT(window != root_); Q_ASSERT(!overlayWindow_ || window != overlayWindow_->winId()); if (windows_.contains(window)) { return; } QSharedPointer<ClientWindow> w(new ClientWindow(&ewmh_, window)); // TODO: replace with ::create if (w->isValid() && w->windowClass() != XCB_WINDOW_CLASS_INPUT_ONLY) { windows_.insert(window, w); connect(w.data(), SIGNAL(pixmapChanged(WindowPixmap*)), SLOT(registerPixmap(WindowPixmap*))); connect(w.data(), SIGNAL(stackingOrderChanged()), SLOT(restack())); restack(); if (initFinished_) { Q_EMIT windowCreated(w.data()); } else { QMetaObject::invokeMethod(this, "windowCreated", Qt::QueuedConnection, Q_ARG(ClientWindow*, w.data())); } updateActiveWindow(); }
Compositor::Compositor() : connection_(QX11Info::connection()), root_(QX11Info::appRootWindow()), damageExt_(xcb_get_extension_data(connection_, &xcb_damage_id)), initFinished_(false) { qRegisterMetaType<ClientWindow *>(); Q_ASSERT(QCoreApplication::instance()); QCoreApplication::instance()->installNativeEventFilter(this); auto ewmhCookie = xcb_ewmh_init_atoms(connection_, &ewmh_); if (!xcb_ewmh_init_atoms_replies(&ewmh_, ewmhCookie, Q_NULLPTR)) { qFatal("Cannot init EWMH"); } auto wmCmCookie = xcb_ewmh_get_wm_cm_owner_unchecked(&ewmh_, QX11Info::appScreen()); xcb_window_t wmCmOwnerWin = XCB_NONE; if (!xcb_ewmh_get_wm_cm_owner_reply(&ewmh_, wmCmCookie, &wmCmOwnerWin, Q_NULLPTR)) { qFatal("Cannot check _NET_WM_CM_Sn"); } if (wmCmOwnerWin) { qFatal("Another compositing manager is already running"); } auto attributesCookie = xcb_get_window_attributes_unchecked(connection_, root_); auto damageQueryVersionCookie = xcb_damage_query_version_unchecked(connection_, 1, 1); auto overlayWindowCookie = xcb_composite_get_overlay_window_unchecked(connection_, root_); auto attributes = xcbReply(xcb_get_window_attributes_reply(connection_, attributesCookie, Q_NULLPTR)); if (!attributes) { qFatal("Cannot get root window attributes"); } auto newEventMask = attributes->your_event_mask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE; xcb_change_window_attributes(connection_, root_, XCB_CW_EVENT_MASK, &newEventMask); auto treeCookie = xcb_query_tree_unchecked(connection_, root_); auto rootGeometryCookie = xcb_get_geometry_unchecked(connection_, root_); auto damageVersion = xcbReply(xcb_damage_query_version_reply(connection_, damageQueryVersionCookie, Q_NULLPTR)); if (!damageVersion) { qFatal("Cannot query version of Damage extension"); } auto overlayWindow = xcbReply(xcb_composite_get_overlay_window_reply(connection_, overlayWindowCookie, Q_NULLPTR)); if (!overlayWindow) { qFatal("Cannot get overlay window"); } overlayWindow_.reset(QWindow::fromWinId(overlayWindow->overlay_win)); auto region = xcb_generate_id(connection_); xcb_xfixes_create_region(connection_, region, 0, Q_NULLPTR); xcb_xfixes_set_window_shape_region(connection_, overlayWindow->overlay_win, XCB_SHAPE_SK_INPUT, 0, 0, region); xcb_xfixes_destroy_region(connection_, region); xcb_composite_redirect_subwindows(connection_, root_, XCB_COMPOSITE_REDIRECT_MANUAL); auto rootGeometry = xcbReply(xcb_get_geometry_reply(connection_, rootGeometryCookie, Q_NULLPTR)); if (!rootGeometry) { qFatal("Cannot query root window geometry"); } rootGeometry_ = QRect(rootGeometry->x, rootGeometry->y, rootGeometry->width, rootGeometry->height); auto tree = xcbReply(xcb_query_tree_reply(connection_, treeCookie, Q_NULLPTR)); if (!tree) { qFatal("Cannot query window tree"); } auto children = xcb_query_tree_children(tree.get()); for (int i = 0; i < xcb_query_tree_children_length(tree.get()); i++) { addChildWindow(children[i]); } updateActiveWindow(); initFinished_ = true; }
WindowsModel::WindowsModel (QObject *parent) : QAbstractItemModel (parent) , CurrentDesktop_ (Util::XWrapper::Instance ().GetCurrentDesktop ()) , ImageProvider_ (new TaskbarImageProvider (QIcon::fromTheme ("xorg"))) { auto& w = Util::XWrapper::Instance (); auto windows = w.GetWindows (); for (auto wid : windows) AddWindow (wid, w); connect (&w, SIGNAL (windowListChanged ()), this, SLOT (updateWinList ())); connect (&w, SIGNAL (activeWindowChanged ()), this, SLOT (updateActiveWindow ())); connect (&w, SIGNAL (windowNameChanged (ulong)), this, SLOT (updateWindowName (ulong))); connect (&w, SIGNAL (windowIconChanged (ulong)), this, SLOT (updateWindowIcon (ulong))); connect (&w, SIGNAL (windowStateChanged (ulong)), this, SLOT (updateWindowState (ulong))); connect (&w, SIGNAL (windowActionsChanged (ulong)), this, SLOT (updateWindowActions (ulong))); connect (&w, SIGNAL (windowDesktopChanged (ulong)), this, SLOT (updateWindowDesktop (ulong))); connect (&w, SIGNAL (desktopChanged ()), this, SLOT (updateCurrentDesktop ())); QHash<int, QByteArray> roleNames; roleNames [Role::WindowName] = "windowName"; roleNames [Role::WindowID] = "windowID"; roleNames [Role::IconGenID] = "iconGenID"; roleNames [Role::IsCurrentDesktop] = "isCurrentDesktop"; roleNames [Role::IsActiveWindow] = "isActiveWindow"; roleNames [Role::IsMinimizedWindow] = "isMinimizedWindow"; setRoleNames (roleNames); int eventBase, errorBase; if (XCompositeQueryExtension (w.GetDisplay (), &eventBase, &errorBase)) { int major = 0, minor = 2; XCompositeQueryVersion (w.GetDisplay (), &major, &minor); if (major > 0 || minor >= 2) qDebug () << "all good, has NamePixmap"; } }