2025-11-27 16:36:46 +00:00
|
|
|
// Copyright (c) 2016-2025 AtomAI, All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// See the COPYRIGHT file at the top-level directory of this distribution and at
|
2016-12-10 18:41:08 +00:00
|
|
|
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
|
2016-11-10 06:34:13 +00:00
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
2025-06-08 17:51:14 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0>
|
|
|
|
|
//
|
|
|
|
|
// This file may not be copied, modified, or distributed
|
2016-11-10 06:34:13 +00:00
|
|
|
// except according to those terms.
|
|
|
|
|
|
2016-11-05 08:16:26 +00:00
|
|
|
#include "alert_c.h"
|
2016-11-10 10:59:37 +00:00
|
|
|
#include "window.h"
|
2018-08-13 12:10:54 +00:00
|
|
|
#include "win_sys.h"
|
2016-11-05 08:16:26 +00:00
|
|
|
|
2022-11-28 01:55:45 +00:00
|
|
|
void min_window(uintptr pid, bool state, int8_t isPid){
|
2018-07-29 15:53:54 +00:00
|
|
|
#if defined(IS_MACOSX)
|
|
|
|
|
// return 0;
|
|
|
|
|
AXUIElementRef axID = AXUIElementCreateApplication(pid);
|
2022-02-03 11:03:32 +00:00
|
|
|
AXUIElementSetAttributeValue(axID, kAXMinimizedAttribute,
|
|
|
|
|
state ? kCFBooleanTrue : kCFBooleanFalse);
|
2018-07-29 15:53:54 +00:00
|
|
|
#elif defined(USE_X11)
|
|
|
|
|
// Ignore X errors
|
|
|
|
|
XDismissErrors();
|
|
|
|
|
// SetState((Window)pid, STATE_MINIMIZE, state);
|
|
|
|
|
#elif defined(IS_WINDOWS)
|
2022-11-28 22:21:03 +00:00
|
|
|
HWND hwnd = getHwnd(pid, isPid);
|
|
|
|
|
win_min(hwnd, state);
|
2018-07-29 15:53:54 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-28 01:55:45 +00:00
|
|
|
void max_window(uintptr pid, bool state, int8_t isPid){
|
2018-07-29 15:53:54 +00:00
|
|
|
#if defined(IS_MACOSX)
|
|
|
|
|
// return 0;
|
|
|
|
|
#elif defined(USE_X11)
|
|
|
|
|
XDismissErrors();
|
|
|
|
|
// SetState((Window)pid, STATE_MINIMIZE, false);
|
|
|
|
|
// SetState((Window)pid, STATE_MAXIMIZE, state);
|
|
|
|
|
#elif defined(IS_WINDOWS)
|
2022-11-28 22:21:03 +00:00
|
|
|
HWND hwnd = getHwnd(pid, isPid);
|
|
|
|
|
win_max(hwnd, state);
|
2018-07-29 15:53:54 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
uintptr get_handle(){
|
2022-02-03 11:03:32 +00:00
|
|
|
MData mData = get_active();
|
2018-08-21 17:04:23 +00:00
|
|
|
|
2017-02-06 11:10:10 +00:00
|
|
|
#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
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-03 11:03:32 +00:00
|
|
|
uintptr b_get_handle() {
|
2022-01-23 18:17:15 +00:00
|
|
|
#if defined(IS_MACOSX)
|
2024-10-07 00:40:34 +00:00
|
|
|
return (uintptr)pub_mData.CgID;
|
2022-01-23 18:17:15 +00:00
|
|
|
#elif defined(USE_X11)
|
2024-10-07 00:40:34 +00:00
|
|
|
return (uintptr)pub_mData.XWin;
|
2022-01-23 18:17:15 +00:00
|
|
|
#elif defined(IS_WINDOWS)
|
2024-10-07 00:40:34 +00:00
|
|
|
return (uintptr)pub_mData.HWnd;
|
2022-01-23 18:17:15 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-28 01:55:45 +00:00
|
|
|
void active_PID(uintptr pid, int8_t isPid){
|
|
|
|
|
MData win = set_handle_pid(pid, isPid);
|
2022-02-03 11:03:32 +00:00
|
|
|
set_active(win);
|
2017-01-18 12:34:35 +00:00
|
|
|
}
|