Skip to content

Commit

Permalink
Merge branch 'jl/LH-1/fix-docking-bug' into next
Browse files Browse the repository at this point in the history
* jl/LH-1/fix-docking-bug:
  Docking Find in Files: Fixed the hanging bug
  Gripper: Remove any modifications post destruction.
  Docking: Properly initialize docking related structures and classes.
  Docking manager: Fix typo in comment.
  Precompiled headers: Include npp_debug.h in debug as a convenience.
  Notepad_plus creation: _hSelf should not be set during creation.

[#1 state:candidate]

Signed-off-by: Thell Fowler <git@tbfowler.name>
  • Loading branch information
Thell Fowler committed Oct 26, 2009
2 parents d9f5681 + 391526c commit 719fa85
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 38 deletions.
23 changes: 11 additions & 12 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7788,7 +7788,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}

// Menu
_mainMenuHandle = ::GetMenu(_hSelf);
_mainMenuHandle = ::GetMenu(hwnd);
int langPos2BeRemoved = MENUINDEX_LANGUAGE+1;
if (nppGUI._isLangMenuCompact)
langPos2BeRemoved = MENUINDEX_LANGUAGE;
Expand Down Expand Up @@ -7843,8 +7843,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
::SendMessage(hwnd, NPPM_INTERNAL_SETCARETWIDTH, 0, 0);
::SendMessage(hwnd, NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0);

_configStyleDlg->init(_hInst, _hSelf);
_preferenceDlg->init(_hInst, _hSelf);
_configStyleDlg->init(_hInst, hwnd);
_preferenceDlg->init(_hInst, hwnd);

//Marker Margin config
_mainEditView->setMakerStyle(svp1._folderStyle);
Expand Down Expand Up @@ -7918,7 +7918,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
//--Splitter Section--//
bool isVertical = (nppGUI._splitterPos == POS_VERTICAL);

_subSplitter->init(_hInst, _hSelf);
_subSplitter->init(_hInst, hwnd);
_subSplitter->create(_mainDocTab, _subDocTab, 8, DYNAMIC, 50, isVertical);

//--Status Bar Section--//
Expand All @@ -7936,13 +7936,13 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_dockingManager->init(_hInst, hwnd, &_pMainWindow);

if (nppGUI._isMinimizedToTray)
_pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT(""));
_pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT(""));

checkSyncState();

// Plugin Manager
NppData nppData;
nppData._nppHandle = _hSelf;
nppData._nppHandle = hwnd;
nppData._scintillaMainHandle = _mainEditView->getHSelf();
nppData._scintillaSecondHandle = _subEditView->getHSelf();

Expand Down Expand Up @@ -8019,7 +8019,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
nppGUI._excludedLangList[i]._cmdID = cmdID;
nppGUI._excludedLangList[i]._langName = itemName;
::DeleteMenu(hLangMenu, cmdID, MF_BYCOMMAND);
DrawMenuBar(_hSelf);
DrawMenuBar(hwnd);
}
}

Expand Down Expand Up @@ -8103,19 +8103,19 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
pNppParam->reloadPluginCmds();

// Shortcut Accelerator : should be the last one since it will capture all the shortcuts
_accelerator.init(_mainMenuHandle, _hSelf);
_accelerator.init(_mainMenuHandle, hwnd);
pNppParam->setAccelerator(&_accelerator);

// Scintilla key accelerator
std::vector<HWND> scints;
scints.push_back(_mainEditView->getHSelf());
scints.push_back(_subEditView->getHSelf());
_scintaccelerator.init(&scints, _mainMenuHandle, _hSelf);
_scintaccelerator.init(&scints, _mainMenuHandle, hwnd);

pNppParam->setScintillaAccelerator(&_scintaccelerator);
_scintaccelerator.updateKeys();

::DrawMenuBar(_hSelf);
::DrawMenuBar(hwnd);


//-- Tool Bar Section --//
Expand All @@ -8125,7 +8125,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
// To notify plugins that toolbar icons can be registered
SCNotification scnN;
scnN.nmhdr.code = NPPN_TBMODIFICATION;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.hwndFrom = hwnd;
scnN.nmhdr.idFrom = 0;
_pluginsManager->notify(&scnN);

Expand Down Expand Up @@ -9978,7 +9978,6 @@ LRESULT CALLBACK Notepad_plus::Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM
// then stock it into GWL_USERDATA index in order to retrieve afterward
{
Notepad_plus *pM30ide = (Notepad_plus *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
pM30ide->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG)pM30ide);

return TRUE;
Expand Down
11 changes: 4 additions & 7 deletions PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ void FindReplaceDlg::findAllIn(InWhat op)
_pFinder = new Finder();
_pFinder->init(_hInst, _hSelf, _ppEditView);

tTbData data = {0};
tTbData data;
_pFinder->create(&data, false);
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_pFinder->getHSelf());
// define the default docking behaviour
Expand Down Expand Up @@ -1730,15 +1730,12 @@ void FindReplaceDlg::findAllIn(InWhat op)
if (::SendMessage(_hParent, cmdid, 0, 0))
{
wsprintf(_findAllResultStr, TEXT("%d hits"), _findAllResult);
if (_findAllResult)
{
focusOnFinder();
}
else
getFocus(); // no hits
focusOnFinder();
}
else // error - search folder doesn't exist
{
::SendMessage(_hSelf, WM_NEXTDLGCTL, (WPARAM)::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO), TRUE);
}
}


