Update x11 alert() code and remove ScaleY()

This commit is contained in:
vcaesar 2022-01-23 14:17:15 -04:00
parent 8defbda0cd
commit bafa051f92
5 changed files with 23 additions and 51 deletions

View File

@ -422,13 +422,6 @@ func ScaleX() int {
return int(C.scale_x())
}
// Deprecated: use the ScaledF(),
//
// ScaleY get primary display vertical DPI scale factor, drop
func ScaleY() int {
return int(C.scale_y())
}
// Deprecated: use the ScaledF(),
//
// Scale get the screen scale (only windows old), drop
@ -1254,7 +1247,6 @@ func showAlert(title, msg string, args ...string) bool {
func IsValid() bool {
abool := C.is_valid()
gbool := bool(abool)
// fmt.Println("bool---------", gbool)
return gbool
}

View File

@ -183,7 +183,12 @@ func DisplaysNum() int {
func Alert(title, msg string, args ...string) bool {
defaultBtn, cancelBtn := alertArgs(args...)
c := `xmessage -center ` + msg +
` -title ` + title + ` -buttons ` + defaultBtn + ":0," + cancelBtn + ":1" + ` -default Ok`
` -title ` + title + ` -buttons ` + defaultBtn + ":0,"
if cancleBtn != "" {
c += cancelBtn + ":1"
}
c += ` -default ` + defaultBtn
out, err := Run(c)
if err != nil {
fmt.Println("Alert: ", err, ". ", string(out))

View File

@ -15,28 +15,17 @@
int show_alert(const char *title, const char *msg,
const char *defaultButton, const char *cancelButton){
int alert = showAlert(title, msg, defaultButton, cancelButton);
return alert;
return showAlert(title, msg, defaultButton, cancelButton);
}
intptr scale_x(){
return scaleX();
}
intptr scale_y(){
return scaleY();
}
bool is_valid(){
bool abool = IsValid();
return abool;
return IsValid();
}
// int find_window(char* name){
// int z = findwindow(name);
// return z;
// }
void min_window(uintptr pid, bool state, uintptr isHwnd){
#if defined(IS_MACOSX)
// return 0;
@ -80,8 +69,7 @@ void close_window(uintptr pid, uintptr isHwnd){
}
bool set_handle(uintptr handle){
bool hwnd = setHandle(handle);
return hwnd;
return setHandle(handle);
}
uintptr get_handle(){
@ -96,9 +84,19 @@ uintptr get_handle(){
#endif
}
// uint32 uintptr
uintptr getHandle() {
#if defined(IS_MACOSX)
return (uintptr)mData.CgID;
#elif defined(USE_X11)
return (uintptr)mData.XWin;
#elif defined(IS_WINDOWS)
return (uintptr)mData.HWnd;
#endif
}
uintptr bget_handle(){
uintptr hwnd = getHandle();
return hwnd;
return getHandle();
}
void set_active(const MData win){

View File

@ -76,18 +76,6 @@ intptr scaleX(){
#endif
}
intptr scaleY(){
#if defined(IS_MACOSX)
return 0;
#elif defined(USE_X11)
return 0;
#elif defined(IS_WINDOWS)
HDC desktopDc = GetDC(NULL);
intptr verticalDPI = GetDeviceCaps(desktopDc, LOGPIXELSY);
return verticalDPI;
#endif
}
Bounds get_bounds(uintptr pid, uintptr isHwnd){
// Check if the window is valid
Bounds bounds;

View File

@ -232,17 +232,6 @@ bool setHandle(uintptr handle){
#endif
}
// uint32 uintptr
uintptr getHandle() {
#if defined(IS_MACOSX)
return (uintptr)mData.CgID;
#elif defined(USE_X11)
return (uintptr)mData.XWin;
#elif defined(IS_WINDOWS)
return (uintptr)mData.HWnd;
#endif
}
bool IsTopMost(void){
// Check the window validity
if (!IsValid()) {return false;}