示例#1
0
bool EventsMonitor::initialize(dictionary * configuration)
{
    const char* uri = getStringProperty(configuration, monitorUri);
    EventsMonitor::host = getStringProperty(configuration, redisHost);
    EventsMonitor::port = getIntProperty(configuration, redisPort);
    EventsMonitor::machinePort = getStringProperty(configuration, serverPort);

    bool initialized = true;

    // connect to libvirt
    if (!connect(uri, callback))
    {
        LOG("Unable to connect to hypervisor uri '%s'", uri);
        initialized = false;
    }

    if (initialized)
    {
        EventsMonitor::machineAddress = getIP(EventsMonitor::host, EventsMonitor::port);
        initialized = !EventsMonitor::machineAddress.empty();
    }

    if (initialized)
    {
        LOG("Physical machine address is http://%s:%s", EventsMonitor::machineAddress.c_str(), EventsMonitor::machinePort.c_str());
    }

    return initialized;
}
示例#2
0
// 0 ERROR
// Otherwise state
static int GetState(Window w)
{
    static Atom _XA_WM_STATE = 0;
    if(!_XA_WM_STATE) _XA_WM_STATE = XInternAtom(fl_display, "WM_STATE", False);

    int ret=0;
    int state = getIntProperty(w, _XA_WM_STATE, _XA_WM_STATE, 0, &ret);
    if(ret!=Success) return 0;
    return state;
}
 OfxRGBAColourB* MyImage::pixel(int x, int y) const
 {
   OfxRectI bounds = getBounds();
   if ((x >= bounds.x1) && ( x< bounds.x2) && ( y >= bounds.y1) && ( y < bounds.y2) )
   {
     int rowBytes = getIntProperty(kOfxImagePropRowBytes);
     int offset = (y - bounds.y1) * rowBytes + (x - bounds.x1) * sizeof(OfxRGBAColourB);
     return reinterpret_cast<OfxRGBAColourB*>(&(reinterpret_cast<char*>(_data)[offset]));
   }
   return 0;
 }
示例#4
0
bool HIDDeviceManager::getLocationId(IOHIDDeviceRef device, SInt32* pResult)
{
    SInt32 result;
    
    if (!getIntProperty(device, CFSTR(kIOHIDLocationIDKey), &result))
    {
        return false;
    }
        
    *pResult = result;
        
    return true;
}
示例#5
0
bool HIDDeviceManager::getProductId(IOHIDDeviceRef device, UInt16* pResult)
{
    SInt32 result;
    
    if (!getIntProperty(device, CFSTR(kIOHIDProductIDKey), &result))
    {
        return false;
    }
    
    *pResult = result;
    
    return true;
}
示例#6
0
bool HIDDeviceManager::initUsage(IOHIDDeviceRef device, HIDDeviceDesc* pDevDesc)
{
    
    SInt32 result;
    
    if (!getIntProperty(device, CFSTR(kIOHIDPrimaryUsagePageKey), &result))
    {
        return false;
    }
    
    pDevDesc->UsagePage = result;

    
    if (!getIntProperty(device, CFSTR(kIOHIDPrimaryUsageKey), &result))
    {
        return false;
    }
    
    pDevDesc->Usage = result;
    
    return true;
}
示例#7
0
bool HIDDeviceManager::initVendorProductVersion(IOHIDDeviceRef device, HIDDeviceDesc* pDevDesc)
{
    
    if (!getVendorId(device, &(pDevDesc->VendorId)))
    {
        return false;
    }
    
    if (!getProductId(device, &(pDevDesc->ProductId)))
    {
        return false;
    }

    SInt32 result;
    if (!getIntProperty(device, CFSTR(kIOHIDVersionNumberKey), &result))
    {
        return false;
    }
    pDevDesc->VersionNumber = result;
    
    return true;
}
示例#8
0
void WindowManager::init_internals(int argc, char* argv[])
{
	DBG("starting window manager");

	fl_open_display();
	XSetErrorHandler(xerror_handler);
	XShapeQueryExtension(fl_display, &XShapeEventBase, &XShapeErrorBase);

	wm_area.set(0, 0/*22*/, Fl::w(), Fl::h()/*-22*/);

	// TODO: make this part of class
	program_name = fl_file_filename(argv[0]);

	int i;
	if(Fl::args(argc, argv, i, arg) < argc)
		Fl::error("options are:\n"
			" -d[isplay] host:#.#\tX display & screen to use\n"
			" -v[isual] #\t\tvisual to use\n"
			" -g[eometry] WxH+X+Y\tlimits windows to this area\n"
			" -x\t\t\tmenu says Exit instead of logout\n"
			" -bg color\t\tFrame color\n"
			" -fg color\t\tLabel color\n"
			" -bg2 color\t\tText field color\n"
			" -cfg color\t\tCursor color\n"
			" -cbg color\t\tCursor outline color" );

	// Init started
	is_init = false;

	Fl::add_handler(wm_event_handler);
	
	// intern atoms
	init_atoms();
	read_configuration();
	read_xset_configuration();
	
	// Set XID now
	show();

	set_default_cursor();
	ICCCM::set_iconsizes(this);
	MWM::set_motif_info(this);
	register_protocols(fl_xid(this));
	Grab_Hotkeys(this);

	XSync(fl_display, 0);

	init_desktops(this);

	//Init done
	is_init = true;

	// find all the windows and create a Frame for each:
	Frame *f=0;
	unsigned int n;
	Window w1, w2, *wins;
	XWindowAttributes attr;
	XQueryTree(fl_display, fl_xid(this), &w1, &w2, &wins, &n);
	for (i = 0; i < (int)n; ++i)
	{
		XGetWindowAttributes(fl_display, wins[i], &attr);
		if(attr.override_redirect) continue;
		if(!attr.map_state)
		{
			if(getIntProperty(wins[i], _XA_WM_STATE, _XA_WM_STATE, 0) != IconicState)
				continue;
		}
		f = new Frame(wins[i], &attr);
	}
	XFree((void *)wins);

	// Activate last one
	for(uint n=0; n<map_order.size(); n++)
	{
		Frame *f = map_order[n];
		if(f->desktop()==Desktop::current())
		{
			f->activate();
			f->raise();
			break;
		}
	}

	update_workarea(true);
	is_running = true;
}