Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Debugger branch: Placement of Windows

<< < (6/12) > >>

oBFusCATed:

--- Quote from: ollydbg on February 11, 2012, 10:30:16 am ---But the compilerdebugger dialog shows correctly. I'm not sure why this does not works under debugger_branch.

--- End quote ---
You can debug it, can't you?
If it does work in trunk, then it is a bug in the branch, so your patch is not correct.
The bug should be fixed.

(If you remember Thomas had an old signature, which was 100% true: 'Never fix a bug you don't understand!')

ollydbg:

--- Quote from: oBFusCATed on February 11, 2012, 10:59:58 am ---You can debug it, can't you?
If it does work in trunk, then it is a bug in the branch, so your patch is not correct.
The bug should be fixed.
(If you remember Thomas had an old signature, which was 100% true: 'Never fix a bug you don't understand!')

--- End quote ---
Ok, I debugged it and find the reason:

The trunk code:

--- Code: ---CompilerSettingsDlg::CompilerSettingsDlg(wxWindow* parent)
{
......

    // make sure everything is laid out properly
    GetSizer()->SetSizeHints(this);
    CentreOnParent();
}
--- End code ---
See, it is already CentreOnparent() on the constructor of the dialog.

But the debugger branch, there is no such code in DebuggerSettingsDlg::DebuggerSettingsDlg().

But the debugger branch, it DO have a CentreOnParent(); in the CompilerSettingsDlg::CompilerSettingsDlg().

--- Code: ---CompilerSettingsDlg::CompilerSettingsDlg(wxWindow* parent)
{
    // make sure everything is laid out properly
    GetSizer()->SetSizeHints(this);
    CentreOnParent();
}

--- End code ---

The solution should be:

Adding  CentreOnParent(); in DebuggerSettingsDlg::DebuggerSettingsDlg(), right?

Jenna:

--- Quote from: ollydbg on February 11, 2012, 11:53:16 am ---The solution should be:

Adding  CentreOnParent(); in DebuggerSettingsDlg::DebuggerSettingsDlg(), right?


--- End quote ---

It will most likely break the configuration made in "Settings -> View -> Enhanced multi-monitor placement", and if it does, these settings are ignored in trunk already.
I can not test at the moment.

I think this should be th eplace for changes:
The settings dialog, to be clear that it can be used for multimonitor systems and for single monitors, and possible the ability to centre a dialog oin the parent and not only on the screen (Changes in PlaceWindow).

ollydbg:

--- Quote from: jens on February 11, 2012, 12:31:50 pm ---
--- Quote from: ollydbg on February 11, 2012, 11:53:16 am ---The solution should be:

Adding  CentreOnParent(); in DebuggerSettingsDlg::DebuggerSettingsDlg(), right?


--- End quote ---

It will most likely break the configuration made in "Settings -> View -> Enhanced multi-monitor placement", and if it does, these settings are ignored in trunk already.

--- End quote ---
I'm not fully understand your meaning, here is the code:

--- Code: ---void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode, bool enforce)
{
    HMONITOR hMonitor;
    MONITORINFO mi;
    RECT        r;

    int the_mode;

    if (!w)
        cbThrow(_T("Passed NULL pointer to PlaceWindow."));

    wxWindow* referenceWindow = Manager::Get()->GetAppWindow();

    if (!referenceWindow)    // no application window available, so this is as good as we can get
        referenceWindow = w;

    wxRect windowRect = w->GetRect();

    ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app"));
    if (!enforce && cfg->ReadBool(_T("/dialog_placement/do_place")) == false)
        return;

    if (mode == pdlBest)
        the_mode = cfg->ReadInt(_T("/dialog_placement/dialog_position"), (int) pdlCentre);
    else
        the_mode = (int) mode;


    static MonitorFromWindow_t MonitorFromWindowProc = (MonitorFromWindow_t) GetProcAddress(GetModuleHandle(_T("user32.dll")), "MonitorFromWindow");
    static GetMonitorInfo_t    GetMonitorInfoProc    = (GetMonitorInfo_t)    GetProcAddress(GetModuleHandle(_T("user32.dll")), "GetMonitorInfoA");
    int monitorWidth;
    int monitorHeight;

    if (GetMonitorInfoProc)
    {
        hMonitor = MonitorFromWindowProc((HWND) referenceWindow->GetHandle(), MONITOR_DEFAULTTONEAREST);

        mi.cbSize = sizeof(mi);
        GetMonitorInfoProc(hMonitor, &mi);
        r = mi.rcWork;

        monitorWidth  = r.right - r.left;
        monitorHeight = r.bottom - r. top;
    }
    else // Win95, NT4: support only single monitor
    {
        wxDisplaySize(&monitorWidth, &monitorHeight);
        r.left = r.top = 0;
    }


    switch(the_mode)
    {
        case pdlCentre:
        {
            windowRect.x = r.left + (monitorWidth  - windowRect.width)/2;
            windowRect.y = r.top  + (monitorHeight - windowRect.height)/2;
        }
        break;


        case pdlHead:
        {
            windowRect.x = r.left + (monitorWidth  - windowRect.width)/2;
            windowRect.y = r.top  + (monitorHeight - windowRect.height)/3;
        }
        break;


        case pdlConstrain:
        {
            int x1 = windowRect.x;
            int x2 = windowRect.x + windowRect.width;
            int y1 = windowRect.y;
            int y2 = windowRect.y + windowRect.height;

            if (windowRect.width > monitorWidth) // cannot place without clipping, so centre it
            {
                x1 = r.left + (monitorWidth  - windowRect.width)/2;
                x2 = x1 + windowRect.width;
            }
            else
            {
                x2 = std::min((int) r.right, windowRect.GetRight());
                x1 = std::max(x2 - windowRect.width, (int) r.left);
                x2 = x1 + windowRect.width;
            }
            if (windowRect.height > monitorHeight) // cannot place without clipping, so centre it
            {
                y1 = r.top + (monitorHeight  - windowRect.height)/2;
                y2 = y1 + windowRect.height;
            }
            else
            {
                y2 = std::min((int) r.bottom, windowRect.GetBottom());
                y1 = std::max(y2 - windowRect.height, (int) r.top);
                y2 = y1 + windowRect.height;
            }
            windowRect = wxRect(x1, y1, x2-x1, y2-y1);
        }
        break;


        case pdlClip:
        {
            int x1 = windowRect.x;
            int x2 = windowRect.x + windowRect.width;
            int y1 = windowRect.y;
            int y2 = windowRect.y + windowRect.height;

            x1 = std::max(x1, (int) r.left);
            x2 = std::min(x2, (int) r.right);
            y1 = std::max(y1, (int) r.top);
            y2 = std::min(y2, (int) r.bottom);

            windowRect = wxRect(x1, y1, x2-x1, y2-y1);
        }
        break;
    }

    w->SetSize(windowRect.x,  windowRect.y, windowRect.width, windowRect.height, wxSIZE_ALLOW_MINUS_ONE);
}


--- End code ---

I do not check on any multiply-monitor related options, so this function is in fact do nothing and return from:

--- Code: ---    if (!enforce && cfg->ReadBool(_T("/dialog_placement/do_place")) == false)
        return;

--- End code ---

So, if you have  "Settings -> View -> Enhanced multi-monitor placement" settings check on, this function will go further to adjust the dialog position.


--- Quote ---I think this should be th eplace for changes:
The settings dialog, to be clear that it can be used for multimonitor systems and for single monitors, and possible the ability to centre a dialog oin the parent and not only on the screen (Changes in PlaceWindow).

--- End quote ---
Not fully understand this either. Sorry. :), you mean the dialog SHOULD be placed in the center of parent window or screen?

Jenna:
The settings dialog should be overworked, to make clear we can place windows in multimonitor and standard mode.
The user can decide where the window should be opened and not be forced to always get it centred on parent.

We can have centre on screen (that's what we have already, if I remember correctly), centre on parent (that is forced by the congtructor in trunk at the moment (for debuggersettings), and possible other settings, like left-top, at mouse-üposition, on left monitor, on right monitor or whatever might be useful.

It should not be so hard to implement.

I can see if I find the time and provide a patch for testing.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version