Skip to content

Instantly share code, notes, and snippets.

@danzeeeman
Last active August 29, 2015 14:24
Show Gist options
  • Save danzeeeman/9a69a8a39d3740958f9a to your computer and use it in GitHub Desktop.
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
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