Exemple #1
0
void
COSXScreen::hideCursor()
{
	LOG((CLOG_DEBUG "hiding cursor"));

	CFStringRef propertyString = CFStringCreateWithCString(
		NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);

	CGSSetConnectionProperty(
		_CGSDefaultConnection(), _CGSDefaultConnection(),
		propertyString, kCFBooleanTrue);

	CFRelease(propertyString);

	CGError error = CGDisplayHideCursor(m_displayID);
	if (error != kCGErrorSuccess) {
		LOG((CLOG_ERR "failed to hide cursor, error=%d", error));
	}

	// appears to fix "mouse randomly not hiding" bug
	CGAssociateMouseAndMouseCursorPosition(true);

	if (CGCursorIsVisible()) {
		LOG((CLOG_WARN "cursor may be still visible"));
	}

	m_cursorHidden = true;
}
Exemple #2
0
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse(JNIEnv *env, jclass unused, jboolean grab) {
    CGAssociateMouseAndMouseCursorPosition(grab == JNI_TRUE ? FALSE : TRUE);
    if (grab)
        CGDisplayHideCursor(kCGDirectMainDisplay);
    else
        CGDisplayShowCursor(kCGDirectMainDisplay);
}
//--------------------------------------
void ofHideCursor(){
	#ifdef TARGET_OSX
		CGDisplayHideCursor(kCGDirectMainDisplay);
	#else 
		glutSetCursor(GLUT_CURSOR_NONE);
	#endif
}
//--------------------------------------------------------------
void testApp::setup(){    
    //setup initial ip addresses
    iPadIP = "";
    iPhoneIP = "";
    osxIP = "";
    
    ofSetFrameRate(24);
    
    count = 0;
    
    debug = false;
    sendOSC = false;
    
    setupUI();
    setupVideo();
    
    CGDisplayHideCursor(NULL);
    
    gotJSON = false;

    ss << "No video information received yet" << endl;
    
    //load json
    loadJSON();
    
}
Exemple #5
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    
    
    if(key == 't') { ofToggleFullscreen();CGDisplayHideCursor(kCGDirectMainDisplay); }
    

}
Exemple #6
0
//------------------------------------------------------------
void ofAppGlutWindow::hideCursor(){
	#if defined(TARGET_OSX) && defined(MAC_OS_X_VERSION_10_7)
		 CGDisplayHideCursor(NULL);
	#else
		glutSetCursor(GLUT_CURSOR_NONE);
	#endif
}
//--------------------------------------------------------------
void ofApp::update(){
    
    player.update();
    
    if(sendOSC){
        
        float p = player.getPosition();
        //printf("%f\n",p);
        
        ofxOscMessage m;
        m.setAddress( "/movie/position" );
        m.addFloatArg(p);
        m.addIntArg(debug);
        
        // Broadcast current position information of movie
        if ((count % 100 == 0)) {
            
            osxSender.sendMessage(m); // send slower for macbook
            
        }
        
        if (count % iPadOSCCount == 0) iPadSender.sendMessage(m); //send every frame for iphone
        if (count % iPhoneOSCCount == 0) iPhoneSender.sendMessage(m); // send every frame for ipad
        count++;
    }
    
    if (!debug) CGDisplayHideCursor(NULL);

    

}
Exemple #8
0
void Input::mouseVisible(bool visible)
{
    if (visible)
    {
#ifdef __APPLE__
    	CGAssociateMouseAndMouseCursorPosition(TRUE);
	    CGDisplayShowCursor(kCGDirectMainDisplay);
#else
        glfwEnable(GLFW_MOUSE_CURSOR);
        glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
#endif
    }
    else
    {
#ifdef __APPLE__
	    glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
        CGDisplayHideCursor(kCGDirectMainDisplay);
	    CGPoint p;
	    p.x = m_mouseMiddleX;
	    p.y = m_mouseMiddleY;
	    //CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, p);
	    CGWarpMouseCursorPosition(p);
	    CGAssociateMouseAndMouseCursorPosition(FALSE);
#else
        glfwDisable(GLFW_MOUSE_CURSOR);
        glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
#endif
    }
    m_mouseVisible = visible;
}
Exemple #9
0
void
COSXScreen::hideCursor()
{
    CFStringRef propertyString = CFStringCreateWithCString(NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);
    CGSSetConnectionProperty(_CGSDefaultConnection(), _CGSDefaultConnection(), propertyString, kCFBooleanTrue);
    CFRelease(propertyString);

    CGDisplayHideCursor(m_displayID);
    LOG((CLOG_DEBUG "Trying to hide cursor."));
}
void inputMouseDown(InputContext* ctx, int x, int y) {
  CGDisplayHideCursor(kCGDirectMainDisplay);
  CGEventRef mouseDown = CGEventCreateMouseEvent(
      NULL, kCGEventLeftMouseDown,
      CGPointMake(x, y),
      kCGMouseButtonLeft
  );

  CGEventPost(kCGHIDEventTap, mouseDown);
  CFRelease(mouseDown);
}
Exemple #11
0
void cyrilApp::toggleFullscreen(void * _o) {
  ((cyrilApp *)_o)->isFullScreen = !((cyrilApp *)_o)->isFullScreen;
  ofSetFullscreen(((cyrilApp *)_o)->isFullScreen);
  
  if (((cyrilApp *)_o)->isFullScreen) {
    ofHideCursor();
#ifdef __APPLE__
    CGDisplayHideCursor(NULL); 
#endif
  }
  else {
    ofShowCursor();
#ifdef __APPLE__
    CGDisplayShowCursor(NULL);
#endif
  }
}
Exemple #12
0
//--------------------------------------------------------------
void testApp::setup(){
    
//    int windowMode = ofGetWindowMode();  
//    if(windowMode == OF_FULLSCREEN){  
//        this->windowWidth = ofGetScreenWidth();  
//        this->windowHeight = ofGetScreenHeight();
//    }
    ofSetFullscreen(true);
    
    desk.resX=backg.resX=curs.resX=slit.resX=errorBall.resX=blueScreen.resX=internet.resX=menu.resX=glitch.resX = ofGetScreenWidth();
    desk.resY=backg.resY=curs.resY=slit.resY=errorBall.resY=blueScreen.resY=internet.resY=menu.resY=glitch.resY = ofGetScreenHeight();

    
    menu.setup("Menu Bar"); // most of the time you don't need a name
    menu.add(finder.setup("GlitchOS", true));
//    menu.add(file.setup("Time", false));
//    menu.add(lol.setup("Truth", false));
//    menu.add(chicken.setup("Hearts", false));
    glitch.setup();
    desk.setup();
    desk.add(webcam.setup("icons/webcam.png", "Webcam"));
    desk.add(windows.setup("icons/windows.png", "Windows"));
    desk.add(safari.setup("icons/chrome.png", "Internet"));
//    desk.add(quickTime.setup("icons/video.png", "Video Player"));
    backg.setup("screen/background.jpg");
    curs.setup("screen/cursor.png");
    slit.setup(6, 20);
    errorBall.setup();
    blueScreen.setup();
    internet.setup();
        
    ofNoFill();
    ofEnableAlphaBlending();
    ofSetEscapeQuitsApp(false);
//    ofHideCursor();
    CGDisplayHideCursor(NULL);
    ofSetVerticalSync(true);
    ofSetFrameRate(60);
    
    slitIR = false;
    blueScreenIR = false;
    internetIR = false;
    quickVideoIR = false;

}
void BaseApp::captureMouse(const bool value){
#ifndef NO_CAPTURE_MOUSE
	if (mouseCaptured != value){
		//static int mouseX, mouseY;
		if (value){
			CGDisplayHideCursor(kCGDirectMainDisplay);

			setCursorPos(width / 2, height / 2);
		} else {
			CGDisplayShowCursor(kCGDirectMainDisplay);

			// TODO: Fix ...
			//setCursorPos(mouseX, mouseY);
		}
		CGAssociateMouseAndMouseCursorPosition(mouseCaptured);

		mouseCaptured = value;
	}
#endif
}
//--------------------------------------------------------------
void ofApp::setup(){
    //setup initial ip addresses
    iPadIP = "";
    iPhoneIP = "";
    osxIP = "";
    
    //set framerate
    ofSetFrameRate(24);
    
    //set count
    count = 0;
    
    //set debug and sendosc
    debug = false;
    sendOSC = false;
    
    //setup ui and our first video
    setupUI();
    setupVideo();
    
    //setup osc
    setupOSC();
    
    //hide cursor
    CGDisplayHideCursor(NULL);
    
    //set gotjson
    gotJSON = false;
    
    //set ss
    ss << "No video information received yet" << endl;
    
    //load json
    loadJSON();
    
    ofRegisterURLNotification(this);
    videosDownloaded = 0;

}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    // hide gui
    if( key == 'h' ){
		bHide = !bHide;
        
        if(bHide){
            // ofHideCursor();
            CGDisplayHideCursor(NULL);
        }else{
            //  ofShowCursor();
            CGDisplayShowCursor(NULL);
        }
	}
    
    // save current settings
	if(key == 's') {
		gui.saveToFile("settings.xml");
	}
    
    // load settings from file / reset to default values
	if(key == 'l') {
		gui.loadFromFile("settings.xml");
	}
}
Exemple #16
0
void _glfwPlatformHideMouseCursor( void )
{
    // TO DO: What if we fail here?
    (void)CGDisplayHideCursor( kCGDirectMainDisplay );
}
FREObject hideMouse(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    CGDisplayHideCursor (kCGDirectMainDisplay);
    return NULL;
}
Exemple #18
0
void _glfwPlatformHideMouseCursor( void )
{
    CGDisplayHideCursor( kCGDirectMainDisplay );
    CGAssociateMouseAndMouseCursorPosition( false );
}
JNIEXPORT void JNICALL Java_com_intellij_util_ui_MacUIUtil_doHideCursor
  (JNIEnv *env, jclass clazz) {
  CGDisplayHideCursor(kCGDirectMainDisplay);
}
Exemple #20
0
//--------------------------------------------------------------
void testApp::setup(){
    
    //ofSetDataPathRoot("data/"); // Necessary for a standalone app.
    
    // Support r-restart.
    cleanup();
    staffPosList.clear();
    
    // Maintenance
    frameRate = 60;
    ofSetFrameRate( frameRate );
    ofSetVerticalSync( true );
    ofEnableAlphaBlending();
    ofSetCircleResolution( 100 );
    myCam.disableMouseInput();
    CGDisplayHideCursor(NULL);
    ofBackground( 255 );
    
    { // Straight from the ofxGamepad example.
        ofxGamepadHandler::get()->enableHotplug();
        
        //CHECK IF THERE EVEN IS A GAMEPAD CONNECTED
        if(ofxGamepadHandler::get()->getNumPads()>0){
            bUsingController = true; // Matt: I added this.
			ofxGamepad* pad = ofxGamepadHandler::get()->getGamepad(0);
			ofAddListener(pad->onAxisChanged, this, &testApp::axisChanged);
			ofAddListener(pad->onButtonPressed, this, &testApp::buttonPressed);
			ofAddListener(pad->onButtonReleased, this, &testApp::buttonReleased);
        } else {
            bUsingController = false; // Matt: I added this too.
        }
    } // End ofxGamepad stuff
    
    { /*
       Precision placement is key in this game, so that the music sounds right. However, there's no way to know what size screen will be used. So everything is sized based on the screen, via a scaler factor calculated using this wizardry:
       */
        iThirdOfScreen = int( ofGetHeight() / 2.25 );
        while ( iThirdOfScreen % 16 != 0 ) {
            iThirdOfScreen--;
        }
        iScaler = iThirdOfScreen / 16; // 25 on my fullscreen.
        //cout<<iScaler<<endl;
    } // End wizardry
    fCalcAllNotePos();
    
    helvetica.loadFont( "fonts/helvetica.otf", iScaler );
    helveticaJumbo.loadFont("fonts/helvetica.otf", iScaler * 4 );
    
    /* Gamestates:
     -1:    restart screen
     0:     title screen
     1:     platforming prototype
     2:     boss prototype
     3:     piano prototype
     4:     boost prototype
     */
    gameState = 0;
    currentState = gameState;
    
    bIsLefty = bIsRecording = bIsDebugging = bShiftIsPressed = myTitle.bChoseControls = false;
    bHighlightNote = false;
    bCamZoomedIn = false;
    
    if ( bHighlightNote ) getThisOne = 0;
    else getThisOne = -1;
    objectLife = 7 * frameRate;
    fMeasureLength = iScaler * 6 * 5.333333;;
    myTitle.iWhichPrototype = 1;
}
Exemple #21
0
void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
	if (!mouse_avail || !window)
		relative = hidecursor = false;

	if (relative)
	{
		if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer))
			VID_SetMouse(false, false, false); // ungrab first!
		if (!vid_usingmouse)
		{
			Rect winBounds;
			CGPoint winCenter;

			SelectWindow(window);

			// Put the mouse cursor at the center of the window
			GetWindowBounds (window, kWindowContentRgn, &winBounds);
			winCenter.x = (winBounds.left + winBounds.right) / 2;
			winCenter.y = (winBounds.top + winBounds.bottom) / 2;
			CGWarpMouseCursorPosition(winCenter);

			// Lock the mouse pointer at its current position
			CGAssociateMouseAndMouseCursorPosition(false);

			// Save the status of mouse acceleration
			originalMouseSpeed = -1.0; // in case of error
			if(apple_mouse_noaccel.integer)
			{
				io_connect_t mouseDev = IN_GetIOHandle();
				if(mouseDev != 0)
				{
					if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
					{
						Con_DPrintf("previous mouse acceleration: %f\n", originalMouseSpeed);
						if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
						{
							Con_Print("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
							Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
						}
					}
					else
					{
						Con_Print("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
						Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
					}
					IOServiceClose(mouseDev);
				}
				else
				{
					Con_Print("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
					Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
				}
			}

			vid_usingmouse = true;
			vid_usingnoaccel = !!apple_mouse_noaccel.integer;
		}
	}
	else
	{
		if (vid_usingmouse)
		{
			if(originalMouseSpeed != -1.0)
			{
				io_connect_t mouseDev = IN_GetIOHandle();
				if(mouseDev != 0)
				{
					Con_DPrintf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
					if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
						Con_Print("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
					IOServiceClose(mouseDev);
				}
				else
					Con_Print("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
			}

			CGAssociateMouseAndMouseCursorPosition(true);

			vid_usingmouse = false;
		}
	}

	if (vid_usinghidecursor != hidecursor)
	{
		vid_usinghidecursor = hidecursor;
		if (hidecursor)
			CGDisplayHideCursor(CGMainDisplayID());
		else
			CGDisplayShowCursor(CGMainDisplayID());
	}
}
Window::Window(const Rect & rect, int fulls)
{ 
   m_rect = rect;
   m_win = 0;
   m_init = false;
   m_ctx = 0;
  
   //
   // Create the Carbon window:
   OSStatus s;

   if ( fulls ) {
      s = CreateNewWindow(kOverlayWindowClass,
         kWindowStandardHandlerAttribute | kWindowCompositingAttribute,
         &m_rect, &m_win);
      if(s != noErr) {
         fprintf(stderr,"failed to create window at %i,%i,%i,%i\n",m_rect.left,m_rect.top,m_rect.right,m_rect.bottom);
         abort();
      }

      // Hide Cursor
      CGCaptureAllDisplays();
      CGDisplayHideCursor(kCGDirectMainDisplay); 
      CGReleaseAllDisplays();
    
   }
   else
   {
      // just a little offset when opening the window
      s = CreateNewWindow(kDocumentWindowClass,
         kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute| kWindowInWindowMenuAttribute,
         &m_rect, &m_win);
      if(s != noErr) {
         fprintf(stderr,"failed to create window at %i,%i,%i,%i\n",m_rect.left,m_rect.top,m_rect.right,m_rect.bottom);
         abort();
      }

      // Put a title
      SetWindowTitleWithCFString (m_win, CFSTR("SAGE GStream Receiver"));
   }

   SetWindowActivationScope(m_win,kWindowActivationScopeAll);
   ShowWindow(m_win);
   ActivateWindow(m_win, true);


   if ( ! fulls ) {
      Rect arect;
      short hGlobal, vGlobal;
      GetWindowBounds(m_win, kWindowStructureRgn, &arect);
      MoveWindow (m_win, arect.left, (arect.top < 0) ? 40 : arect.top+50, true);
   }

   // Create context
   m_ctx = aglCreateContext(agl_fmt,0);
   if(m_ctx == 0) {
      fprintf(stderr,"failed to create OpenGL context\n");
      abort();
   }

   // Set the global context, shared by other windows:
   if(agl_ctx == 0) {
      agl_ctx = m_ctx;
   }

   //
   // All your window are belong to us:
   GLboolean e;
   e = aglSetDrawable(m_ctx,GetWindowPort(m_win));
   if(!e) {
      fprintf(stderr,"failed aglSetDrawable\n");
      abort();
   }

   // Initialize the OpenGL
   aglSetCurrentContext(m_ctx);
   glViewport(0,0,m_rect.right - m_rect.left,m_rect.bottom - rect.top);
    
    /* glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(m_rect.left,m_rect.right,m_rect.top,m_rect.bottom,-1,1);
    
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    */
    
   glClearColor(0,0,0,1);
   glClear(GL_COLOR_BUFFER_BIT);

   aglSwapBuffers(m_ctx);
}
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
	ofSetVerticalSync(true);
    
    
	ofSetFrameRate(30);
    ofBackground(0);
    
    
    
    ofHideCursor();
    
    
    ofSetFullscreen(true);
    
    // Interaction
    vidGrabber.setVerbose(true);
    vidGrabber.setDeviceID(0);
    vidGrabber.initGrabber(320,240);
    
    colorImg.allocate(320,240);
    
    actionThreshold[0] = 10;
    actionThreshold[1] = 10;
    actionThreshold[2] = 10;
    actionThreshold[3] = 10;
    actionThreshold[4] = 10;
    
    
    // GUI
    
    thres.push_back(thres1);
    thres.push_back(thres2);
    thres.push_back(thres3);
    thres.push_back(thres4);
    thres.push_back(thres5);
    
    
    gui.setup();
    gui.add(fps.setup("FrameRate",framerate));
    gui.add(camSwitch.setup("Show Video",false));
    gui.add(mirror.setup("Mirror Video",true));
    gui.add(thres1.setup("Threshold 1st Region" ,actionThreshold[0],0,15000));
    gui.add(thres2.setup("Threshold 2st Region" ,actionThreshold[1],0,15000));
    gui.add(thres3.setup("Threshold 3st Region" ,actionThreshold[2],0,15000));
    gui.add(thres4.setup("Threshold 4st Region" ,actionThreshold[3],0,15000));
    gui.add(thres5.setup("Threshold 5st Region" ,actionThreshold[4],0,15000));
    gui.add(threshold.setup("Threshold Gray Image" ,80,0,200));
    gui.add(timeLimit.setup("Set Delay Time" ,8,0,40));
    
    
    gui.setPosition(ofGetWidth() - 210, ofGetWindowHeight() - 300);
    
    // Load recent values at startup
    gui.loadFromFile("settings.xml");
    
    // Read Sentences from database
    sqlite = new ofxSQLite("rizomi.db");
    /*
    sqlite->simpleQuery(""\
                        "CREATE TABLE IF NOT EXISTS highlight (" \
                        " id INTEGER" \
                        " ,start INTEGER" \
                        " ,stop INTEGER" \
                        ");"
                        );
     sqlite->insert("highlight")
     .use("id", 0)
     .use("start",0)
     .use("stop",3).execute();

     */
    
    
    ofxSQLiteSelect sel = sqlite->select("id, word").from("words");
	sel.execute().begin();
    
	while(sel.hasNext()) {
		int id = sel.getInt();
		std::string name = sel.getString();
		sel.next();
        name = ofUTF8::toUpper(name);
        texts.resize(texts.size()+1);
        texts[texts.size()-1] = name;
	}
    
    
    // load font
    font = new ofxFontStash();
    font->setup("mono.ttf"); //load verdana font, set lineHeight to be 130%
    
    // Create Sentence Objects
    SentenceNum = texts.size();
    SentenceNum = 30;
    cout << "Sentence size : "<< SentenceNum << endl;
    

    // 2D Vector Array
    // to hold highlighted letter indexes
    highlights.resize(SentenceNum);
    vector<ofVec2f> pp;
    
    // Loop through database to get indexes
    for (int j = 0; j < SentenceNum; j++) {
        
        sel = sqlite->select("id, start, stop").from("highlight").where("id", j);
        sel.execute().begin();
        
        while(sel.hasNext()) {
            int id = sel.getInt();
            int start = sel.getInt();
            int stop = sel.getInt();
            pp.resize(pp.size()+1);
            pp[pp.size()-1]=ofVec2f(start,stop);
            //cout << id << ", " << pp[pp.size()] << endl;
            sel.next();
        }

     
        highlights[j] = pp;
        pp.clear();
    }
    

    // Get sentences and generate sentences
    sentences.resize(SentenceNum);
    speedVals.resize(SentenceNum);
    
    for (int j = 0; j < SentenceNum; j++) {
        Sentence *sentence = new Sentence(texts[j],font, 0, 12*j);
        sentences[j] = sentence;
        speedVals[j] = ofRandom(0.0008, 0.005);
        sentences[j]->setSpeed(speedVals[j]);
        sentences[j]->setFactorNoiseX(ofRandom(0.003, 0.02));
    }
    
    
   // Background Lines
    bgLineNum = 80;
    for (int i=0;  i< bgLineNum; i++) {
        bgLineAlpha.resize(bgLineAlpha.size()+1);
        bgLineAlpha[bgLineAlpha.size()-1] = ofMap(i, 0, bgLineNum, 0, 100);
    }
    
    // Hide Cursor
    CGDisplayHideCursor(NULL);
}
OP_STATUS MacOpPluginAdapter::ProcessMessage(const OpTypedMessage* message)
{
	switch (message->GetType())
	{
		case OpPeerConnectedMessage::Type:
			if (m_plugin_window)
				// Send initial top-level window coordinates.
				m_plugin_window->OnDesktopWindowMoved(NULL);
			break;
			
		case OpPeerDisconnectedMessage::Type:
			m_plugin_channel = NULL;
			break;
			
		case OpMacPluginUpdateViewMessage::Type:
			if (m_plugin_window)
				m_plugin_window->UpdatePluginView();
			break;
			
		case OpMacPluginFullscreenMessage::Type:
		{
			SystemUIMode outMode;
			SystemUIOptions  outOptions;
			GetSystemUIMode(&outMode, &outOptions);
			
			ProcessSerialNumber psn;
			
			if (OpMacPluginFullscreenMessage::Cast(message)->GetFullscreen())
			{
				// Hide menu and dock
				SetSystemUIMode(kUIModeAllHidden, outOptions);
				
				// Set the plugin as the front process
				psn.highLongOfPSN = OpMacPluginFullscreenMessage::Cast(message)->GetHighLongOfPSN();
				psn.lowLongOfPSN = OpMacPluginFullscreenMessage::Cast(message)->GetLowLongOfPSN();
				SetFrontProcess(&psn);
			}
			else
			{
				// Set Opera as the front process
				GetCurrentProcess(&psn);
				SetFrontProcess(&psn);
				
				// Show menu and dock
				SetSystemUIMode(kUIModeNormal, outOptions);
			}
		}
			break;
			
		case OpMacPluginWindowShownMessage::Type:
		{
			ProcessSerialNumber psn;
			
			if (OpMacPluginWindowShownMessage::Cast(message)->GetShow())
			{
				// Set the plugin as the front process
				psn.highLongOfPSN = OpMacPluginWindowShownMessage::Cast(message)->GetHighLongOfPSN();
				psn.lowLongOfPSN = OpMacPluginWindowShownMessage::Cast(message)->GetLowLongOfPSN();
				SetFrontProcess(&psn);
			}
			else
			{
				// Set Opera as the front process
				GetCurrentProcess(&psn);
				SetFrontProcess(&psn);
			}
		}
			break;
			
		case OpMacPluginInfoMessage::Type:
			return message->Reply(OpMacPluginInfoResponseMessage::Create(CommandLineManager::GetInstance()->GetArgument(CommandLineManager::DisableCoreAnimation) ? TRUE : FALSE,
																		 CommandLineManager::GetInstance()->GetArgument(CommandLineManager::DisableInvalidatingCoreAnimation) ? TRUE : FALSE));

		case OpMacPluginCursorShownMessage::Type:
		{
			if (OpMacPluginCursorShownMessage::Cast(message)->GetShow())
			{
				CGDisplayShowCursor(CGMainDisplayID());
			}
			else
			{
				CGDisplayHideCursor(CGMainDisplayID());
			}
		}
			break;

		case OpMacPluginContextMenuShownMessage::Type:
		{
			gHandlingContextMenu = OpMacPluginContextMenuShownMessage::Cast(message)->GetShow();
		}
			break;
	}
	
	return OpStatus::OK;
}
Exemple #25
0
void _glfwPlatformHideMouseCursor( void )
{
    // TO DO: What if we fail here?
    CGDisplayHideCursor( kCGDirectMainDisplay );
    CGAssociateMouseAndMouseCursorPosition( false );
}
Exemple #26
0
int CScreensaver::Create() {
    ProcessSerialNumber psn;
    ProcessInfoRec pInfo;
    OSStatus err;
    
    // Ugly workaround for a problem with the System Preferences app
    // For an unknown reason, when this screensaver is run using the 
    // Test button in the System Prefs Screensaver control panel, the 
    // control panel calls our stopAnimation function as soon as the 
    // science application opens a GLUT window.  This problem does not 
    // occur when the screensaver is run normally (from the screensaver 
    // engine.)  So we just display a message and don't access the core 
    // client.
    // With V6 graphics when using gfx_switcher, the graphics application 
    // fails to run and stderr shows the message: 
    // "The process has forked and you cannot use this CoreFoundation 
    // functionality safely. You MUST exec()" 
    GetCurrentProcess(&psn);
    memset(&pInfo, 0, sizeof(pInfo));
    pInfo.processInfoLength = sizeof( ProcessInfoRec );
    pInfo.processName = NULL;
    err = GetProcessInformation(&psn, &pInfo);
    if ( (err == noErr) && (pInfo.processSignature == 'sprf') ) {
        saverState = SaverState_ControlPanelTestMode;
    }

    // Calculate the estimated blank time by adding the starting
    //  time and and the user-specified time which is in minutes
    // On dual-GPU Macbok Pros, the CScreensaver class will be
    // constructed and destructed each time we switch beteen
    // battery and AC power, so we need to get the starting time
    // only once.
    if (!ScreenSaverStartTime) {
        ScreenSaverStartTime = time(0);
    }
    
    m_dwBlankScreen = gGoToBlank;
    if (gGoToBlank && (gBlankingTime > 0))
        m_dwBlankTime = ScreenSaverStartTime + (gBlankingTime * 60);
    else
        m_dwBlankTime = 0;
    
    // If there are multiple displays, initBOINCSaver may get called 
    // multiple times (once for each display), so we need to guard 
    // against launching multiple instances of the core client
    if (saverState == SaverState_Idle) {
        CFStringGetCString(gPathToBundleResources, m_gfx_Switcher_Path, sizeof(m_gfx_Switcher_Path), kCFStringEncodingMacRoman);
        strlcat(m_gfx_Switcher_Path, "/gfx_switcher", sizeof(m_gfx_Switcher_Path));

        err = initBOINCApp();

        CGDisplayHideCursor(kCGNullDirectDisplay);
    
        if (saverState == SaverState_LaunchingCoreClient)
        {
            SetError(FALSE, 0);
            m_bQuitDataManagementProc = false;
            m_bDataManagementProcStopped = false;
            if (rpc == NULL) {
                rpc = new RPC_CLIENT;
            }
        }
    }
    
    if (!IsDualGPUMacbook) {
        SetDiscreteGPU(false);
        if (IsDualGPUMacbook && (GPUSelectConnect != IO_OBJECT_NULL)) {
            IOServiceClose(GPUSelectConnect);
            GPUSelectConnect = IO_OBJECT_NULL;
        }
    }
    
    return TEXTLOGOFREQUENCY;
}
Exemple #27
0
	void update() {
#ifdef INSTALL
		if(cam.update()) {
			ofPixels& pixels = cam.getColorPixels();
#else
		cam.update();
		if(cam.isFrameNew()) {
			ofPixels& pixels = cam.getPixelsRef();
#endif
			// next two could be replaced with one line
			ofxCv::rotate90(pixels, rotated, rotate ? 270 : 0);
			ofxCv:flip(rotated, rotated, 1);
			Mat rotatedMat = toCv(rotated);
			if(tracker.update(rotatedMat))  {
				ofVec2f position = tracker.getPosition();
				vector<FaceTrackerData*> neighbors = data.getNeighborsCount(position, neighborCount);
				FaceTrackerData curData;
				curData.load(tracker);
				if(!neighbors.empty()) {
					nearestData = *faceCompare.nearest(curData, neighbors);
					if(nearestData.label != lastLabel) {
						similar.loadImage(nearestData.getImageFilename());
#ifdef INSTALL
						whitePoint = getWhitePoint(similar);
#else
						whitePoint.set(1, 1, 1);
#endif
					}
					lastLabel = nearestData.label;
				}
				if(faceCompare.different(curData, currentData) && faceCompare.different(curData, neighbors)) {
					saveFace(curData, rotated);
					currentData.push_back(pair<ofVec2f, FaceTrackerData>(position, curData));
				}
			}
			presence.update(tracker.getFound());
			if(presence.wasTriggered()) {
				presenceFade.stop();
			}
			if(presence.wasUntriggered()) {
				for(int i = 0; i < currentData.size(); i++) {
					data.add(currentData[i].first, currentData[i].second);
				}
				currentData.clear();
				presenceFade.start();
			}
		}
	}
	void draw() {
		ofBackground(255);
		CGDisplayHideCursor(NULL);
		ofSetColor(255);
		if(similar.isAllocated()) {
			shader.begin();
			shader.setUniformTexture("tex", similar, 0);
			shader.setUniform3fv("whitePoint", (float*) &whitePoint);
			similar.draw(0, 0);
			shader.end();
		}
		ofPushStyle();
		if(presenceFade.getActive()) {
			ofSetColor(0, ofMap(presenceFade.get(), 0, 1, 0, 128));
			ofFill();
			ofRect(0, 0, ofGetWidth(), ofGetHeight());
			ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 32));
			data.drawBins();
			ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 64));
			data.drawData();
		}
		ofSetColor(255, 64);
		ofNoFill();
		if(!tracker.getFound()) {
			ofCircle(tracker.getPosition(), 10);
		}
		tracker.draw();
		ofPopStyle();
		
