Last active
August 29, 2015 14:24
-
-
Save danzeeeman/9a69a8a39d3740958f9a to your computer and use it in GitHub Desktop.
OF Calls to reposition an app to the second display after a screen failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool resetScreen; | |
FadeTimer resetScreenDelay; //from ofxTiming by @kylemcdonald -> https://github.com/kylemcdonald/ofxTiming | |
void ofApp::setup(){ | |
.... | |
resetScreenDelay.setLength(3.0, 0.0); | |
resetScreen = false; | |
} | |
void ofApp::update(){ | |
.... | |
if(resetScreen){ | |
if(resetScreenDelay.get() == 1.0){ | |
if(ofGetWindowPositionX()!= ofGetScreenWidth()){ | |
ofLog()<<"Screen Reset"<<endl; | |
ofSetFullscreen(false); | |
ofSetWindowPosition(ofGetScreenWidth()+ofGetScreenWidth()/2, 0); | |
ofSetFullscreen(true); | |
resetScreen = false; | |
} | |
} | |
}else if(ofGetFrameNum()%500 == 0){ | |
if(ofGetWindowPositionX()!= ofGetScreenWidth()){ | |
ofLog()<<"Screen Reset Triggered"<<endl; | |
resetScreen = true; | |
resetScreenDelay.start(); | |
} | |
} | |
} | |
void ofApp::windowResized(int w, int h){ | |
... | |
if(ofGetWindowPositionX()!= ofGetScreenWidth() && !resetScreen){ | |
resetScreenDelay.start(); | |
resetScreen = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment