Fixed error and update code style

This commit is contained in:
vcaesar 2018-08-13 08:53:49 -04:00
parent fd7080b0ea
commit fa1051211b
3 changed files with 16 additions and 14 deletions

View File

@ -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];
} }

View File

@ -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

View File

@ -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,8 +625,7 @@ 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;
} }