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