-
-
Notifications
You must be signed in to change notification settings - Fork 38
Retrieve window dimensions #23
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
Changes from 51 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
ba301b4
(#17) Started window_manager.h interface
b780ff0
(#17) window_manager MacOS implementation to retrieve list of window …
5b8b55e
(#17) Updated CmakeLists.txt to include MacOS window_manager implemen…
1e1108c
(#17) Export getWindows and getWindowRect functions
65a1997
(#17) Added window_manager source files for both Linux and Windows
36ba190
(#17) Changed window handles to int64_t, added getWindowTitle function
s1hofmann c96a86a
(#17) Updated windowhandle types, added implementation for getWindowT…
s1hofmann 4e92f3c
(#17) Windows implementation, WIP
s1hofmann e9d4d7f
(#17) Exported getWindowTitle
s1hofmann 72b1609
(#17) Added window_manager source file in Windows
s1hofmann 2f1cf9b
(#17) Added plattform specific typedef for window handles
aa4cc6f
(#17) Refactored window manager macOS implementation
b273dbb
(#17) Switched to typedef for windowhandle
c76079f
(#17) Changed point and size types to use int64_t
s1hofmann d656baa
(#17) Updated Windows implementation
s1hofmann c5bbe90
(#17) WindowHandle now refers to int64_t on all platforms
s1hofmann d934da5
(#17) Added Linux implementation of window_manager
s1hofmann b193e7a
(#17) Linux implementation, WIP
s1hofmann 2cc06ac
(#22) Working retrival of window name in Linux
s1hofmann 7240b4c
:(#22) Working retrival of window name in Linux
s1hofmann dc910e1
(#17) Retrival of window rect, WIP
s1hofmann fef4c28
(#17) Updated getWindows implementation on Linux
s1hofmann 760e05b
(#15) getActiveWindow implementation on Linux
s1hofmann c068dac
(#15) getActiveWindow on macOS, fixed wrong order of width and height…
d412c3d
(#15) getActiveWindow implementation on Windows
s1hofmann 37321e4
(#17) Updated typings
s1hofmann d96afeb
Merge branch 'feature/17/retrieve_window_dimensions' of github.com:nu…
s1hofmann c790569
(#17) Added integration test
s1hofmann 7a86432
(#17) Added window integration tests to CI pipelines
s1hofmann 7243b0e
(#17) Updated test code for window tests
s1hofmann b0325a8
(#17) Removed test code inside electron app
s1hofmann ac51ca0
(#17) Switched to Spectron + Jest tests
s1hofmann c3dced4
(#17) Shortened test script by using added 145 packages in 1.069s
s1hofmann 785e5b9
(#17) Updated test to focus our Electron window due to problems with …
s1hofmann 4cd61f6
(#17) Trying to work around the batch windows problem
s1hofmann 430d6cb
(#17) Made window toplevel by default
s1hofmann 01bbe79
(#17) Focus still does not work with batch windows
s1hofmann f108dd6
(#17) Fixed call of focus on browserWindow
s1hofmann 3bd63cc
(#17) Add call to minimize before calling focus to fix window focus, …
s1hofmann cf18af3
(#17) Additional timeouts for focus handling
s1hofmann 1394e9d
(#17) Added call to restore() to fix issues on macOS
s1hofmann 2ec2fbe
(#17) Moved focus workaround from beforeEach to beforeAll
s1hofmann 674b7cb
(#17) Removed border offset for x and y coordinates of window rect on…
s1hofmann e7d78d3
(#17) Also remove border from width and height
s1hofmann 439de7a
(#17) Switched to using already existing XGetMainDisplay and XCloseMa…
s1hofmann 277a948
(#17) Added extern declaration to avoid symbol mangeling
s1hofmann 162d7c4
(#17) Fix type conversion
s1hofmann e0fccf1
(#17) Added additional tests for window handling
1017ea8
(#17) Reverted minimized window test since minimized windows are not …
95d50c4
(#17) Added proper interfaces for return types
107fb79
(#17) Refactored window_manager code on Linux to properly use existin…
19c2f5a
Update src/macos/window_manager.mm
s1hofmann ce2345c
Update src/win32/window_manager.cc
s1hofmann 6d62a7c
(#17) Added doc comment regarding the use of instead of
b81d49e
(#17) Added doc comments to window_manager interface
63b74a7
(#17) Handling of possible value for
204ffdf
(#17) Added doc comment regarding EnumWindowsProc
c650f00
(#17) Added checks for valid windows
0021b37
(#17) Fixed removed variable
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <X11/Xlib.h> | ||
#include <X11/Xutil.h> | ||
#include "../window_manager.h" | ||
extern "C" { | ||
#include "../xdisplay.h" | ||
} | ||
|
||
WindowHandle getActiveWindow() { | ||
Display* xServer = XGetMainDisplay(); | ||
Window window; | ||
if (xServer != NULL) { | ||
int32_t revertToWindow; | ||
XGetInputFocus(xServer, &window, &revertToWindow); | ||
return window; | ||
} | ||
return -1; | ||
} | ||
|
||
std::vector<WindowHandle> getWindows() { | ||
Display* xServer = XGetMainDisplay(); | ||
std::vector<WindowHandle> windowHandles; | ||
if (xServer != NULL) { | ||
Window defaultRootWindow = DefaultRootWindow(xServer); | ||
Window rootWindow; | ||
Window parentWindow; | ||
Window* windowList; | ||
uint32_t windowCount; | ||
|
||
Status queryTreeResult = XQueryTree(xServer, defaultRootWindow, &rootWindow, &parentWindow, &windowList, &windowCount); | ||
if (queryTreeResult > 0) { | ||
for (size_t idx = 0; idx < windowCount; ++idx) { | ||
windowHandles.push_back(windowList[idx]); | ||
} | ||
} | ||
} | ||
return windowHandles; | ||
} | ||
|
||
std::string getWindowTitle(const WindowHandle windowHandle) { | ||
Display* xServer = XGetMainDisplay(); | ||
std::string windowName = ""; | ||
if (xServer != NULL) { | ||
XTextProperty windowTextProperty; | ||
Status getWMNameResult = XGetWMName(xServer, windowHandle, &windowTextProperty); | ||
if (getWMNameResult > 0) { | ||
windowName = std::string(reinterpret_cast<const char*>(windowTextProperty.value)); | ||
} | ||
} | ||
return windowName; | ||
} | ||
|
||
MMRect getWindowRect(const WindowHandle windowHandle) { | ||
Display* xServer = XGetMainDisplay(); | ||
MMRect windowRect = MMRectMake(0, 0, 0, 0); | ||
if (xServer != NULL) { | ||
Window rootWindow; | ||
int32_t x, y; | ||
uint32_t width, height, border_width, border_height; | ||
Status getXGeometryResult = XGetGeometry(xServer, windowHandle, &rootWindow, &x, &y, &width, &height, &border_width, &border_height); | ||
if (getXGeometryResult > 0) { | ||
windowRect = MMRectMake(x, y, width, height); | ||
} | ||
} | ||
return windowRect; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <AppKit/AppKit.h> | ||
#import <ApplicationServices/ApplicationServices.h> | ||
#include "../window_manager.h" | ||
|
||
NSDictionary* getWindowInfo(int64_t windowHandle) { | ||
CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; | ||
CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); | ||
|
||
for (NSDictionary *info in (NSArray *)windowList) { | ||
NSNumber *windowNumber = info[(id)kCGWindowNumber]; | ||
|
||
if (windowHandle == [windowNumber intValue]) { | ||
CFRetain(info); | ||
CFRelease(windowList); | ||
return info; | ||
} | ||
} | ||
|
||
if (windowList) { | ||
CFRelease(windowList); | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
WindowHandle getActiveWindow() { | ||
CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; | ||
CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); | ||
|
||
for (NSDictionary *info in (NSArray *)windowList) { | ||
NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; | ||
NSNumber *windowNumber = info[(id)kCGWindowNumber]; | ||
|
||
auto app = [NSRunningApplication runningApplicationWithProcessIdentifier: [ownerPid intValue]]; | ||
|
||
if (![app isActive]) { | ||
continue; | ||
} | ||
|
||
CFRelease(windowList); | ||
return [windowNumber intValue]; | ||
} | ||
|
||
if (windowList) { | ||
CFRelease(windowList); | ||
} | ||
return -1; | ||
} | ||
|
||
std::vector<WindowHandle> getWindows() { | ||
CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; | ||
CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); | ||
|
||
std::vector<WindowHandle> windowHandles; | ||
|
||
for (NSDictionary *info in (NSArray *)windowList) { | ||
NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; | ||
NSNumber *windowNumber = info[(id)kCGWindowNumber]; | ||
|
||
auto app = [NSRunningApplication runningApplicationWithProcessIdentifier: [ownerPid intValue]]; | ||
auto path = app ? [app.bundleURL.path UTF8String] : ""; | ||
|
||
if (app && path != "") { | ||
windowHandles.push_back([windowNumber intValue]); | ||
} | ||
} | ||
|
||
if (windowList) { | ||
CFRelease(windowList); | ||
} | ||
|
||
return windowHandles; | ||
} | ||
|
||
MMRect getWindowRect(const WindowHandle windowHandle) { | ||
auto windowInfo = getWindowInfo(windowHandle); | ||
if (windowInfo != nullptr) { | ||
CGRect windowRect; | ||
if (CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)windowInfo[(id)kCGWindowBounds], &windowRect)) { | ||
return MMRectMake(windowRect.origin.x, windowRect.origin.y, windowRect.size.width, windowRect.size.height); | ||
} | ||
return MMRectMake(0, 0, 0, 0); | ||
} | ||
return MMRectMake(0, 0, 0, 0); | ||
} | ||
|
||
std::string getWindowTitle(const WindowHandle windowHandle) { | ||
auto windowInfo = getWindowInfo(windowHandle); | ||
if (windowInfo != nullptr) { | ||
NSString *windowName = windowInfo[(id)kCGWindowName]; | ||
return [windowName UTF8String]; | ||
} | ||
return ""; | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.