Skip to content

Commit

Permalink
passThrough variable name in GLFW and example updated with blue circl…
Browse files Browse the repository at this point in the history
…e to disable force passThrough

(cherry picked from commit c7a409b)
  • Loading branch information
danoli3 committed Aug 27, 2024
1 parent 8516bcb commit 44c14ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
13 changes: 8 additions & 5 deletions examples/windowing/transparentWindow/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ void ofApp::draw(){
ofSetColor(255,0,0,sinAlpha);
ofDrawCircle(i * 13, sinX + ofGetWidth()*0.5, sinRadius);
}

ofSetColor(primaryBtnColor);
ofDrawCircle(ballPositionX, ballPositionY, 15);

if(bDrawGuides) { // Draw edge of transparent window for clarity
int screenWidth = ofGetWidth();
Expand Down Expand Up @@ -133,11 +130,11 @@ void ofApp::draw(){
fontRenderer.drawString("This happens dynamically via GLFW Attribute", 50, 10 + 4 * lineSpacing);
}

ofSetColor(primaryBtnColor);
ofSetColor(highlightColor);
if (bAllowPassThrough) {
fontRenderer.drawString("GLFW Mouse passThrough enabled", centerX, 2 * lineSpacing);
if(bForcePassThrough) {
fontRenderer.drawString("GLFW Mouse passThrough enabled", centerX, 2 * lineSpacing);
fontRenderer.drawString("Enabled: Force Mouse passThrough - Click the Blue Circle", centerX, 1 * lineSpacing);
}
} else {
fontRenderer.drawString("press h to enable GLFW passThrough or mouse below box", centerX, 2 * lineSpacing);
Expand Down Expand Up @@ -165,6 +162,9 @@ void ofApp::draw(){
}

fontRenderer.drawString("window pos ("+ofToString(ofGetWindowPositionX())+", "+ofToString( ofGetWindowPositionY())+")", 20, 30);

ofSetColor(primaryBtnColor);
ofDrawCircle(ballPositionX, ballPositionY, 15);
}


Expand Down Expand Up @@ -215,6 +215,9 @@ void ofApp::mouseMoved(int x, int y ){

float distance = ofDist(x, y, ballPositionX, ballPositionY);
if(distance <= 15 || y < 300) {
if(bForcePassThrough == true && distance <= 15){
bForcePassThrough = false;
}
if(bAllowPassThrough && (bForcePassThrough == false || distance <= 15)) {
bAllowPassThrough = false;
ofLogNotice("ofApp") << "ofSetWindowMousePassThrough:" << bAllowPassThrough;
Expand Down
12 changes: 6 additions & 6 deletions libs/openFrameworks/app/ofAppGLFWWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ void ofAppGLFWWindow::setup(const ofGLESWindowSettings & settings) {
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, settings.transparent);
#endif
#if (GLFW_VERSION_MAJOR >= 3 && GLFW_VERSION_MINOR >= 4)
if( settings.mousePassthrough && settings.transparent && settings.decorated) {
if( settings.mousePassThrough && settings.transparent && settings.decorated) {
ofLogError("ofAppGLFWWindow") << "window is decorated and has transparent input pass through. use floating...";
}
glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, settings.mousePassthrough);
glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, settings.mousePassThrough);
glfwWindowHint(GLFW_FLOATING, settings.floating);
#endif
currentRenderer = std::make_shared<ofGLProgrammableRenderer>(this);
Expand Down Expand Up @@ -1076,11 +1076,11 @@ void ofAppGLFWWindow::setup(const ofGLESWindowSettings & settings) {
}

//------------------------------------------------------------
void ofAppGLFWWindow::setWindowMousePassthrough(bool allowPassthrough) {
if(settings.mousePassthrough == allowPassthrough) return;
settings.mousePassthrough = allowPassthrough;
void ofAppGLFWWindow::setWindowMousePassThrough(bool allowPassThrough) {
if(settings.mousePassThrough == allowPassThrough) return;
settings.mousePassThrough = allowPassThrough;
#if (GLFW_VERSION_MAJOR >= 3 && GLFW_VERSION_MINOR >= 4)
glfwSetWindowAttrib(getGLFWWindow(), GLFW_MOUSE_PASSTHROUGH, settings.mousePassthrough);
glfwSetWindowAttrib(getGLFWWindow(), GLFW_MOUSE_PASSTHROUGH, settings.mousePassThrough);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion libs/openFrameworks/app/ofAppGLFWWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow {

void setFullscreen(bool fullscreen);
void toggleFullscreen();
void setWindowMousePassthrough(bool allowPassthrough);
void setWindowMousePassThrough(bool allowPassThrough);

void enableSetupScreen();
void disableSetupScreen();
Expand Down

0 comments on commit 44c14ae

Please sign in to comment.