Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for multiple monitors #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 57 additions & 6 deletions vis_milk2/Milkdrop2PcmVisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static LONG lastWindowStyle = 0;
static LONG lastWindowStyleEx = 0;

static bool fullscreen = false;
static bool stretch = false;
static RECT lastRect = { 0 };

static HMODULE module = nullptr;
Expand Down Expand Up @@ -106,14 +107,59 @@ void DeinitD3d() {
}
}

void ToggleStretch(HWND hwnd) {
if (!stretch) {
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
int left = GetSystemMetrics(SM_XVIRTUALSCREEN);
int top = GetSystemMetrics(SM_YVIRTUALSCREEN);

if (!fullscreen) {
lastWindowStyle = GetWindowLong(hwnd, GWL_STYLE);
lastWindowStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
lastWindowStyleEx &= ~WS_EX_TOPMOST;
GetWindowRect(hwnd, &lastRect);
}

d3dPp.BackBufferWidth = width;
d3dPp.BackBufferHeight = height;

pD3DDevice->Reset(&d3dPp);
SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
SetWindowLongW(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
SetWindowPos(hwnd, HWND_NOTOPMOST, left, top, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED);

stretch = true;
} else {
ShowCursor(TRUE);

int width = lastRect.right - lastRect.left;
int height = lastRect.bottom - lastRect.top;

d3dPp.BackBufferWidth = width;
d3dPp.BackBufferHeight = height;

pD3DDevice->Reset(&d3dPp);
stretch = false;

SetWindowLongW(hwnd, GWL_STYLE, lastWindowStyle);
SetWindowLongW(hwnd, GWL_EXSTYLE, lastWindowStyleEx);
SetWindowPos(hwnd, HWND_NOTOPMOST, lastRect.left, lastRect.top, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
fullscreen = false;
}

void ToggleFullScreen(HWND hwnd) {
if (!fullscreen) {
ShowCursor(FALSE);

lastWindowStyle = GetWindowLong(hwnd, GWL_STYLE);
lastWindowStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
lastWindowStyleEx &= ~WS_EX_TOPMOST;
GetWindowRect(hwnd, &lastRect);
if (!stretch) {
lastWindowStyle = GetWindowLong(hwnd, GWL_STYLE);
lastWindowStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
lastWindowStyleEx &= ~WS_EX_TOPMOST;
GetWindowRect(hwnd, &lastRect);
}

HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

Expand Down Expand Up @@ -152,6 +198,7 @@ void ToggleFullScreen(HWND hwnd) {
SetWindowPos(hwnd, HWND_NOTOPMOST, lastRect.left, lastRect.top, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
stretch = false;
}

LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
Expand Down Expand Up @@ -204,6 +251,10 @@ LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if (wParam == VK_F4) {
PostQuitMessage(0);
}
else if (wParam == VK_SHIFT)
{
ToggleStretch(hWnd);
}
else if (wParam == VK_RETURN) {
ToggleFullScreen(hWnd);
}
Expand Down Expand Up @@ -264,7 +315,7 @@ unsigned __stdcall CreateWindowAndRun(void* data) {

int windowWidth = DEFAULT_WIDTH;
int windowHeight = DEFAULT_HEIGHT;

RECT rc;
SetRect(&rc, 0, 0, windowWidth, windowHeight);
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);
Expand Down Expand Up @@ -294,7 +345,7 @@ unsigned __stdcall CreateWindowAndRun(void* data) {

SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) icon);
SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) icon);

ShowWindow(hwnd, SW_SHOW);

int lastWidth = windowWidth;
Expand Down
4 changes: 2 additions & 2 deletions vis_milk2/plugin.rc
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ BEGIN
IDS_CONFIG_PANEL_BUTTON_8 " "
IDS_EXTRA_FONT_1_NAME "Tooltips"
IDS_EXTRA_FONT_2_NAME "Animated Songtitles"
IDS_PRESS_F1_MSG "Press F1 for Help "
IDS_PRESS_F1_MSG "Press F12 for Help "
IDS_GRAPHICS_SUBSYSTEM_IS_TEMPORARILY_UNSTABLE
"One or more fullscreen display adapters are behaving strangely and will not\nreport a list of display modes. It's quite possible that your graphics subsystem\nis temporarily unstable.\n\nSUGGESTED ACTION: If you have modified your multimon setup or Windows,\ndisplay settings, or have updated any display drivers or installed\nany new programs, you should probably REBOOT YOUR COMPUTER before\ntrying to configure (or run) the plug-in again."
END
Expand Down Expand Up @@ -893,7 +893,7 @@ BEGIN
IDS_FORCE_INTO_DESKTOP_MODE_HELP
"Enable this to force the plug-in to start in desktop mode."
IDS_HELP_ON_F1 "Help on 'Press F1...' checkbox"
IDS_HELP_ON_F1_HELP "Disable this to prevent the 'Press F1 for Help' message\nfrom appearing when the plug-in starts."
IDS_HELP_ON_F1_HELP "Disable this to prevent the 'Press F12 for Help' message\nfrom appearing when the plug-in starts."
IDS_CB_SKIN_HELP "Check this box to 'skin' the plug-in's window frame when it runs\nin a window, so that it looks like the rest of the windows that\nmake up Winamp's interface.\n\nThis feature requires Winamp 2.90 or later; if the box is greyed\nout, it means you need a newer version of Winamp."
IDS_SAVE_CPU_CHECKBOX "Help on 'Save CPU' checkbox"
IDS_SAVE_CPU_CHECKBOX_HELP
Expand Down
48 changes: 21 additions & 27 deletions vis_milk2/text1.bin
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
GENERAL:

ESC exit help / menus
ALT+ENTER toggle fullscreen

PRESETS:

SPACE / H soft / hard cut to next preset
BACKSPACE go back to previous preset
` / ~ [un]lock current preset
R toggle random/sequential preset order
L load specific preset
M show/hide preset-editing Menu
S save new preset
A do random mini-mash-up
D toggle warp & comp shader locks

PLAYBACK:

F1 play/pause F2 stop
F3 prev F4 next
F5 volume up F6 volume down
F7 shuffle F8 repeat mode

INFO:

F12 help F9 title / time / preset
GENERAL:

ESC exit help / menus
ALT+ENTER toggle fullscreen
ALT+SHIFT toggle multiple monitor stretching

PRESETS:

SPACE / H soft / hard cut to next preset
BACKSPACE go back to previous preset
` / ~ [un]lock current preset
R toggle random/sequential preset order
L load specific preset
M show/hide preset-editing Menu
S save new preset
A do random mini-mash-up
D toggle warp & comp shader locks

INFO:

F12 help F9 title / time / preset