Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new features #286

Merged
merged 4 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions altsnap.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ void ShowSClickMenu(HWND hwnd, LPARAM param)
{ 0, MF_SEPARATOR, NULL }, /* ------------------------ */
{ AC_KILL, MF_STRING, l10n->input_actions_kill},
{ 0, MF_SEPARATOR, NULL }, /* ------------------------ */
{ AC_MOVEONOFF, CHK(LP_MOVEONOFF), l10n->input_actions_moveonoff},
{ 0, MF_SEPARATOR, NULL }, /* ------------------------ */
{ AC_NONE, MF_STRING, l10n->input_actions_nothing},
};
#undef CHK
#undef K
unsigned i;
for (i=0; i < ARR_SZ(mnlst); i++) {
if ( (ACMenuItems>>i)&1 )
AppendMenu(menu, mnlst[i].mf, mnlst[i].action, mnlst[i].str);
if ( (ACMenuItems>>i)&1 ) // Put the action in the HIWORD of wParam
AppendMenu(menu, mnlst[i].mf, mnlst[i].action<<16, mnlst[i].str);
}
TrackPopupMenu(menu, GetSystemMetrics(SM_MENUDROPALIGNMENT), pt.x, pt.y, 0, hwnd, NULL);
DestroyMenu(menu);
Expand Down Expand Up @@ -383,8 +385,20 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, char *szCmdLine, in
// Look for previous instance
if (!multi && !GetPrivateProfileInt(L"Advanced", L"MultipleInstances", 0, inipath)){
if (quiet) return 0;
HWND previnst = FindWindow(APP_NAME, NULL);

HWND previnst = FindWindow(APP_NAME, L"");
if (previnst) {
// Ask old HotKey window to perform an action.
const char *actionstr = strstr(params, "-a");
if (actionstr && actionstr[2] && actionstr[3] && actionstr[4]) {
enum action action = MapActionA(&actionstr[3]);
HWND msghwnd;
if ((msghwnd = FindWindow( APP_NAME"-HotKeys", L""))) {
PostMessage(msghwnd, WM_HOTKEY, (actionstr[2] == 'p')*0x1000+action, 0);
return 0;
}
}
// Update old instance if no action to be made.
LOG("Previous instance found and no -multi mode")
if(hide) PostMessage(previnst, WM_CLOSECONFIG, 0, 0);
if(config) PostMessage(previnst, WM_OPENCONFIG, 0, 0);
Expand Down Expand Up @@ -458,6 +472,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, char *szCmdLine, in
}
}

UnhookSystem();
DestroyWindow(g_hwnd);
LOG("GOOD NORMAL EXIT");
return msg.wParam;
Expand Down
2 changes: 1 addition & 1 deletion altsnap.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define the name of the installer

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

#define VS_VERSION_INFO 1
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,5,6,0
PRODUCTVERSION 1,5,6,0
FILEVERSION 1,5,67,0
PRODUCTVERSION 1,5,7,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
Expand All @@ -21,7 +21,7 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "AltSnap"
VALUE "FileVersion", "1.56"
VALUE "FileVersion", "1.57"
VALUE "InternalName", "altsnap"
VALUE "OriginalFilename", "AltSnap.exe"
VALUE "CompanyName", "Gillibert Software"
Expand Down
37 changes: 26 additions & 11 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ INT_PTR CALLBACK MousePageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
{L"NStacked", l10n->input_actions_nstacked},
{L"PStacked", l10n->input_actions_pstacked},
{L"StackList", l10n->input_actions_stacklist},
{L"StackList2", l10n->input_actions_stacklist2},
{L"Roll", l10n->input_actions_roll},
{L"AlwaysOnTop", l10n->input_actions_alwaysontop},
{L"Borderless", l10n->input_actions_borderless},
Expand Down Expand Up @@ -866,8 +867,13 @@ static LRESULT WINAPI PickShortcutWinProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
VK_LWIN, VK_RWIN
, '\0'
};
// static int was_enabled;

