Close doc in document list on middle mouse button up

In 94b83158dc, closing doc in document list was on middle mouse button down.
This commit make it on middle mouse button up (for aligning with closing tab behaviour in Notepad++, also with OS middle mouse button click behaviour).
This commit is contained in:
Don Ho 2023-02-11 18:53:58 +01:00
parent 94b83158dc
commit 4d107e2691
4 changed files with 37 additions and 4 deletions

View File

@ -542,7 +542,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
// allocate commandLineStr buffer with the return value + 1, then call it again to get the current command line string.
#define NPPM_CREATELEXER (NPPMSG + 110)
// void* NPPN_CREATELEXER(0, const TCHAR *lexer_name)
// void* NPPM_CREATELEXER(0, const TCHAR *lexer_name)
// Returns the ILexer pointer created by Lexilla
#define NPPM_GETBOOKMARKID (NPPMSG + 111)

View File

@ -45,6 +45,24 @@ int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo
return (0 - result);
}
LRESULT run_listViewProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_MBUTTONUP:
{
// Redirect the message to parent
::SendMessage(::GetParent(hwnd), WM_PARENTNOTIFY, WM_MBUTTONUP, lParam);
return TRUE;
}
default:
break;
}
return ::CallWindowProc(oldEditProc, hwnd, message, wParam, lParam);
}
void VerticalFileSwitcher::startColumnSort()
{
// reset sorting if exts column was just disabled
@ -77,6 +95,9 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
_fileListView.initList();
_fileListView.display();
::SetWindowLongPtr(_fileListView.getHSelf(), GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_defaultListViewProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_fileListView.getHSelf(), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(listViewStaticProc)));
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
NppDarkMode::autoSubclassAndThemeWindowNotify(_hSelf);
@ -89,11 +110,13 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
return TRUE;
}
// Different from WM_MBUTTONDOWN, WM_MBUTTONUP message is not sent to parent hwnd by WIN32 API
// So we subclass listview to redirect WM_MBUTTONUP via WM_PARENTNOTIFY (as WM_MBUTTONDOWN)
case WM_PARENTNOTIFY:
{
switch ( wParam )
{
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
{
// Get item ID under cursor
LVHITTESTINFO hitInfo{};
@ -124,6 +147,7 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
break;
}
case WM_NOTIFY:
{
switch (reinterpret_cast<LPNMHDR>(lParam)->code)

View File

@ -29,6 +29,8 @@ struct sortCompareData {
int sortDirection = 0;
};
LRESULT run_listViewProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
class VerticalFileSwitcher : public DockingDlgInterface {
public:
VerticalFileSwitcher(): DockingDlgInterface(IDD_DOCLIST) {};
@ -102,14 +104,21 @@ public:
};
protected:
HMENU _hGlobalMenu = NULL;
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void initPopupMenus();
void popupMenuCmd(int cmdID);
static LRESULT CALLBACK listViewStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
const auto dlg = (VerticalFileSwitcher*)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (run_listViewProc(dlg->_defaultListViewProc, hwnd, message, wParam, lParam));
};
private:
bool colHeaderRClick = false;
int _lastSortingColumn = 0;
int _lastSortingDirection = SORT_DIRECTION_NONE;
VerticalFileSwitcherListView _fileListView;
HIMAGELIST _hImaLst = nullptr;
WNDPROC _defaultListViewProc = nullptr;
};

View File

@ -622,7 +622,7 @@
#define NPPM_INTERNAL_EXPORTFUNCLISTANDQUIT (NOTEPADPLUS_USER_INTERNAL + 46)
#define NPPM_INTERNAL_PRNTANDQUIT (NOTEPADPLUS_USER_INTERNAL + 47)
#define NPPM_INTERNAL_SAVEBACKUP (NOTEPADPLUS_USER_INTERNAL + 48)
#define NPPM_INTERNAL_STOPMONITORING (NOTEPADPLUS_USER_INTERNAL + 49) // Used by Monitoring feature
#define NPPM_INTERNAL_STOPMONITORING (NOTEPADPLUS_USER_INTERNAL + 49) // Used by Monitoring feature
#define NPPM_INTERNAL_EDGEBACKGROUND (NOTEPADPLUS_USER_INTERNAL + 50)
#define NPPM_INTERNAL_EDGEMULTISETSIZE (NOTEPADPLUS_USER_INTERNAL + 51)
#define NPPM_INTERNAL_UPDATECLICKABLELINKS (NOTEPADPLUS_USER_INTERNAL + 52)