Skip to content

Feature/18/focus window #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ export function focusWindow(handle: number): void
* The window is moved to the x & y coordinates if specified.
*
* @param {number} handle - The handle ID of the window to be resized.
* @param {Rect} rect - The new size of the window.
* @param {Size} newSize - The new size of the window.
* @returns {void}
*/
export function resizeWindow(handle: number, rect: Rect): void
export function resizeWindow(handle: number, newSize: Size): void

/**
* Moves a window by its handle to the given x and y coordinates.
*
* @param {number} handle - The handle ID of the window to be resized.
* @param {Point} newOrigin - The new size of the window.
* @returns {void}
*/
export function moveWindow(handle: number, newOrigin: Point): void

export const screen: Screen;
28 changes: 13 additions & 15 deletions src/linux/window_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,22 @@ bool focusWindow(const WindowHandle windowHandle) {
return false;
}

bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect) {
bool resizeWindow(const WindowHandle windowHandle, const MMSize newSize) {
Display* display = XGetMainDisplay();
if (display != NULL && windowHandle >= 0) {
XWindowChanges changes;

//size
changes.width = rect.size.width;
changes.height = rect.size.height;

//origin
changes.x = rect.origin.x;
changes.y = rect.origin.y;

// Resize and move the window
XConfigureWindow(display, windowHandle, CWX | CWY | CWWidth | CWHeight, &changes);
auto status = XResizeWindow(display, windowHandle, newSize.width, newSize.height);
XFlush(display);

return true;
return status;
}
return false;
}

bool moveWindow(const WindowHandle windowHandle, const MMPoint newOrigin) {
Display* display = XGetMainDisplay();
if (display != NULL && windowHandle >= 0) {
auto status = XMoveWindow(display, windowHandle, newOrigin.x, newOrigin.y);
XFlush(display);
return status;
}
return false;
}
Loading