Removed NativeTransparency option (now always enabled)

This commit is contained in:
Birunthan Mohanathas 2012-04-17 09:32:10 +03:00
parent 174a612c49
commit 8332f8465e
3 changed files with 55 additions and 130 deletions

View File

@ -115,7 +115,6 @@ CMeterWindow::CMeterWindow(const std::wstring& config, const std::wstring& iniFi
m_WindowStartHidden(false), m_WindowStartHidden(false),
m_SavePosition(false), // Must be false m_SavePosition(false), // Must be false
m_SnapEdges(true), m_SnapEdges(true),
m_NativeTransparency(true),
m_AlphaValue(255), m_AlphaValue(255),
m_FadeDuration(250), m_FadeDuration(250),
m_WindowZPosition(ZPOSITION_NORMAL), m_WindowZPosition(ZPOSITION_NORMAL),
@ -1794,7 +1793,6 @@ void CMeterWindow::ReadConfig()
m_WindowStartHidden = false; m_WindowStartHidden = false;
m_SavePosition = true; m_SavePosition = true;
m_SnapEdges = true; m_SnapEdges = true;
m_NativeTransparency = true;
m_ClickThrough = false; m_ClickThrough = false;
m_KeepOnScreen = true; m_KeepOnScreen = true;
m_AutoSelectScreen = false; m_AutoSelectScreen = false;
@ -1835,7 +1833,6 @@ void CMeterWindow::ReadConfig()
m_WindowStartHidden = 0!=parser.ReadInt(section, L"StartHidden", m_WindowStartHidden); m_WindowStartHidden = 0!=parser.ReadInt(section, L"StartHidden", m_WindowStartHidden);
m_SavePosition = 0!=parser.ReadInt(section, L"SavePosition", m_SavePosition); m_SavePosition = 0!=parser.ReadInt(section, L"SavePosition", m_SavePosition);
m_SnapEdges = 0!=parser.ReadInt(section, L"SnapEdges", m_SnapEdges); m_SnapEdges = 0!=parser.ReadInt(section, L"SnapEdges", m_SnapEdges);
m_NativeTransparency = 0!=parser.ReadInt(section, L"NativeTransparency", m_NativeTransparency);
m_ClickThrough = 0!=parser.ReadInt(section, L"ClickThrough", m_ClickThrough); m_ClickThrough = 0!=parser.ReadInt(section, L"ClickThrough", m_ClickThrough);
m_KeepOnScreen = 0!=parser.ReadInt(section, L"KeepOnScreen", m_KeepOnScreen); m_KeepOnScreen = 0!=parser.ReadInt(section, L"KeepOnScreen", m_KeepOnScreen);
m_AutoSelectScreen = 0!=parser.ReadInt(section, L"AutoSelectScreen", m_AutoSelectScreen); m_AutoSelectScreen = 0!=parser.ReadInt(section, L"AutoSelectScreen", m_AutoSelectScreen);
@ -2442,17 +2439,6 @@ bool CMeterWindow::ResizeWindow(bool reset)
m_WindowH = m_Background->GetHeight(); m_WindowH = m_Background->GetHeight();
//Calculate the window position from the config parameters //Calculate the window position from the config parameters
WindowToScreen(); WindowToScreen();
if (!m_NativeTransparency)
{
// Graph the desktop and place the background on top of it
Bitmap* desktop = GrabDesktop(m_ScreenX, m_ScreenY, m_WindowW, m_WindowH);
Graphics graphics(desktop);
Rect r(0, 0, m_WindowW, m_WindowH);
graphics.DrawImage(m_Background, r, 0, 0, m_WindowW, m_WindowH, UnitPixel);
delete m_Background;
m_Background = desktop;
}
} }
delete tintedBackground; delete tintedBackground;
@ -2466,36 +2452,9 @@ bool CMeterWindow::ResizeWindow(bool reset)
SetWindowSizeVariables(m_WindowW, m_WindowH); SetWindowSizeVariables(m_WindowW, m_WindowH);
if (!m_NativeTransparency)
{
// If Background is not set, take a copy from the desktop
if (m_Background == NULL && m_BackgroundMode == BGMODE_COPY)
{
m_Background = GrabDesktop(m_ScreenX, m_ScreenY, m_WindowW, m_WindowH);
}
}
return true; return true;
} }
/*
** Grabs a part of the desktop
*/
Bitmap* CMeterWindow::GrabDesktop(int x, int y, int w, int h)
{
HDC desktopDC = GetDC(0);
HDC dc = CreateCompatibleDC(desktopDC);
HBITMAP desktopBM = CreateCompatibleBitmap(desktopDC, w, h);
HBITMAP oldBM = (HBITMAP)SelectObject(dc, desktopBM);
BitBlt(dc, 0, 0, w, h, desktopDC, x, y, SRCCOPY);
SelectObject(dc, oldBM);
DeleteDC(dc);
ReleaseDC(0, desktopDC);
Bitmap* background = new Bitmap(desktopBM, NULL);
DeleteObject(desktopBM);
return background;
}
/* /*
** Creates the back buffer bitmap. ** Creates the back buffer bitmap.
** **
@ -2552,7 +2511,7 @@ void CMeterWindow::CreateRegion(bool clear)
} }
} }
SetWindowRgn(m_Window, region, !m_NativeTransparency); SetWindowRgn(m_Window, region, FALSE);
} }
} }
@ -2668,11 +2627,6 @@ void CMeterWindow::Redraw()
} }
UpdateTransparency(m_TransparencyValue, false); UpdateTransparency(m_TransparencyValue, false);
if (!m_NativeTransparency)
{
InvalidateRect(m_Window, NULL, FALSE);
}
} }
/* /*
@ -2857,8 +2811,6 @@ void CMeterWindow::Update(bool nodraw)
*/ */
void CMeterWindow::UpdateTransparency(int alpha, bool reset) void CMeterWindow::UpdateTransparency(int alpha, bool reset)
{ {
if (m_NativeTransparency)
{
if (reset) if (reset)
{ {
AddWindowExStyle(WS_EX_LAYERED); AddWindowExStyle(WS_EX_LAYERED);
@ -2886,14 +2838,6 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset)
DeleteDC(dcMemory); DeleteDC(dcMemory);
m_TransparencyValue = alpha; m_TransparencyValue = alpha;
}
else
{
if (reset)
{
RemoveWindowExStyle(WS_EX_LAYERED);
}
}
} }
/* /*
@ -3037,7 +2981,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CMeterWindow::FadeWindow(int from, int to) void CMeterWindow::FadeWindow(int from, int to)
{ {
if (!m_NativeTransparency || m_FadeDuration == 0) if (m_FadeDuration == 0)
{ {
if (to == 0) if (to == 0)
{ {
@ -3321,7 +3265,7 @@ LRESULT CMeterWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
switch (m_WindowHide) switch (m_WindowHide)
{ {
case HIDEMODE_HIDE: case HIDEMODE_HIDE:
if (!m_NativeTransparency || m_TransparencyValue == m_AlphaValue) if (m_TransparencyValue == m_AlphaValue)
{ {
FadeWindow(m_AlphaValue, 0); FadeWindow(m_AlphaValue, 0);
} }
@ -4675,8 +4619,6 @@ LRESULT CMeterWindow::OnDelayedRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam)
*/ */
LRESULT CMeterWindow::OnDelayedMove(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnDelayedMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (m_NativeTransparency)
{
m_Parser.ResetMonitorVariables(this); m_Parser.ResetMonitorVariables(this);
// Move the window to correct position // Move the window to correct position
@ -4688,12 +4630,6 @@ LRESULT CMeterWindow::OnDelayedMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
SetWindowPos(m_Window, NULL, m_ScreenX, m_ScreenY, m_WindowW, m_WindowH, SWP_NOZORDER | SWP_NOACTIVATE); SetWindowPos(m_Window, NULL, m_ScreenX, m_ScreenY, m_WindowW, m_WindowH, SWP_NOZORDER | SWP_NOACTIVATE);
}
else
{
// With copy transparency we'll do a full refresh
PostMessage(m_Window, WM_METERWINDOW_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL);
}
return 0; return 0;
} }

