GraphicsClientItemsClient::GraphicsClientItemsClient(QGraphicsScene *scene_) :
    JackClient("GraphicsClientItemsClient"),
    scene(scene_),
    clientStyle(3),
    audioPortStyle(1),
    midiPortStyle(3),
    font("Helvetica", 12),
    contextName(RecursiveJackContext::getInstance()->getCurrentContext()->get_name())
{
    setCallProcess(false);
    setEmitPortSignals(true);
    setEmitClientSignals(true);
    activate();
    // get all clients and create visual representations for them:
    QStringList clientNames = getClients();
    for (int i = 0; i < clientNames.size(); i++) {
        onClientRegistered(clientNames[i]);
    }
    // make sure we're notified when clients are registered or unregistered:
    QObject::connect(this, SIGNAL(clientRegistered(QString)), this, SLOT(onClientRegistered(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(clientUnregistered(QString)), this, SLOT(onClientUnregistered(QString)), Qt::QueuedConnection);
    // the same for ports:
    QObject::connect(this, SIGNAL(portRegistered(QString,QString,int)), this, SLOT(onPortRegistered(QString,QString,int)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(portUnregistered(QString,QString,int)), this, SLOT(onPortRegistered(QString,QString,int)), Qt::QueuedConnection);
}
void XLibWindowManagerAdapterPrivate::onNewEvent()
{
    XSetErrorHandler(xErrorHandler);
    XSync(m_display, False);
    XEvent event;
    while (XPending(m_display)) {
        XNextEvent(m_display, &event);
        if (event.type == PropertyNotify
            && event.xproperty.atom == XInternAtom(m_display,
                                                   "_NET_CLIENT_LIST", False)) {
            //Window Event
            Window *clients;
            unsigned long len = 0;
            if (getClients(&clients, &len)) {
                if (len > m_numberOfClients) {
                    // A  window created
                    handleCreatedWindow(clients[len - 1]);
                } else if (len < m_numberOfClients) {
                    // A window destroyed
                    unsigned long i, j;
                    for (i = 0; i < m_numberOfClients; ++i) {
                        for (j = 0; j < len; ++j) {
                            if (m_clients[i] == clients[j]) {
                                break;
                            }
                        }
                        if (j == len && i < m_numberOfClients) {
                            handleDestroyedWindow(m_clients[i]);
                            break;
                        }
                    }
                } else {
                    // This is strange, but happens.
                    qWarning("A window neither created nor destroyed");
                }
                // Set new clients and the number of clients
                XFree(m_clients);
                m_clients = clients;
                m_numberOfClients = len;
            }
        }
        if (event.type == GenericEvent) {
            //Touch Event
            XGenericEventCookie *xcookie = &event.xcookie;
            if (!XGetEventData(m_display, xcookie)) {
                qWarning("Failed to get X generic event data\n");
                continue;
            }
            if (q_ptr->m_listener) {
                q_ptr->m_listener->onTouchEvent(xcookie);
                // In case TouchManager changes error handler
                XSetErrorHandler(xErrorHandler);
            }
            XFreeEventData(m_display, xcookie);
        }
    }
}
void XLibWindowManagerAdapterPrivate::dispatchOpenWindowEvents()
{
    Window root = XDefaultRootWindow(m_display);
    handleCreatedWindow(root);

    getClients(&m_clients, &m_numberOfClients);
    for (unsigned long i = 0; i < m_numberOfClients; ++i) {
        handleCreatedWindow(m_clients[i]);
    }
}
std::pair<std::shared_ptr<ClientPool>, std::vector<McrouterRouteHandlePtr>>
McRouteHandleProvider::makePool(const folly::dynamic& json) {
  checkLogic(json.isString() || json.isObject(),
             "Pool should be a string (name of pool) or an object");
  auto pool = poolFactory_.parsePool(json);
  std::vector<McrouterRouteHandlePtr> destinations;
  for (const auto& client : pool->getClients()) {
    auto pdstn = destinationMap_.fetch(*client);
    auto route = makeDestinationRoute(client, std::move(pdstn));
    destinations.push_back(std::move(route));
  }

  return std::make_pair(std::move(pool), std::move(destinations));
}
Exemple #5
0
void ProxyPlugin::clientData(TCPClient *client, ProxyData &cdata)
{
    for (unsigned i = 1;; i++){
        const char *proxyCfg = getClients(i);
        if ((proxyCfg == NULL) || (*proxyCfg == 0))
            break;
        ProxyData wdata(proxyCfg);
        if (wdata.Client.ptr && (clientName(client) == wdata.Client.ptr)){
            cdata = wdata;
            cdata.Default.bValue = false;
            set_str(&cdata.Client.ptr, clientName(client).c_str());
            return;
        }
    }
    cdata = data;
    set_str(&cdata.Client.ptr, clientName(client).c_str());
    cdata.Default.bValue = true;
    clear_list(&cdata.Clients);
}
void
CMSWindowsServerTaskBarReceiver::showStatus()
{
	// create the window
	createWindow();

	// lock self while getting status
	lock();

	// get the current status
	std::string status = getToolTip();

	// get the connect clients, if any
	const CClients& clients = getClients();

	// done getting status
	unlock();

	// update dialog
	HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
	SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
	child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
	SendMessage(child, LB_RESETCONTENT, 0, 0);
	for (CClients::const_iterator index = clients.begin();
							index != clients.end(); ) {
		const char* client = index->c_str();
		if (++index == clients.end()) {
			SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client);
		}
		else {
			SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client);
		}
	}

	if (!IsWindowVisible(m_window)) {
		// position it by the mouse
		POINT cursorPos;
		GetCursorPos(&cursorPos);
		RECT windowRect;
		GetWindowRect(m_window, &windowRect);
		int  x = cursorPos.x;
		int  y = cursorPos.y;
		int fw = GetSystemMetrics(SM_CXDLGFRAME);
		int fh = GetSystemMetrics(SM_CYDLGFRAME);
		int ww = windowRect.right  - windowRect.left;
		int wh = windowRect.bottom - windowRect.top;
		int sw = GetSystemMetrics(SM_CXFULLSCREEN);
		int sh = GetSystemMetrics(SM_CYFULLSCREEN);
		if (fw < 1) {
			fw = 1;
		}
		if (fh < 1) {
			fh = 1;
		}
		if (x + ww - fw > sw) {
			x -= ww - fw;
		}
		else {
			x -= fw;
		}
		if (x < 0) {
			x = 0;
		}
		if (y + wh - fh > sh) {
			y -= wh - fh;
		}
		else {
			y -= fh;
		}
		if (y < 0) {
			y = 0;
		}
		SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
							SWP_SHOWWINDOW);
	}
}