switch (msg) {
// case WM_CREATE: {
// was_enabled = ENABLED();
// if (was_enabled) UnhookSystem();
// } break;
case WM_CHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
Expand Down Expand Up @@ -902,6 +908,7 @@ static LRESULT WINAPI PickShortcutWinProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
HWND sethwnd = GetDlgItem(phwnd, IDC_SHORTCUTS_SET);
EnableWindow(sethwnd, TRUE);
SetFocus(sethwnd);
// if (was_enabled) HookSystem();
} break;
default:
return DefWindowProc(hwnd, msg, wp, lp);
Expand Down Expand Up @@ -944,6 +951,7 @@ INT_PTR CALLBACK KeyboardPageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
{L"Kill", l10n->input_actions_kill},
{L"Pause", l10n->input_actions_pause},
{L"Resume", l10n->input_actions_resume},
{L"ASOnOff", l10n->input_actions_asonoff},
{L"Lower", l10n->input_actions_lower},
{L"Roll", l10n->input_actions_roll},
{L"AlwaysOnTop", l10n->input_actions_alwaysontop},
Expand All @@ -956,6 +964,7 @@ INT_PTR CALLBACK KeyboardPageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
{L"PStacked", l10n->input_actions_pstacked},
{L"PStacked2", l10n->input_actions_pstacked2},
{L"StackList", l10n->input_actions_stacklist},
{L"StackList2", l10n->input_actions_stacklist2},
{L"MLZone", l10n->input_actions_mlzone},
{L"MTZone", l10n->input_actions_mtzone},
{L"MRZone", l10n->input_actions_mrzone},
Expand Down Expand Up @@ -1413,10 +1422,12 @@ LRESULT CALLBACK TestWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
} break;

case WM_PAINT: {
/* We must keep track of pens and delete them.*/
RECT wRect;
HPEN pen = (HPEN) CreatePen(PS_SOLID, 2, GetSysColor(COLOR_BTNTEXT));
const HPEN pen = (HPEN) CreatePen(PS_SOLID, 2, GetSysColor(COLOR_BTNTEXT));
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
int SavedCD = SaveDC(hdc);

GetWindowRect(hwnd, &wRect);
POINT Offset = { wRect.left, wRect.top };
Expand All @@ -1441,16 +1452,16 @@ LRESULT CALLBACK TestWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
, width
, (height+height*centerfrac/100)/2 + Offset.y);
if (centermode == 3) {
HPEN rcpen = (HPEN) CreatePen(PS_SOLID, 2, GetSysColor(COLOR_BTNFACE));
SelectObject(hdc, rcpen);
HPEN bgpen = (HPEN) CreatePen(PS_SOLID, 2, GetSysColor(COLOR_BTNFACE));
HPEN prevpen = SelectObject(hdc, bgpen);
Rectangle(hdc
, Offset.x+(width-width*centerfrac/100)/2
, Offset.y+(height-height*centerfrac/100)/2
, (width+width*centerfrac/100)/2 + Offset.x
, (height+height*centerfrac/100)/2 + Offset.y);
DeleteObject(rcpen);

SelectObject(hdc, pen);
SelectObject(hdc, prevpen); // restore pen
DeleteObject(bgpen); // delete bgpen.
// Draw diagonal lines
POINT pta[2] = {{Offset.x+(width-width*centerfrac/100)/2, Offset.y+(height-height*centerfrac/100)/2},
{ (width+width*centerfrac/100)/2 + Offset.x, (height+height*centerfrac/100)/2 + Offset.y}
};
Expand All @@ -1460,19 +1471,18 @@ LRESULT CALLBACK TestWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
};
Polyline(hdc, ptb, 2);

rcpen = (HPEN) CreatePen(PS_DOT, 1, GetSysColor(COLOR_BTNTEXT));
SelectObject(hdc, rcpen);
HPEN dotpen = (HPEN) CreatePen(PS_DOT, 1, GetSysColor(COLOR_BTNTEXT));
prevpen = SelectObject(hdc, dotpen);
SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
Rectangle(hdc
, Offset.x+(width-width*centerfrac/100)/2
, Offset.y+(height-height*centerfrac/100)/2
, (width+width*centerfrac/100)/2 + Offset.x
, (height+height*centerfrac/100)/2 + Offset.y);
DeleteObject(rcpen);
SelectObject(hdc, prevpen); // restore pen
DeleteObject(dotpen); // so we can delete this one...
}

DeleteObject(pen);

// Draw textual info....
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
Expand All @@ -1486,7 +1496,12 @@ LRESULT CALLBACK TestWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
RECT trc2 = {5, 5, crc.right, splitheight};
DrawText(hdc, str, wcslen(str), &trc2, DT_NOCLIP|DT_TABSTOP);
}

RestoreDC(hdc, SavedCD);
EndPaint(hwnd, &ps);

DeleteObject(pen); // delete pen

return 0;
} break;

Expand Down
Loading