#ifndef INSTALL
		drawFramerate();
#endif
	}
//--------------------------------------------------------------
void testApp::setup(){
    
    { // Mauricio
        //ship1.setup(ofVec2f( ofGetWindowWidth() / 2 , ofGetWindowHeight() / 2), 2, ofColor( ofColor( 20, 20, 200)));
        //        enemyFbo.allocate( 0 , 0 );
        ofSeedRandom();
        secondBackground.setup();
    }
    
    
    { // Matt
        
        //ofSetDataPathRoot("data/"); // Comment this in to compile a standalone build.
        gameState = 0;
        font.loadFont("blocked.ttf", 24);
        fontSmall.loadFont("blocked.ttf", 12);
        ofSetRectMode( OF_RECTMODE_CORNER );
        startScreen.loadImage("spaceships_start_screen.png");
        startScreenFade = 0;
        startScreenFadeVel = 3;
        
        // This one listens to the same port that we were sending to in the other app.
        mReceiver.setup( 99999 );
        
        killFrameRate = false; // Turn on the enemy and background, watch the framerate drop.
        // Maintenance
        ofSetVerticalSync( true );
        ofSetFrameRate( 60 );
        ofSetCircleResolution( 100 );
        ofEnableAlphaBlending();
        ofBackground( 0 );
        //ofHideCursor(); // Doesn't work.
        CGDisplayHideCursor(NULL); // But this does.
        generation = 0;
        //cam.setDistance(0);
        metroid.setup();
        
        { // Make the ships.
            float offset = 100;
            for ( int i = 0; i < 4; i++ ) {
                SpaceShip tmp;
                string picNum =  ofToString(i);
                // We pass in the value of i to set a permanent "control index," to which the specific controls are tied. That way if a ship gets destroyed and the vector indicies get changed, the controls stay the same. -Matt
                spaceShip.loadImage("spaceship" + picNum + ".png");
                tmp.setup( i, ofVec2f( offset, offset ), spaceShip);
                shipList.push_back( tmp );
            }
            // Individual pos
            shipList[ 1 ].pos.set( ofGetWindowWidth() - offset, offset );
            shipList[ 2 ].pos.set( offset, ofGetWindowHeight() - offset );
            shipList[ 3 ].pos.set( ofGetWindowWidth() - offset, ofGetWindowHeight() - offset );
            // Individual color
            shipList[ 1 ].colorPlayer = ofColor( 200, 20, 20 );
            shipList[ 2 ].colorPlayer = ofColor( 100, 80, 20 );
            shipList[ 3 ].colorPlayer = ofColor( 0, 255, 20 );
        }
    }
    
    
    //-----------------Michael Kane's-----------------//
    //Michael was an important part of the previous sequel so we decided to call the second michael's kahane defection, this part of the code is actually his
    for( int i = 0; i < 50; i++){
    
        Michael tmp;
        float vx = ofRandom(-4,4);
        float vy = ofRandom(-4,4);
        tmp.setParams(metroid.pos, vx, vy);
        kahane.push_back(tmp);
        
    }
    
        
        
    
}
Exemple #29
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){

int swap = ofMap(key, 48, 57, 0, 9);

    if((swap <= 9)&&(swap >= 0)){
        if(swap < maxNumber){
              for(int i = 0; i < maxNumber; i++){
                  mapping[i]->deactivate();
              }
            mapping[swap]->activate();
            swapGloble = swap;
        }
    }
    
    switch (key) {
        case 's':
            save();

            break;
        case 'l':
            loadMe();

            break;
        case 'f':
            
            CGDisplayHideCursor(kCGDirectMainDisplay);

            ofToggleFullscreen();
            break;
        case ' ':
            if(debug == 0){

                debug = 1;
            }
            else{
                debug = 0;
            }
            
            for(int i = 0; i < maxNumber; i++){
                mapping[i]->debugSet(debug);
            }
            break;
            
        case 13:
            maxNumber ++;
            mapping[maxNumber-1] = new ofxQuad();
            vid.push_back(ofVideoPlayer());
            vid[maxNumber-1].loadMovie(dir.getPath(0));

            width =  vid[maxNumber-1].getWidth() * (maxNumber-hozpertion);
            if((width + vid[maxNumber-1].getWidth()) > ofGetWidth() ){
                hozpertion = maxNumber + 1;
                height += vid[maxNumber-1].getHeight();
                width = 10;
            }
          
            mapping[maxNumber-1]->setup(width+10,10+height, 200, 200, ofGetWidth(), ofGetHeight(),maxNumber-1);
            mapping[maxNumber-1]->deactivate();
            vid[maxNumber-1].play();
            mapping[maxNumber-1]->debugSet(0);
            
            break;
            
        case 357:
            
            if( load >=(int)dir.size()-1){
                load = 0;
            }
            else{
                load += 1;
            }
            vid[swapGloble].loadMovie(dir.getPath(load));
            
            break;
    
    
        case 359:
            
            if( load <=0){

                load = (int)dir.size()-1;
            }
            else{
                load -= 1;
                
            }

            vid[swapGloble].loadMovie(dir.getPath(load));
            break;
            
        default:
            break;
    }
  //      cout << " me first " << endl;
}