mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-08 12:08:05 -05:00
Merge branch 'run-miniminzed'
This commit is contained in:
commit
9a4d379e76
@ -35,6 +35,30 @@ function kernel32_defines(lib) {
|
|||||||
lib.lazy_bind("GetProcAddress", win32.FARPROC, win32.HMODULE, win32.LPCSTR);
|
lib.lazy_bind("GetProcAddress", win32.FARPROC, win32.HMODULE, win32.LPCSTR);
|
||||||
lib.lazy_bind("GetCurrentThreadId", win32.DWORD);
|
lib.lazy_bind("GetCurrentThreadId", win32.DWORD);
|
||||||
|
|
||||||
|
this.STARTUPINFO = ctypes.StructType("STARTUPINFO", [
|
||||||
|
{ "cb": win32.DWORD },
|
||||||
|
{ "lpReserved": win32.LPTSTR },
|
||||||
|
{ "lpDesktop": win32.LPTSTR },
|
||||||
|
{ "lpTitle": win32.LPTSTR },
|
||||||
|
{ "dwX": win32.DWORD },
|
||||||
|
{ "dwY": win32.DWORD },
|
||||||
|
{ "dwXSize": win32.DWORD },
|
||||||
|
{ "dwYSize": win32.DWORD },
|
||||||
|
{ "dwXCountChars": win32.DWORD },
|
||||||
|
{ "dwYCountChars": win32.DWORD },
|
||||||
|
{ "dwFillAttribute": win32.DWORD },
|
||||||
|
{ "dwFlags": win32.DWORD },
|
||||||
|
{ "wShowWindow": win32.WORD },
|
||||||
|
{ "cbReserved2": win32.WORD },
|
||||||
|
{ "lpReserved2": win32.LPBYTE },
|
||||||
|
{ "hStdInput": win32.HANDLE },
|
||||||
|
{ "hStdOutput": win32.HANDLE },
|
||||||
|
{ "hStdError": win32.HANDLE }
|
||||||
|
]);
|
||||||
|
this.LPSTARTUPINFO = ctypes.PointerType(this.STARTUPINFO);
|
||||||
|
|
||||||
|
lib.lazy_bind("GetStartupInfoW", ctypes.void_t, this.LPSTARTUPINFO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new ctypes_library(KERNEL32_LIBNAME, KERNEL32_ABIS, kernel32_defines, this);
|
new ctypes_library(KERNEL32_LIBNAME, KERNEL32_ABIS, kernel32_defines, this);
|
||||||
|
@ -372,6 +372,22 @@ function user32_defines(lib) {
|
|||||||
lib.lazy_bind("GetCursorPos", win32.BOOL, win32.LPPOINT);
|
lib.lazy_bind("GetCursorPos", win32.BOOL, win32.LPPOINT);
|
||||||
lib.lazy_bind("GetMessagePos", win32.DWORD);
|
lib.lazy_bind("GetMessagePos", win32.DWORD);
|
||||||
|
|
||||||
|
this.WINDOWINFO = ctypes.StructType("WINDOWINFO", [
|
||||||
|
{ "cbSize": win32.DWORD },
|
||||||
|
{ "rcWindow": win32.RECT },
|
||||||
|
{ "rcClient": win32.RECT },
|
||||||
|
{ "dwStyle": win32.DWORD },
|
||||||
|
{ "dwExStyle": win32.DWORD },
|
||||||
|
{ "dwWindowStatus": win32.DWORD },
|
||||||
|
{ "cxWindowBorders": win32.UINT },
|
||||||
|
{ "cyWindowBorders": win32.UINT },
|
||||||
|
{ "atomWindowType": win32.ATOM },
|
||||||
|
{ "wCreatorVersion": win32.WORD }
|
||||||
|
]);
|
||||||
|
this.PWINDOWINFO = this.LPWINDOWINFO = this.WINDOWINFO.ptr;
|
||||||
|
|
||||||
|
lib.lazy_bind("GetWindowInfo", win32.BOOL, win32.HWND, this.WINDOWINFO.ptr);
|
||||||
|
|
||||||
this.WINDOWPLACEMENT = ctypes.StructType("WINDOWPLACEMENT", [
|
this.WINDOWPLACEMENT = ctypes.StructType("WINDOWPLACEMENT", [
|
||||||
{ "length": win32.UINT },
|
{ "length": win32.UINT },
|
||||||
{ "flags": win32.UINT },
|
{ "flags": win32.UINT },
|
||||||
@ -411,6 +427,7 @@ function user32_defines(lib) {
|
|||||||
this.SWP_NOREPOSITION = this.SWP_NOOWNERZORDER;
|
this.SWP_NOREPOSITION = this.SWP_NOOWNERZORDER;
|
||||||
this.SWP_DEFERERASE = 0x2000;
|
this.SWP_DEFERERASE = 0x2000;
|
||||||
this.SWP_ASYNCWINDOWPOS = 0x4000;
|
this.SWP_ASYNCWINDOWPOS = 0x4000;
|
||||||
|
this.SWP_STATECHANGED = 0x8000; /* Undocumented */
|
||||||
|
|
||||||
lib.lazy_bind("GetSysColor", win32.DWORD, ctypes.int);
|
lib.lazy_bind("GetSysColor", win32.DWORD, ctypes.int);
|
||||||
this.COLOR_MENU = 4;
|
this.COLOR_MENU = 4;
|
||||||
|
@ -21,6 +21,7 @@ var win32 = new function() {
|
|||||||
|
|
||||||
this.BOOL = ctypes.bool;
|
this.BOOL = ctypes.bool;
|
||||||
this.BYTE = ctypes.unsigned_char;
|
this.BYTE = ctypes.unsigned_char;
|
||||||
|
this.LPBYTE = this.BYTE.ptr;
|
||||||
this.INT_PTR = is64bit ? ctypes.int64_t : ctypes.int;
|
this.INT_PTR = is64bit ? ctypes.int64_t : ctypes.int;
|
||||||
this.UINT = ctypes.unsigned_int;
|
this.UINT = ctypes.unsigned_int;
|
||||||
this.UINT_PTR = is64bit ? ctypes.uint64_t : ctypes.unsigned_int;
|
this.UINT_PTR = is64bit ? ctypes.uint64_t : ctypes.unsigned_int;
|
||||||
|
@ -70,7 +70,8 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
let procPrev = firetray.Handler.wndProcsOrig.get(wid);
|
let procPrev = firetray.Handler.wndProcsOrig.get(wid);
|
||||||
return user32.CallWindowProcW(user32.WNDPROC(procPrev), hWnd, uMsg, wParam, lParam); // or DefWindowProcW
|
return user32.CallWindowProcW(
|
||||||
|
user32.WNDPROC(procPrev), hWnd, uMsg, wParam, lParam); // or DefWindowProcW
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -81,22 +82,27 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow
|
|||||||
* - a WH_CALLWNDPROC hook doesn't catch SWP_SHOWWINDOW
|
* - a WH_CALLWNDPROC hook doesn't catch SWP_SHOWWINDOW
|
||||||
* - chaining WNDPROCs crashes the app (UserCallWinProcCheckWow or ffi_call)
|
* - chaining WNDPROCs crashes the app (UserCallWinProcCheckWow or ffi_call)
|
||||||
*/
|
*/
|
||||||
firetray.Window.startupShowCount = 0;
|
|
||||||
firetray.Window.wndProcStartup = function(hWnd, uMsg, wParam, lParam) {
|
firetray.Window.wndProcStartup = function(hWnd, uMsg, wParam, lParam) {
|
||||||
let wid = firetray.Win32.hwndToHexStr(hWnd);
|
let wid = firetray.Win32.hwndToHexStr(hWnd);
|
||||||
|
|
||||||
if (uMsg === win32.WM_WINDOWPOSCHANGING) {
|
if (uMsg === win32.WM_WINDOWPOSCHANGING) {
|
||||||
let posStruct = ctypes.cast(win32.LPARAM(lParam), user32.WINDOWPOS.ptr).contents;
|
let posStruct = ctypes.cast(win32.LPARAM(lParam),
|
||||||
|
user32.WINDOWPOS.ptr).contents;
|
||||||
|
|
||||||
let isShowing = ((posStruct.flags & user32.SWP_SHOWWINDOW) != 0);
|
let isShowing = ((posStruct.flags & user32.SWP_SHOWWINDOW) != 0);
|
||||||
if (isShowing) {
|
if (isShowing) {
|
||||||
log.debug("wndProcStartup CALLED with WM_WINDOWPOSCHANGING/SWP_SHOWWINDOW");
|
log.debug("wndProcStartup CALLED with WM_WINDOWPOSCHANGING/SWP_SHOWWINDOW");
|
||||||
firetray.Window.startupShowCount += 1;
|
firetray.Window.startup.showCount += 1;
|
||||||
|
|
||||||
if (firetray.Window.startupShowCount < 2) { // hide
|
if (firetray.Window.startup.showCount < 2) { // hide
|
||||||
log.debug("start_hidden");
|
log.debug("start_hidden");
|
||||||
// Modifying a JS posStruct field does really modify the WINDOWPOS C
|
// Modifying posStruct is modifying lParam, which is passed onwards!
|
||||||
// struct behind lParam !
|
if (firetray.Window.startup.showSpecial) {
|
||||||
posStruct.flags &= ~user32.SWP_SHOWWINDOW;
|
posStruct.flags &= user32.SWP_NOSIZE|user32.SWP_NOMOVE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
posStruct.flags &= ~user32.SWP_SHOWWINDOW;
|
||||||
|
}
|
||||||
let force = true;
|
let force = true;
|
||||||
firetray.Handler.addPopupMenuWindowItemAndSeparatorMaybe(wid, force);
|
firetray.Handler.addPopupMenuWindowItemAndSeparatorMaybe(wid, force);
|
||||||
}
|
}
|
||||||
@ -108,8 +114,17 @@ firetray.Window.wndProcStartup = function(hWnd, uMsg, wParam, lParam) {
|
|||||||
mapBak: null
|
mapBak: null
|
||||||
});
|
});
|
||||||
firetray.Handler.wndProcsStartup.remove(wid);
|
firetray.Handler.wndProcsStartup.remove(wid);
|
||||||
|
|
||||||
|
if (firetray.Window.startup.showSpecial) {
|
||||||
|
let placement = new user32.WINDOWPLACEMENT;
|
||||||
|
let ret = user32.GetWindowPlacement(hWnd, placement.address());
|
||||||
|
firetray.js.assert(ret, "GetWindowPlacement failed.");
|
||||||
|
placement.showCmd = firetray.Window.startup.showSpecial;
|
||||||
|
user32.SetWindowPlacement(hWnd, placement.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let procPrev = firetray.Handler.wndProcsOrig.get(wid);
|
let procPrev = firetray.Handler.wndProcsOrig.get(wid);
|
||||||
@ -197,6 +212,13 @@ firetray.Handler.registerWindow = function(win) {
|
|||||||
let proc, map;
|
let proc, map;
|
||||||
if (!firetray.Handler.appStarted &&
|
if (!firetray.Handler.appStarted &&
|
||||||
firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
||||||
|
let startupInfo = new kernel32.STARTUPINFO;
|
||||||
|
kernel32.GetStartupInfoW(startupInfo.address());
|
||||||
|
let showSpecial = ([
|
||||||
|
user32.SW_SHOWMINNOACTIVE, user32.SW_SHOWMINIMIZED,
|
||||||
|
user32.SW_SHOWMAXIMIZED
|
||||||
|
].indexOf(startupInfo.wShowWindow) > -1) ? startupInfo.wShowWindow : 0;
|
||||||
|
firetray.Window.startup = {showCount: 0, showSpecial: showSpecial};
|
||||||
proc = firetray.Window.wndProcStartup; map = firetray.Handler.wndProcsStartup;
|
proc = firetray.Window.wndProcStartup; map = firetray.Handler.wndProcsStartup;
|
||||||
} else {
|
} else {
|
||||||
proc = firetray.Window.wndProc; map = firetray.Handler.wndProcs;
|
proc = firetray.Window.wndProc; map = firetray.Handler.wndProcs;
|
||||||
|
Loading…
Reference in New Issue
Block a user