Dialogs open on the primary display in Windows regardless of which monitor the codeblocks window is open on. Dialogs should open on the same monitor as Code::Blocks is currently displayed on.
This patch fixes the issue. :) Patch applies using TortoiseSVN in codeblocks/src.
Topic: Multi-monitor dialog position update
Description:
! Dialogs would not open on the same screen as the parent dialog when the parent
is not on the primary display in a multi-monitor Windows environment
I followed the tabs/spaces pattern of each file. In files where I saw that the entire file followed one pattern (say hard tabs) except for one or two lines in a function I updated (that used spaces) I fixed those two lines. In files that were "mixed content" through the file, I left those alone.
If you look at the patch copy in a whitespace viewer, you will see that I was consistent for each file and did not change any patterns.
[attachment deleted by admin]
OK I'm ready to make this an option. I need to add the following function to the SDK. Where should I put it, and what class should it be a public member of? I'm thinking Manager.
static void Manager::PositionUserDialog( wxDialog* dlg )
{
if (user wants dialogs repositioned centered on parent)
{
dlg->CenterOnScreen();
}
}
template<wxDialog* D>PlaceDialog()
{
if(Manager::Get()->GetConfigManager("app")->Exists("/environment/place_dialogs"))
D->CentreOnScreen();
};
That way, we don't pollute Manager -- this does not belong in there.
EDIT: Don't blame me if I have a typo in there... it is late, and I am falling asleep... But you get the idea :)
But you'd rather put the template in the header, not the cpp
EDIT:
... and you will want to add the void which I forgot, or the compiler won't let you get away.
Yep I was a step ahead of you there. I have this in sdk\xtra_classes.h:
template<wxDialog* D> void PositionUserDialog(bool force=false)
{
if(force || Manager::Get()->GetConfigManager("app")->Exists("/environment/place_dialogs"))
D->CenterOnScreen();
}
src/main.cpp:1418
void MainFrame::OnFileOpen(wxCommandEvent& event)
{
wxFileDialog* dlg = new wxFileDialog(this,
_("Open file"),
wxEmptyString,
wxEmptyString,
SOURCE_FILES_DIALOG_FILTER,
wxOPEN | wxMULTIPLE);
dlg->SetFilterIndex(SOURCE_FILES_FILTER_INDEX);
//PositionUserDialog(dlg); <-- CRASHES ON "dlg->CenterOnScreen();" IF ENABLED
if (dlg->ShowModal() == wxID_OK)
{
wxArrayString files;
dlg->GetPaths(files);
OnDropFiles(0,0,files);
}
delete dlg;
}
it seems as are some windows-system dialogs not allowed to be CenterOnScreen'ed 8)
It's clearly a bug in wxWidgets, and it's even more clear that what I stated is the truth. A child dialog should open over the parent, end of story.
Every dialog in wxWidgets calls this when it is created:
The centering bug lies in that code.
My code worked around that by calling:
which apparently works.
Note the following declarations from wxWidgets-2.6.2\include\wx\window.h:344
// the generic centre function - centers the window on parent by`
// default or on screen if it doesn't have parent or
// wxCENTER_ON_SCREEN flag is given
void Centre( int direction = wxBOTH );
void Center( int direction = wxBOTH ) { Centre(direction); }
// centre on screen (only works for top level windows)
void CentreOnScreen(int dir = wxBOTH) { Centre(dir | wxCENTER_ON_SCREEN); }
void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); }
// centre with respect to the the parent window
void CentreOnParent(int dir = wxBOTH) { Centre(dir | wxCENTER_FRAME); }
void CenterOnParent(int dir = wxBOTH) { CentreOnParent(dir); }
The code for Centre() that handles all of the above functionality is in wxWidgets-2.6.2\src\common\wincmn.cpp:394
I'll do a diff later of the file from the one in the wxWidgets trunk and see if any changes have been made to that code. Now I'm going bowling. :)