mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-10 18:23:54 +00:00
Fixed error and update code style
This commit is contained in:
parent
fd7080b0ea
commit
fa1051211b
@ -276,7 +276,7 @@ typedef struct _Bounds Bounds;
|
|||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
if (nItems == 4) {
|
if (nItems == 4) {
|
||||||
frame.X = (int32) result[0];
|
frame.X = (int32) result[0];
|
||||||
frame.Y = (int32) result[2]
|
frame.Y = (int32) result[2];
|
||||||
frame.W = (int32) result[0] + (int32) result[1];
|
frame.W = (int32) result[0] + (int32) result[1];
|
||||||
frame.H = (int32) result[2] + (int32) result[3];
|
frame.H = (int32) result[2] + (int32) result[3];
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ Bounds get_bounds(uintptr pid, uintptr isHwnd){
|
|||||||
MData win;
|
MData win;
|
||||||
win.XWin = (Window)pid;
|
win.XWin = (Window)pid;
|
||||||
|
|
||||||
Bounds client = GetClient();
|
Bounds client = get_client(pid, isHwnd);
|
||||||
Bounds frame = GetFrame(win);
|
Bounds frame = GetFrame(win);
|
||||||
|
|
||||||
bounds.X = client.X - frame.X;
|
bounds.X = client.X - frame.X;
|
||||||
@ -91,6 +91,8 @@ Bounds get_client(uintptr pid, uintptr isHwnd){
|
|||||||
|
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
|
|
||||||
|
Display *rDisplay = XOpenDisplay(NULL);
|
||||||
|
|
||||||
// Ignore X errors
|
// Ignore X errors
|
||||||
XDismissErrors();
|
XDismissErrors();
|
||||||
MData win;
|
MData win;
|
||||||
@ -103,17 +105,17 @@ Bounds get_client(uintptr pid, uintptr isHwnd){
|
|||||||
int32 x = 0, y = 0;
|
int32 x = 0, y = 0;
|
||||||
|
|
||||||
// Check if the window is the root
|
// Check if the window is the root
|
||||||
XQueryTree(rDisplay, win,
|
XQueryTree(rDisplay, win.XWin,
|
||||||
&root, &parent, &children, &count);
|
&root, &parent, &children, &count);
|
||||||
if (children) { XFree(children); }
|
if (children) { XFree(children); }
|
||||||
|
|
||||||
// Retrieve window attributes
|
// Retrieve window attributes
|
||||||
XWindowAttributes attr = { 0 };
|
XWindowAttributes attr = { 0 };
|
||||||
XGetWindowAttributes(rDisplay, win, &attr);
|
XGetWindowAttributes(rDisplay, win.XWin, &attr);
|
||||||
|
|
||||||
// Coordinates must be translated
|
// Coordinates must be translated
|
||||||
if (parent != attr.root){
|
if (parent != attr.root){
|
||||||
XTranslateCoordinates(rDisplay, win, attr.root, attr.x,
|
XTranslateCoordinates(rDisplay, win.XWin, attr.root, attr.x,
|
||||||
attr.y, &x, &y, &parent);
|
attr.y, &x, &y, &parent);
|
||||||
}
|
}
|
||||||
// Coordinates can be left alone
|
// Coordinates can be left alone
|
||||||
|
@ -275,7 +275,7 @@ bool IsMinimized(void){
|
|||||||
|
|
||||||
// Ignore X errors
|
// Ignore X errors
|
||||||
// XDismissErrors();
|
// XDismissErrors();
|
||||||
// return GetState (mData.XWin, STATE_MINIMIZE);
|
// return GetState(mData.XWin, STATE_MINIMIZE);
|
||||||
|
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ bool IsMaximized(void){
|
|||||||
|
|
||||||
// Ignore X errors
|
// Ignore X errors
|
||||||
// XDismissErrors();
|
// XDismissErrors();
|
||||||
// return GetState (mData.XWin, STATE_MAXIMIZE);
|
// return GetState(mData.XWin, STATE_MAXIMIZE);
|
||||||
|
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ MData GetActive(void){
|
|||||||
|
|
||||||
// Get the current active window
|
// Get the current active window
|
||||||
result.XWin = XDefaultRootWindow(rDisplay);
|
result.XWin = XDefaultRootWindow(rDisplay);
|
||||||
void* active = GetWindowProperty(result,WM_ACTIVE,NULL);
|
void* active = GetWindowProperty(result, WM_ACTIVE, NULL);
|
||||||
|
|
||||||
// Check result value
|
// Check result value
|
||||||
if (active != NULL) {
|
if (active != NULL) {
|
||||||
@ -607,8 +607,9 @@ char *GetTitle(){
|
|||||||
|
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
return GetWindowText
|
return GetWindowText(
|
||||||
(mData.HWnd, mData.Title, 512) > 0 ? mData.Title : "";
|
mData.HWnd, mData.Title, 512) > 0 ?
|
||||||
|
mData.Title : "";
|
||||||
// return GetWindowText
|
// return GetWindowText
|
||||||
// (mData.HWnd, name, 512) > 0 ?
|
// (mData.HWnd, name, 512) > 0 ?
|
||||||
// _UTF8Encode(name) : "null";
|
// _UTF8Encode(name) : "null";
|
||||||
@ -624,10 +625,9 @@ int32 WGetPID(void){
|
|||||||
|
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
// Attempt to retrieve the window pid
|
// Attempt to retrieve the window pid
|
||||||
if (AXUIElementGetPid(mData.AxID, &pid)
|
if (AXUIElementGetPid(mData.AxID, &pid)== kAXErrorSuccess) {
|
||||||
== kAXErrorSuccess) {
|
return pid;
|
||||||
return pid;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user