Expand Down
18 changes: 18 additions & 0 deletions PowerEditor/src/WinControls/DockingWnd/Docking.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ struct tTbData{
RECT rcFloat; // floating position
int iPrevCont; // stores the privious container (toggling between float and dock)
const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin

tTbData():
hClient(NULL),
pszName(NULL),
dlgID(-1),
uMask(0),
hIconTab(NULL),
pszAddInfo(NULL),
iPrevCont(-1),
pszModuleName(NULL)
{
memset(&rcFloat, 0, sizeof(RECT));
}

~tTbData()
{

}
};


Expand Down
2 changes: 0 additions & 2 deletions PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "Tabbar.h"
#include "npp_winver.h"

#include "Debug/npp_debug.h"

#ifndef WH_MOUSE_LL
#define WH_MOUSE_LL 14
#endif
Expand Down
23 changes: 20 additions & 3 deletions PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,26 @@ struct tTbData;
class DockingDlgInterface : public StaticDialog
{
public:
DockingDlgInterface(): StaticDialog() {};
DockingDlgInterface(int dlgID): StaticDialog(),
_dlgID(dlgID), _isFloating(TRUE), _iDockedPos(0) {};
DockingDlgInterface():
StaticDialog(),
_HSource(NULL),
_data(NULL),
_dlgID(-1),
_isFloating(TRUE),
_iDockedPos(0)
{
memset(_pluginName, 0, MAX_PATH * sizeof(TCHAR));
}
DockingDlgInterface(int dlgID):
StaticDialog(),
_HSource(NULL),
_data(NULL),
_dlgID(dlgID),
_isFloating(TRUE),
_iDockedPos(0)
{
memset(_pluginName, 0, MAX_PATH * sizeof(TCHAR));
}

virtual void init(HINSTANCE hInst, HWND parent);

Expand Down
7 changes: 4 additions & 3 deletions PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
}
case DMM_MOVE:
{
Gripper* pGripper = new Gripper;
// Gripper will self delete on WM_DESTROY
Gripper* pGripper = new Gripper;
pGripper->init(_hInst, _hParent);
pGripper->startGrip((DockingCont*)lParam, this, pGripper);
pGripper->startGrip((DockingCont*)lParam, this);
break;
}
case DMM_MOVE_SPLITTER:
Expand Down Expand Up @@ -882,7 +883,7 @@ void DockingManager::toggleVisTb(DockingCont* pContSrc, DockingCont* pContTgt)

for (size_t iTb = 0; iTb < vTbData.size(); iTb++)
{
/* get data one by another */
/* get data one by one */
tTbData* TbData = vTbData[iTb];
toggleTb(pContSrc, pContTgt, TbData);
}
Expand Down
9 changes: 2 additions & 7 deletions PowerEditor/src/WinControls/DockingWnd/Gripper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ Gripper::Gripper()
_startMovingFromTab = FALSE;
_iItem = 0;

_pRes = 0;

_hdc = NULL;
_hbm = NULL;
_hbrush = NULL;
Expand All @@ -108,11 +106,10 @@ Gripper::Gripper()
}


void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr, void* pRes)
void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr)
{
_pDockMgr = pDockMgr;
_pCont = pCont;
_pRes = pRes;

_pDockMgr->getDockInfo(&_dockData);

Expand Down Expand Up @@ -209,7 +206,6 @@ LRESULT Gripper::runProc(UINT message, WPARAM wParam, LPARAM lParam)
onButtonUp();

::DestroyWindow(_hSelf);
_hSelf = NULL;
return TRUE;
}
case DMM_CANCEL_MOVE:
Expand All @@ -228,15 +224,14 @@ LRESULT Gripper::runProc(UINT message, WPARAM wParam, LPARAM lParam)
::UnhookWindowsHookEx(hookKeyboard);

::DestroyWindow(_hSelf);
_hSelf = NULL;
return FALSE;
}
case WM_DESTROY:
{
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
::SetWindowPos(_hParent, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
_pCont->focusClient();
delete _pRes;
delete this;
break;
}
default:
Expand Down
5 changes: 1 addition & 4 deletions PowerEditor/src/WinControls/DockingWnd/Gripper.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Gripper
_hParent = hParent;
};

void startGrip(DockingCont* pCont, DockingManager* pDockMgr, void* pRes);
void startGrip(DockingCont* pCont, DockingManager* pDockMgr);

~Gripper() {
if (_hdc) {
Expand Down Expand Up @@ -121,9 +121,6 @@ protected :
RECT _rcItem;
TCITEM _tcItem;

// resource pointer of THIS class
void *_pRes;

HDC _hdc;
HBITMAP _hbm;
HBRUSH _hbrush;
Expand Down
2 changes: 2 additions & 0 deletions PowerEditor/src/precompiled_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@
// Power Editor
#include "Common.h"

#include "Debug/npp_debug.h"

#endif // PRECOMPILED_HEADERS_H

0 comments on commit 719fa85

Please sign in to comment.