View File

@ -224,7 +224,6 @@ public:
int GetXScreen() { return m_WindowXScreen; } int GetXScreen() { return m_WindowXScreen; }
int GetYScreen() { return m_WindowYScreen; } int GetYScreen() { return m_WindowYScreen; }
bool GetNativeTransparency() { return m_NativeTransparency; }
bool GetClickThrough() { return m_ClickThrough; } bool GetClickThrough() { return m_ClickThrough; }
bool GetKeepOnScreen() { return m_KeepOnScreen; } bool GetKeepOnScreen() { return m_KeepOnScreen; }
bool GetAutoSelectScreen() { return m_AutoSelectScreen; } bool GetAutoSelectScreen() { return m_AutoSelectScreen; }
@ -305,7 +304,6 @@ private:
void CreateRegion(bool clear); void CreateRegion(bool clear);
void GetSkinFolders(const std::wstring& folder); void GetSkinFolders(const std::wstring& folder);
Gdiplus::Bitmap* GrabDesktop(int x, int y, int w, int h);
void SnapToWindow(CMeterWindow* window, LPWINDOWPOS wp); void SnapToWindow(CMeterWindow* window, LPWINDOWPOS wp);
void MapCoordsToScreen(int& x, int& y, int w, int h); void MapCoordsToScreen(int& x, int& y, int w, int h);
void WindowToScreen(); void WindowToScreen();
@ -410,7 +408,6 @@ private:
bool m_WindowStartHidden; // If true, the window is hidden at startup bool m_WindowStartHidden; // If true, the window is hidden at startup
bool m_SavePosition; // If true, the window's position is saved bool m_SavePosition; // If true, the window's position is saved
bool m_SnapEdges; // If true, the window snaps to the edges of the screen when moved bool m_SnapEdges; // If true, the window snaps to the edges of the screen when moved
bool m_NativeTransparency; // If true, use the W2k/XP native transparency
int m_AlphaValue; // The 'from' transparency value 0 - 255 int m_AlphaValue; // The 'from' transparency value 0 - 255
int m_FadeDuration; // Time it takes to fade the window int m_FadeDuration; // Time it takes to fade the window
ZPOSITION m_WindowZPosition; // Window's Z-position ZPOSITION m_WindowZPosition; // Window's Z-position

View File

@ -2836,13 +2836,6 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
} }
// Tick the transparency // Tick the transparency
if (!meterWindow->GetNativeTransparency())
{
EnableMenuItem(settingsMenu, 1, MF_BYPOSITION | MF_GRAYED); // "Transparency" menu
EnableMenuItem(settingsMenu, IDM_SKIN_CLICKTHROUGH, MF_BYCOMMAND | MF_GRAYED);
}
else
{
HMENU alphaMenu = GetSubMenu(settingsMenu, 1); HMENU alphaMenu = GetSubMenu(settingsMenu, 1);
if (alphaMenu) if (alphaMenu)
{ {
@ -2869,7 +2862,6 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
break; break;
} }
} }
}
// Tick the configs // Tick the configs
switch (meterWindow->GetWindowHide()) switch (meterWindow->GetWindowHide())