Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonUnch authored Jan 13, 2021
1 parent 3acb6be commit 208fa52
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 61 deletions.
Binary file modified AltDrag.ini
Binary file not shown.
2 changes: 1 addition & 1 deletion altdrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// App
#define APP_NAME L"AltDrag"
#define APP_NAMEA "AltDrag"
#define APP_VERSION "1.33"
#define APP_VERSION "1.34"

// Messages
#define WM_TRAY (WM_USER+1)
Expand Down
2 changes: 1 addition & 1 deletion altdrag.nsi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# define the name of the installer
!define APP_NAME "AltDrag"
!define APP_VERSION "1.32"
!define APP_VERSION "1.34"

# define the name of the installer
OutFile "${APP_NAME}${APP_VERSION}-inst.exe"
Expand Down
6 changes: 3 additions & 3 deletions altdrag.rc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "x86.exe.manifest"

#define VS_VERSION_INFO 1
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,3,0
PRODUCTVERSION 1,3,3,0
FILEVERSION 1,3,4,0
PRODUCTVERSION 1,3,4,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
Expand All @@ -21,7 +21,7 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "AltDrag"
VALUE "FileVersion", "1.33"
VALUE "FileVersion", "1.34"
VALUE "InternalName", "altdrag"
VALUE "OriginalFilename", "AltDrag.exe"
VALUE "CompanyName", "Gillibert Software"
Expand Down
111 changes: 58 additions & 53 deletions hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct {
char PearceDBClick;
unsigned char CenterFraction;
unsigned char RefreshRate;

unsigned char MinAlpha;

struct {
Expand Down Expand Up @@ -176,8 +176,9 @@ struct {
struct blacklist Snaplist;
struct blacklist MDIs;
struct blacklist Pause;
struct blacklist MMBLower;
} BlkLst = { {NULL, 0, NULL}, {NULL, 0, NULL}, {NULL, 0, NULL}
, {NULL, 0, NULL}, {NULL, 0, NULL} };
, {NULL, 0, NULL}, {NULL, 0, NULL}, {NULL, 0, NULL}};

// Cursor data
HWND cursorwnd = NULL;
Expand Down Expand Up @@ -873,42 +874,43 @@ static int IsHotkey(int key)
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
//// This is used to detect is the window was snapped normally outside of
//// AltDrag, in this case if windows was in the database, we restore it.
//static int IsWindowSnapped(HWND hwnd)
//{
// RECT rect, mon;
// if(!GetWindowRectL(state.hwnd, &rect)) return 0;
//
// MONITORINFO mi = { sizeof(MONITORINFO) };
// GetMonitorInfo(state.origin.monitor, &mi);
// mon = mi.rcWork;
//
// int W = rect.right - rect.left;
// int H = rect.bottom - rect.top;
// int SW = mon.right - mon.left;
// int SH = mon.bottom - mon.top;
//
// if (W == SW/2) {
// if(H == SH){
// if (rect.top == 0 && (rect.left == 0 || rect.right == SW))
// return 1;
// } else if (H == SH/2) {
// if (rect.top == 0 || rect.bottom == SH)
// return 1;
// }
// }
// return 0;
//}
/////////////////////////////////////////////////////////////////////////////
// This is used to detect is the window was snapped normally outside of
// AltDrag, in this case the window appears as normal
// ie: wndpl.showCmd=SW_SHOWNORMAL, but if the WM_RESTORE command is sent,
// The window will be restored. This is a non documented behaviour.
// Works under Windows 10 20H2 at least...
static int IsWindowSnapped(HWND hwnd)
{
RECT rect, mon;
if(!GetWindowRectL(state.hwnd, &rect)) return 0;

MONITORINFO mi = { sizeof(MONITORINFO) };
GetMonitorInfo(state.origin.monitor, &mi);
mon = mi.rcWork;

int W = rect.right - rect.left;
int H = rect.bottom - rect.top;
int SW = mon.right - mon.left;
int SH = mon.bottom - mon.top;

if (W == SW/2) {
if(H == SH){
if (rect.top == 0 && (rect.left == 0 || rect.right == SW))
return 1;
} else if (H == SH/2) {
if (rect.top == 0 || rect.bottom == SH)
return 1;
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
static void RestoreOldWin(POINT pt)
{
// Restore old width/height?
int restore = 0;
if (state.wndentry->restore
// || (IsWindowSnapped(state.hwnd) && state.wndentry->width && state.wndentry->height)
) {
if (state.wndentry->restore) {
restore = 1;
state.origin.width = state.wndentry->width;
state.origin.height = state.wndentry->height;
Expand Down Expand Up @@ -945,7 +947,11 @@ static void MouseMove(POINT pt)
{ LastWin.hwnd = NULL; UnhookMouse(); return; }

// Restore Aero snapped window
if(state.action == AC_MOVE && !was_moving) RestoreOldWin(pt);
int was_snapped=0;
if(state.action == AC_MOVE && !was_moving){
RestoreOldWin(pt);
was_snapped = IsWindowSnapped(state.hwnd);
}

static RECT wnd;
if (!was_moving && !GetWindowRect(state.hwnd, &wnd)) return;
Expand Down Expand Up @@ -995,14 +1001,14 @@ static void MouseMove(POINT pt)
if ( ret == 1) return;

// Restore window if maximized
if (IsZoomed(state.hwnd)) {
if (IsZoomed(state.hwnd) || was_snapped) {
WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
GetWindowPlacement(state.hwnd, &wndpl);
wndpl.showCmd = SW_RESTORE;
SetWindowPlacement(state.hwnd, &wndpl);
// Update wndwidth and wndheight
wndwidth = wndpl.rcNormalPosition.right-wndpl.rcNormalPosition.left;
wndheight = wndpl.rcNormalPosition.bottom-wndpl.rcNormalPosition.top;
wndwidth = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
wndheight = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
}
} else if (state.action == AC_RESIZE) {
// Restore the window (to monitor size) if it's maximized
Expand Down Expand Up @@ -1288,33 +1294,29 @@ static HWND GetClass_HideIfTooltip(POINT pt, HWND hwnd, wchar_t *classname, size
return hwnd;
}
/////////////////////////////////////////////////////////////////////////////
// 1.29
static int ScrollPointedWindow(POINT pt, DWORD mouseData, WPARAM wParam)
{
// Get window and foreground window
HWND hwnd = WindowFromPoint(pt);
HWND foreground = GetForegroundWindow();

// Return if no window or if foreground window is blacklisted
if (!hwnd || ( foreground && (
blacklisted(foreground, &BlkLst.Windows)
||blacklistedP(foreground, &BlkLst.Processes) ) )
) {
if (hwnd == NULL || (foreground != NULL && blacklisted(foreground,&BlkLst.Windows)))
return 0;
}

// Get class behind eventual tooltip
wchar_t classname[256] = L"";
hwnd = GetClass_HideIfTooltip(pt, hwnd, classname, ARR_SZ(classname));
wchar_t classname[20] = L"";
hwnd=GetClass_HideIfTooltip(pt, hwnd, classname, ARR_SZ(classname));

// If it's a groupbox, grab the real window
LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
if ((style&BS_GROUPBOX) && !wcscmp(classname, L"Button")) {
if ((style&BS_GROUPBOX) && !wcscmp(classname,L"Button")) {
HWND groupbox = hwnd;
EnableWindow(groupbox, FALSE);
hwnd = WindowFromPoint(pt);
EnableWindow(groupbox, TRUE);
if (!hwnd) return 0;
} else if (!wcscmp(classname, L"Windows.UI.Core.CoreWindow")) {
return 0;
}

// Get wheel info
Expand All @@ -1323,7 +1325,7 @@ static int ScrollPointedWindow(POINT pt, DWORD mouseData, WPARAM wParam)

// Change WM_MOUSEWHEEL to WM_MOUSEHWHEEL if shift is being depressed
// Introduced in Vista and far from all programs have implemented it.
if (wParam == WM_MOUSEWHEEL && state.shift) {
if (wParam == WM_MOUSEWHEEL && state.shift && (GetAsyncKeyState(VK_SHIFT)&0x8000)) {
wParam = WM_MOUSEHWHEEL;
wp = (-GET_WHEEL_DELTA_WPARAM(mouseData)) << 16; // Up is left, down is right
}
Expand All @@ -1338,10 +1340,10 @@ static int ScrollPointedWindow(POINT pt, DWORD mouseData, WPARAM wParam)
if (GetAsyncKeyState(VK_XBUTTON2)&0x8000) wp |= MK_XBUTTON2;

// Forward scroll message
if(PostMessage(hwnd, wParam, wp, lp))
return 1;
else
return 0;
SendMessage(hwnd, wParam, wp, lp);

// Block original scroll event
return 1;
}
/////////////////////////////////////////////////////////////////////////////
static int ActionAltTab(POINT pt, int delta)
Expand Down Expand Up @@ -2083,7 +2085,7 @@ __declspec(dllexport) LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wPara
HWND hwnd = WindowFromPoint(pt);
if (!hwnd) return CallNextHookEx(NULL, nCode, wParam, lParam);
hwnd = GetAncestor(hwnd, GA_ROOT);
if (blacklisted(hwnd, &BlkLst.Windows))
if (blacklisted(hwnd, &BlkLst.Windows) || blacklisted(hwnd, &BlkLst.MMBLower))
return CallNextHookEx(NULL, nCode, wParam, lParam);

int area = SendMessage(hwnd, WM_NCHITTEST, 0, MAKELPARAM(pt.x,pt.y));
Expand All @@ -2092,6 +2094,8 @@ __declspec(dllexport) LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wPara
if (state.shift) {
PostMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
} else {
if(hwnd == GetAncestor(GetForegroundWindow(), GA_ROOT))
SetForegroundWindow(GetWindow(hwnd, GW_HWNDPREV));
SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
}
return 1;
Expand Down Expand Up @@ -2422,6 +2426,7 @@ __declspec(dllexport) void Load(void)
readblacklist(inipath, &BlkLst.Snaplist, L"Snaplist");
readblacklist(inipath, &BlkLst.MDIs, L"MDIs");
readblacklist(inipath, &BlkLst.Pause, L"Pause");
readblacklist(inipath, &BlkLst.MMBLower, L"MMBLower");

// Allocate some memory
monitors_alloc++;
Expand Down
6 changes: 3 additions & 3 deletions hooks.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define VS_VERSION_INFO 1
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,3,0
PRODUCTVERSION 1,3,3,0
FILEVERSION 1,3,4,0
PRODUCTVERSION 1,3,4,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
Expand All @@ -15,7 +15,7 @@ BEGIN
VALUE "FileDescription", "Hooks for AltDrag"
VALUE "InternalName", "hooks"
VALUE "OriginalFilename", "hooks.dll"
VALUE "FileVersion", "1.33"
VALUE "FileVersion", "1.34"
VALUE "CompanyName", "Gillibert Software"
VALUE "LegalCopyright", "Stefan Sundin"
END
Expand Down

0 comments on commit 208fa52

Please sign in to comment.