1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// license:BSD-3-Clause
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
// debugbaseinfo.c - Win32 debug window handling
//
//============================================================
#include "emu.h"
#include "debugbaseinfo.h"
debugbase_info::debugbase_info(debugger_windows_interface &debugger) :
m_debugger(debugger),
m_machine(debugger.machine()),
m_metrics(debugger.metrics()),
m_waiting_for_debugger(debugger.waiting_for_debugger())
{
}
void debugbase_info::smart_set_window_bounds(HWND wnd, HWND parent, RECT const &bounds)
{
// first get the current bounds, relative to the parent
RECT curbounds;
GetWindowRect(wnd, &curbounds);
if (parent)
{
RECT parentbounds;
GetWindowRect(parent, &parentbounds);
curbounds.top -= parentbounds.top;
curbounds.bottom -= parentbounds.top;
curbounds.left -= parentbounds.left;
curbounds.right -= parentbounds.left;
}
// if the position matches, don't change it
int flags = 0;
if (curbounds.top == bounds.top && curbounds.left == bounds.left)
flags |= SWP_NOMOVE;
if ((curbounds.bottom - curbounds.top) == (bounds.bottom - bounds.top) &&
(curbounds.right - curbounds.left) == (bounds.right - bounds.left))
flags |= SWP_NOSIZE;
// if we need to, reposition the window
if (flags != (SWP_NOMOVE | SWP_NOSIZE))
{
SetWindowPos(
wnd, nullptr,
bounds.left, bounds.top,
bounds.right - bounds.left, bounds.bottom - bounds.top,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | flags);
}
}
void debugbase_info::smart_show_window(HWND wnd, bool show)
{
bool const visible = bool(IsWindowVisible(wnd));
if (visible != show)
ShowWindow(wnd, show ? SW_SHOW : SW_HIDE);
}
|