void LayoutManager::addMenu(IMenu& menu) { dynamicMenus_.push_back(&menu); auto window = getWindow(menu.windowId()); if (window == nullptr) { return; } for (auto actionIt = actions_.begin(); actionIt != actions_.end(); ++actionIt) { auto action = actionIt->action_; if (getWindow(action->windowId()) != window) { continue; } for (auto& path : action->paths()) { if (matchMenu(menu, path.c_str())) { menu.addAction(*action, path.c_str()); actionIt->menus_.insert(&menu); } } } }
//_____________________________________________ void SizeGrip::embed( void ) { #if OXYGEN_HAVE_X11 if( !QX11Info::isPlatformX11() ) return; auto c = m_decoration.data()->client().data(); xcb_window_t windowId = c->windowId(); if( windowId ) { /* find client's parent we want the size grip to be at the same level as the client in the stack */ xcb_window_t current = windowId; auto connection = QX11Info::connection(); xcb_query_tree_cookie_t cookie = xcb_query_tree_unchecked( connection, current ); ScopedPointer<xcb_query_tree_reply_t> tree(xcb_query_tree_reply( connection, cookie, nullptr ) ); if( !tree.isNull() && tree->parent ) current = tree->parent; // reparent xcb_reparent_window( connection, winId(), current, 0, 0 ); setWindowTitle( "Oxygen::SizeGrip" ); } else { hide(); } #endif }
void PlastikClient::get_qubes_label() { WId wid = windowId(); Atom atom_label = XInternAtom (QX11Info::display(), "_QUBES_LABEL", True); if (atom_label == 0) { qubes_label = QubesLabels[QUBES_LABEL_DOM0]; return; } Atom actual_type; int actual_format; unsigned long nitems = 0, bytes_left; char *data = 0; int result = XGetWindowProperty (QX11Info::display(), wid, atom_label, 0L /* offset */, 1L /* length */, false /* don't delete */, XA_CARDINAL, &actual_type, &actual_format, &nitems, &bytes_left, (uchar**)(&data)); if (result != Success || nitems != 1) { // ERROR? Only Dom0 Windows don't have this property set... qubes_label = QubesLabels[QUBES_LABEL_DOM0]; return; } int label = (int)*data; qubes_label = QubesLabels[label]; }
void PlastikClient::get_qubes_vmname() { WId wid = windowId(); Atom atom_label = XInternAtom (QX11Info::display(), "_QUBES_VMNAME", True); if (atom_label == 0) { qubes_vmname = "[Dom0]"; return; } Atom actual_type; int actual_format; unsigned long nitems = 0, bytes_left; char *data = 0; int result = XGetWindowProperty (QX11Info::display(), wid, atom_label, 0L /* offset */, 0L /* length */, false /* don't delete */, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_left, (uchar**)(&data)); if (result != Success) { // ERROR? Only Dom0 Windows don't have this property set... qubes_vmname = "[Dom0]"; return; } if (bytes_left > 0) { int result = XGetWindowProperty (QX11Info::display(), wid, atom_label, 0L /* offset */, bytes_left /* length */, false /* don't delete */, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_left, (uchar**)(&data)); if (result != Success) { // ERROR? Only Dom0 Windows don't have this property set... qubes_vmname = "[ERROR Reading VM Name?!]"; return; } qubes_vmname = "[" + QString (data) + "]"; } else { // ERROR? Only Dom0 Windows don't have this property set... qubes_vmname = "[Dom0]"; return; } }
void LipstickCompositorWindow::refreshMouseRegion() { QWaylandSurface *s = surface(); if (s) { QVariantMap properties = s->windowProperties(); if (properties.contains(QLatin1String("MOUSE_REGION"))) { m_mouseRegion = s->windowProperties().value("MOUSE_REGION").value<QRegion>(); m_mouseRegionValid = true; if (LipstickCompositor::instance()->debug()) qDebug() << "Window" << windowId() << "mouse region set:" << m_mouseRegion; } else { m_mouseRegionValid = false; if (LipstickCompositor::instance()->debug()) qDebug() << "Window" << windowId() << "mouse region cleared"; } emit mouseRegionBoundsChanged(); } }
void LayoutManager::removeViews(IWindow& window) { for (auto viewIt = views_.begin(); viewIt != views_.end(); ++viewIt) { auto view = viewIt->first; if (getWindow(view->windowId()) != &window) { continue; } viewIt->second->removeView(*view); viewIt->second = nullptr; } }
//! [0] int main(int argc, char *argv[]) { QApplication app(argc, argv); if (app.arguments().count() != 2) { qFatal("Error - expected window id as argument"); return 1; } QString windowId(app.arguments()[1]); EmbedWidget window; window.embedInto(windowId.toULong()); window.show(); return app.exec(); }
void LxQtTaskGroup::contextMenuEvent(QContextMenuEvent *event) { setPopupVisible(false, true); mPreventPopup = true; if (windowId()) { LxQtTaskButton::contextMenuEvent(event); return; } QMenu menu(tr("Group")); QAction *a = menu.addAction(XdgIcon::fromTheme("process-stop"), tr("Close group")); connect(a, SIGNAL(triggered()), this, SLOT(closeGroup())); menu.exec(mapToGlobal(event->pos())); mPreventPopup = false; }
void LayoutManager::refreshViews(IWindow& window) { // go through every view associated with this window and try to re add it. // this will move the view between regions where appropriate for (auto viewIt = views_.begin(); viewIt != views_.end(); ++viewIt) { auto view = viewIt->first; if (getWindow(view->windowId()) != &window) { continue; } assert(views_[view] == nullptr); addView(*view, window); } }
void LayoutManager::refreshActions(IWindow& window) { // go through every action associated with this window and try to re add it. // this will move the action between menus where appropriate for (auto actionIt = actions_.begin(); actionIt != actions_.end(); ++actionIt) { auto action = actionIt->action_; if (getWindow(action->windowId()) != &window) { continue; } assert(actionIt->menus_.empty()); addAction(*actionIt, window); } }
void LayoutManager::removeActions(IWindow& window) { for (auto actionIt = actions_.begin(); actionIt != actions_.end(); ++actionIt) { auto action = actionIt->action_; if (getWindow(action->windowId()) != &window) { continue; } for (auto& menu : actionIt->menus_) { menu->removeAction(*action); } actionIt->menus_.clear(); } }
/* void onOpenWindow (in nsIXULWindow window); */ NS_IMETHODIMP nsWindowDataSource::OnOpenWindow(nsIXULWindow *window) { nsCAutoString windowId(NS_LITERAL_CSTRING("window-")); windowId.AppendInt(windowCount++, 10); nsCOMPtr<nsIRDFResource> windowResource; gRDFService->GetResource(windowId, getter_AddRefs(windowResource)); nsVoidKey key(window); mWindowResources.Put(&key, windowResource); // assert the new window if (mContainer) mContainer->AppendElement(windowResource); return NS_OK; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QString windowId(a.arguments()[1]); QVBoxLayout* layout = new QVBoxLayout; QX11EmbedWidget *embed = new QX11EmbedWidget; embed -> setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); SBBadChild w; layout -> addWidget(&w); embed -> setLayout(layout); embed -> embedInto(windowId.toULong()); embed -> show(); return a.exec(); }
void LXQtTaskButton::refreshIconGeometry(QRect const & geom) { NETWinInfo info(QX11Info::connection(), windowId(), (WId) QX11Info::appRootWindow(), NET::WMIconGeometry, 0); NETRect const curr = info.iconGeometry(); if (curr.pos.x != geom.x() || curr.pos.y != geom.y() || curr.size.width != geom.width() || curr.size.height != geom.height()) { NETRect nrect; nrect.pos.x = geom.x(); nrect.pos.y = geom.y(); nrect.size.height = geom.height(); nrect.size.width = geom.width(); info.setIconGeometry(nrect); } }
void LipstickCompositorWindow::refreshGrabbedKeys() { QWaylandSurface *s = surface(); if (s) { const QStringList grabbedKeys = s->windowProperties().value( QLatin1String("GRABBED_KEYS")).value<QStringList>(); if (m_grabbedKeys.isEmpty() && !grabbedKeys.isEmpty()) { qApp->installEventFilter(this); } else if (!m_grabbedKeys.isEmpty() && grabbedKeys.isEmpty()) { qApp->removeEventFilter(this); } m_grabbedKeys.clear(); foreach (const QString &key, grabbedKeys) m_grabbedKeys.append(key.toInt()); if (LipstickCompositor::instance()->debug()) qDebug() << "Window" << windowId() << "grabbed keys changed:" << grabbedKeys; } }
void LXQtTaskGroup::contextMenuEvent(QContextMenuEvent *event) { setPopupVisible(false, true); mPreventPopup = true; if (windowId()) { LXQtTaskButton::contextMenuEvent(event); return; } QMenu * menu = new QMenu(tr("Group")); menu->setAttribute(Qt::WA_DeleteOnClose); QAction *a = menu->addAction(XdgIcon::fromTheme("process-stop"), tr("Close group")); connect(a, SIGNAL(triggered()), this, SLOT(closeGroup())); connect(menu, &QMenu::aboutToHide, [this] { mPreventPopup = false; }); menu->setGeometry(mPlugin->panel()->calculatePopupWindowPos(mapToGlobal(event->pos()), menu->sizeHint())); mPlugin->willShowWindow(menu); menu->show(); }
//_____________________________________________ void SizeGrip::sendMoveResizeEvent( QPoint position ) { #if OXYGEN_HAVE_X11 if( !QX11Info::isPlatformX11() ) return; // pointer to connection auto connection( QX11Info::connection() ); // client auto c = m_decoration.data()->client().data(); /* get root position matching position need to use xcb because the embedding of the widget breaks QT's mapToGlobal and other methods */ QPoint rootPosition( position ); xcb_get_geometry_cookie_t cookie( xcb_get_geometry( connection, winId() ) ); ScopedPointer<xcb_get_geometry_reply_t> reply( xcb_get_geometry_reply( connection, cookie, 0x0 ) ); if( reply ) { // translate coordinates xcb_translate_coordinates_cookie_t coordCookie( xcb_translate_coordinates( connection, winId(), reply.data()->root, -reply.data()->border_width, -reply.data()->border_width ) ); ScopedPointer< xcb_translate_coordinates_reply_t> coordReply( xcb_translate_coordinates_reply( connection, coordCookie, 0x0 ) ); if( coordReply ) { rootPosition.rx() += coordReply.data()->dst_x; rootPosition.ry() += coordReply.data()->dst_y; } } // move/resize atom if( !m_moveResizeAtom ) { // create atom if not found const QString atomName( "_NET_WM_MOVERESIZE" ); xcb_intern_atom_cookie_t cookie( xcb_intern_atom( connection, false, atomName.size(), qPrintable( atomName ) ) ); ScopedPointer<xcb_intern_atom_reply_t> reply( xcb_intern_atom_reply( connection, cookie, 0x0 ) ); m_moveResizeAtom = reply ? reply->atom:0; } if( !m_moveResizeAtom ) return; // button release event xcb_button_release_event_t releaseEvent; memset(&releaseEvent, 0, sizeof(releaseEvent)); releaseEvent.response_type = XCB_BUTTON_RELEASE; releaseEvent.event = winId(); releaseEvent.child = XCB_WINDOW_NONE; releaseEvent.root = QX11Info::appRootWindow(); releaseEvent.event_x = position.x(); releaseEvent.event_y = position.y(); releaseEvent.root_x = rootPosition.x(); releaseEvent.root_y = rootPosition.y(); releaseEvent.detail = XCB_BUTTON_INDEX_1; releaseEvent.state = XCB_BUTTON_MASK_1; releaseEvent.time = XCB_CURRENT_TIME; releaseEvent.same_screen = true; xcb_send_event( connection, false, winId(), XCB_EVENT_MASK_BUTTON_RELEASE, reinterpret_cast<const char*>(&releaseEvent)); xcb_ungrab_pointer( connection, XCB_TIME_CURRENT_TIME ); // move resize event xcb_client_message_event_t clientMessageEvent; memset(&clientMessageEvent, 0, sizeof(clientMessageEvent)); clientMessageEvent.response_type = XCB_CLIENT_MESSAGE; clientMessageEvent.type = m_moveResizeAtom; clientMessageEvent.format = 32; clientMessageEvent.window = c->windowId(); clientMessageEvent.data.data32[0] = rootPosition.x(); clientMessageEvent.data.data32[1] = rootPosition.y(); clientMessageEvent.data.data32[2] = 4; // bottom right clientMessageEvent.data.data32[3] = Qt::LeftButton; clientMessageEvent.data.data32[4] = 0; xcb_send_event( connection, false, QX11Info::appRootWindow(), XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, reinterpret_cast<const char*>(&clientMessageEvent) ); xcb_flush( connection ); #endif }