openframeworks / openframeworks/openFrameworks

Proposal : ofAppGLFWWindow, set position and shape at the same time

Open
#6,950 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

reading the code I've noticed some hacks to make things work like this:

	setWindowPosition(pos.x, pos.y);
	setWindowShape(screenSize.x, screenSize.y);
	setWindowPosition(pos.x, pos.y);

and inside function setWindowShape we have another setWindowPosition going.
I'm proposing the creation of a function who does the two things at the same time, only to be used when position and shape (dimensions) are set at once.

//------------------------------------------------------------
void ofAppGLFWWindow::setWindowRectangle(ofRectangle rect) {
	if(settings.windowMode == OF_WINDOW){
		windowW = rect.width;
		windowH = rect.height;
	}
	currentW = rect.width/pixelScreenCoordScale;
	currentH = rect.height/pixelScreenCoordScale;

//	cout << "glfwSetWindowSize " << ofGetFrameNum() << endl;
	glfwSetWindowSize(windowP,currentW,currentH);
	glfwSetWindowPos(windowP,rect.x/pixelScreenCoordScale,rect.y/pixelScreenCoordScale);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ofAppGLFWWindow::setWindowPosition and setWindowShape, including the existing callers that set both values. Compare them with the proposed setWindowRectangle behavior; done means position and dimensions can be applied together without the duplicate positioning calls while preserving window-mode and scaled-coordinate handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.