mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
update code style
This commit is contained in:
parent
35f5016d33
commit
15233120e0
@ -15,8 +15,8 @@
|
|||||||
// #include "../MMBitmap_c.h"
|
// #include "../MMBitmap_c.h"
|
||||||
|
|
||||||
void padHex(MMRGBHex color, char* hex){
|
void padHex(MMRGBHex color, char* hex){
|
||||||
//Length needs to be 7 because snprintf includes a terminating null.
|
// Length needs to be 7 because snprintf includes a terminating null.
|
||||||
//Use %06x to pad hex value with leading 0s.
|
// Use %06x to pad hex value with leading 0s.
|
||||||
snprintf(hex, 7, "%06x", color);
|
snprintf(hex, 7, "%06x", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
// #include "../base/xdisplay_c.h"
|
// #include "../base/xdisplay_c.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MMSize getMainDisplaySize(void)
|
MMSize getMainDisplaySize(void){
|
||||||
{
|
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
CGDirectDisplayID displayID = CGMainDisplayID();
|
CGDirectDisplayID displayID = CGMainDisplayID();
|
||||||
return MMSizeMake(CGDisplayPixelsWide(displayID),
|
return MMSizeMake(CGDisplayPixelsWide(displayID),
|
||||||
@ -26,8 +25,7 @@ MMSize getMainDisplaySize(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pointVisibleOnMainDisplay(MMPoint point)
|
bool pointVisibleOnMainDisplay(MMPoint point){
|
||||||
{
|
|
||||||
MMSize displaySize = getMainDisplaySize();
|
MMSize displaySize = getMainDisplaySize();
|
||||||
return point.x < displaySize.width && point.y < displaySize.height;
|
return point.x < displaySize.width && point.y < displaySize.height;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MMBitmapRef copyMMBitmapFromDisplayInRect(MMRect rect)
|
MMBitmapRef copyMMBitmapFromDisplayInRect(MMRect rect){
|
||||||
{
|
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
|
|
||||||
MMBitmapRef bitmap = NULL;
|
MMBitmapRef bitmap = NULL;
|
||||||
|
@ -37,7 +37,7 @@ void aWindow();
|
|||||||
|
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
|
|
||||||
static Boolean (*gAXIsProcessTrustedWithOptions) (CFDictionaryRef);
|
static Boolean(*gAXIsProcessTrustedWithOptions) (CFDictionaryRef);
|
||||||
|
|
||||||
static CFStringRef* gkAXTrustedCheckOptionPrompt;
|
static CFStringRef* gkAXTrustedCheckOptionPrompt;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ void aWindow();
|
|||||||
CFRelease(wlist);
|
CFRelease(wlist);
|
||||||
|
|
||||||
// Check whether the resulting array is populated
|
// Check whether the resulting array is populated
|
||||||
if (info != NULL && CFArrayGetCount (info) > 0){
|
if (info != NULL && CFArrayGetCount(info) > 0){
|
||||||
// Retrieve description from info array
|
// Retrieve description from info array
|
||||||
CFDictionaryRef desc = (CFDictionaryRef)CFArrayGetValueAtIndex(info, 0);
|
CFDictionaryRef desc = (CFDictionaryRef)CFArrayGetValueAtIndex(info, 0);
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ void aWindow();
|
|||||||
// Check results
|
// Check results
|
||||||
if (temp == win){
|
if (temp == win){
|
||||||
// Retain element
|
// Retain element
|
||||||
CFRetain (element);
|
CFRetain(element);
|
||||||
result = element;
|
result = element;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -129,12 +129,12 @@ void aWindow();
|
|||||||
void XDismissErrors (void){
|
void XDismissErrors (void){
|
||||||
Display *rDisplay = XOpenDisplay(NULL);
|
Display *rDisplay = XOpenDisplay(NULL);
|
||||||
// Save old handler and dismiss errors
|
// Save old handler and dismiss errors
|
||||||
mOld = XSetErrorHandler (XHandleError);
|
mOld = XSetErrorHandler(XHandleError);
|
||||||
// Flush output buffer
|
// Flush output buffer
|
||||||
XSync (rDisplay, False);
|
XSync(rDisplay, False);
|
||||||
|
|
||||||
// Reinstate old handler
|
// Reinstate old handler
|
||||||
XSetErrorHandler (mOld);
|
XSetErrorHandler(mOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Definitions
|
// Definitions
|
||||||
@ -576,7 +576,7 @@ void SetActive(const MData win){
|
|||||||
!= kAXErrorSuccess){
|
!= kAXErrorSuccess){
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
// Attempt to retrieve the PID of the window
|
// Attempt to retrieve the PID of the window
|
||||||
if (AXUIElementGetPid (win.AxID, &pid)
|
if (AXUIElementGetPid(win.AxID, &pid)
|
||||||
!= kAXErrorSuccess || !pid) {return;}
|
!= kAXErrorSuccess || !pid) {return;}
|
||||||
|
|
||||||
// Ignore deprecated warnings
|
// Ignore deprecated warnings
|
||||||
@ -589,7 +589,7 @@ void SetActive(const MData win){
|
|||||||
|
|
||||||
ProcessSerialNumber psn;
|
ProcessSerialNumber psn;
|
||||||
// Attempt to retrieve the process psn
|
// Attempt to retrieve the process psn
|
||||||
if (GetProcessForPID (pid, &psn) == 0){
|
if (GetProcessForPID(pid, &psn) == 0){
|
||||||
// Gracefully activate process
|
// Gracefully activate process
|
||||||
SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
|
SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
|
||||||
}
|
}
|
||||||
@ -609,8 +609,7 @@ void SetActive(const MData win){
|
|||||||
if (WM_ACTIVE != None){
|
if (WM_ACTIVE != None){
|
||||||
// Retrieve the screen number
|
// Retrieve the screen number
|
||||||
XWindowAttributes attr = { 0 };
|
XWindowAttributes attr = { 0 };
|
||||||
XGetWindowAttributes (rDisplay,
|
XGetWindowAttributes(rDisplay, win.XWin, &attr);
|
||||||
win.XWin, &attr);
|
|
||||||
int s = XScreenNumberOfScreen(attr.screen);
|
int s = XScreenNumberOfScreen(attr.screen);
|
||||||
|
|
||||||
// Prepare an event
|
// Prepare an event
|
||||||
@ -676,7 +675,7 @@ MData GetActive(void){
|
|||||||
|
|
||||||
CGWindowID win = 0;
|
CGWindowID win = 0;
|
||||||
// Use undocumented API to get WID
|
// Use undocumented API to get WID
|
||||||
if (_AXUIElementGetWindow (element, &win)
|
if (_AXUIElementGetWindow(element, &win)
|
||||||
== kAXErrorSuccess && win){
|
== kAXErrorSuccess && win){
|
||||||
// Manually set internals
|
// Manually set internals
|
||||||
result.CgID = win;
|
result.CgID = win;
|
||||||
@ -763,8 +762,8 @@ void SetTopMost(bool state){
|
|||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
|
|
||||||
// Ignore X errors
|
// Ignore X errors
|
||||||
// XDismissErrors ();
|
// XDismissErrors();
|
||||||
// SetState (mData.XWin, STATE_TOPMOST, state);
|
// SetState(mData.XWin, STATE_TOPMOST, state);
|
||||||
|
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
@ -817,7 +816,7 @@ char *GetTitle(){
|
|||||||
CFStringRef data = NULL;
|
CFStringRef data = NULL;
|
||||||
|
|
||||||
// Determine the current title of the window
|
// Determine the current title of the window
|
||||||
if (AXUIElementCopyAttributeValue (mData.AxID,
|
if (AXUIElementCopyAttributeValue(mData.AxID,
|
||||||
kAXTitleAttribute, (CFTypeRef*) &data)
|
kAXTitleAttribute, (CFTypeRef*) &data)
|
||||||
== kAXErrorSuccess && data != NULL){
|
== kAXErrorSuccess && data != NULL){
|
||||||
char conv[512];
|
char conv[512];
|
||||||
@ -872,7 +871,7 @@ char *GetTitle(){
|
|||||||
(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";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user