ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
43 participants
275 discussions
Start a n
N
ew thread
[reactos] 01/01: [EXPLORER] -Rewrite taskbar settings routines and dialog - Rewrite the taskbar settings and start menu settings property sheets. - All settings in the taskbar settings property sheet can be loaded and saved properly except for the quick launch one which will be implemented later. - Implement toggling lock, autohide and always on top. The rest will be implemented later.
by Giannis Adamopoulos
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2ed535da8ab490b53bb49…
commit 2ed535da8ab490b53bb496f3ac25fd1fd03f4965 Author: Giannis Adamopoulos <gadamopoulos(a)reactos.org> AuthorDate: Mon Oct 30 17:39:12 2017 +0200 [EXPLORER] -Rewrite taskbar settings routines and dialog - Rewrite the taskbar settings and start menu settings property sheets. - All settings in the taskbar settings property sheet can be loaded and saved properly except for the quick launch one which will be implemented later. - Implement toggling lock, autohide and always on top. The rest will be implemented later. --- base/shell/explorer/CMakeLists.txt | 2 +- base/shell/explorer/explorer.cpp | 3 +- base/shell/explorer/precomp.h | 55 ++-- base/shell/explorer/resource.h | 2 + base/shell/explorer/settings.cpp | 106 +++---- base/shell/explorer/taskswnd.cpp | 13 + base/shell/explorer/trayntfy.cpp | 64 ++-- base/shell/explorer/trayprop.cpp | 583 +++++++++++++------------------------ base/shell/explorer/traywnd.cpp | 173 +++++------ 9 files changed, 395 insertions(+), 606 deletions(-) diff --git a/base/shell/explorer/CMakeLists.txt b/base/shell/explorer/CMakeLists.txt index 8d1eaa42c6..f935f4dafd 100644 --- a/base/shell/explorer/CMakeLists.txt +++ b/base/shell/explorer/CMakeLists.txt @@ -1,7 +1,7 @@ PROJECT(SHELL) set_cpp(WITH_RUNTIME) - +add_definitions(-D_ATL_NO_EXCEPTIONS) include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl) list(APPEND SOURCE diff --git a/base/shell/explorer/explorer.cpp b/base/shell/explorer/explorer.cpp index e803c4db42..f6e7402423 100644 --- a/base/shell/explorer/explorer.cpp +++ b/base/shell/explorer/explorer.cpp @@ -127,7 +127,8 @@ StartWithDesktop(IN HINSTANCE hInstance) hExplorerInstance = hInstance; hProcessHeap = GetProcessHeap(); - LoadTaskBarSettings(); + g_TaskbarSettings.Load(); + InitCommonControls(); OleInitialize(NULL); diff --git a/base/shell/explorer/precomp.h b/base/shell/explorer/precomp.h index f674a2c13c..df6fd7537f 100644 --- a/base/shell/explorer/precomp.h +++ b/base/shell/explorer/precomp.h @@ -27,6 +27,7 @@ #include <atlbase.h> #include <atlcom.h> #include <atlwin.h> +#include <atlstr.h> #include <shellapi.h> #include <shlobj.h> #include <shlwapi.h> @@ -40,6 +41,7 @@ #include <undocshell.h> #include <rosctrls.h> +#include <rosdlgs.h> #include <shellutils.h> #include "tmschema.h" @@ -125,6 +127,7 @@ HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void */ #define TWM_OPENSTARTMENU (WM_USER + 260) +#define TWM_SETTINGSCHANGED (WM_USER + 300) extern const GUID IID_IShellDesktopTray; @@ -181,35 +184,39 @@ TrayMessageLoop(IN OUT ITrayWindow *Tray); * settings.c */ -/* Structure to hold non-default options*/ -typedef struct _TASKBAR_SETTINGS +typedef struct _TW_STUCKRECTS2 +{ + DWORD cbSize; + LONG Unknown; + union + { + DWORD dwFlags; + struct + { + DWORD AutoHide : 1; + DWORD AlwaysOnTop : 1; + DWORD SmallIcons : 1; + DWORD HideClock : 1; + }; + }; + DWORD Position; + SIZE Size; + RECT Rect; +} TW_STRUCKRECTS2, *PTW_STUCKRECTS2; + +struct TaskbarSettings { BOOL bLock; - BOOL bAutoHide; - BOOL bAlwaysOnTop; BOOL bGroupButtons; - BOOL bShowQuickLaunch; - BOOL bShowClock; BOOL bShowSeconds; BOOL bHideInactiveIcons; -} TASKBAR_SETTINGS, *PTASKBAR_SETTINGS; - -extern TASKBAR_SETTINGS TaskBarSettings; - -VOID -LoadTaskBarSettings(VOID); + TW_STRUCKRECTS2 sr; -VOID -SaveTaskBarSettings(VOID); + BOOL Load(); + BOOL Save(); +}; -BOOL -LoadSettingDword(IN LPCWSTR pszKeyName, - IN LPCWSTR pszValueName, - OUT DWORD &dwValue); -BOOL -SaveSettingDword(IN LPCWSTR pszKeyName, - IN LPCWSTR pszValueName, - IN DWORD dwValue); +extern TaskbarSettings g_TaskbarSettings; /* * shellservice.cpp @@ -229,7 +236,7 @@ ProcessStartupItems(VOID); */ VOID -DisplayTrayProperties(IN HWND hwndOwner); +DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar); /* * desktop.cpp @@ -344,7 +351,7 @@ VOID UnregisterTrayNotifyWndClass(VOID); HWND -CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, CTrayNotifyWnd** ppTrayNotify); +CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, CTrayNotifyWnd** ppTrayNotify); BOOL TrayNotify_NotifyIconCmd(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam, IN LPARAM lParam); diff --git a/base/shell/explorer/resource.h b/base/shell/explorer/resource.h index ae3c29181f..aed1e08a60 100644 --- a/base/shell/explorer/resource.h +++ b/base/shell/explorer/resource.h @@ -107,6 +107,7 @@ \*******************************************************************************/ /* Taskbar Page */ +#define IDC_TASKBARPROP_FIRST_CMD 1000 #define IDC_TASKBARPROP_HIDEICONS 1000 #define IDC_TASKBARPROP_ICONCUST 1007 #define IDC_TASKBARPROP_ONTOP 1101 @@ -116,6 +117,7 @@ #define IDC_TASKBARPROP_LOCK 1105 #define IDC_TASKBARPROP_SECONDS 1106 #define IDC_TASKBARPROP_SHOWQL 1107 +#define IDC_TASKBARPROP_LAST_CMD 1107 #define IDC_TASKBARPROP_TASKBARBITMAP 1111 #define IDC_TASKBARPROP_NOTIFICATIONBITMAP 1112 diff --git a/base/shell/explorer/settings.cpp b/base/shell/explorer/settings.cpp index 791a91c79c..f47e165d7d 100644 --- a/base/shell/explorer/settings.cpp +++ b/base/shell/explorer/settings.cpp @@ -20,85 +20,61 @@ #include "precomp.h" -TASKBAR_SETTINGS TaskBarSettings; -const WCHAR szSettingsKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"; -const WCHAR szAdvancedSettingsKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"; +TaskbarSettings g_TaskbarSettings; -VOID -LoadTaskBarSettings(VOID) +BOOL TaskbarSettings::Save() { - DWORD dwValue = NULL; - - LoadSettingDword(szAdvancedSettingsKey, L"TaskbarSizeMove", dwValue); - TaskBarSettings.bLock = (dwValue == 0); - - LoadSettingDword(szAdvancedSettingsKey, L"ShowSeconds", dwValue); - TaskBarSettings.bShowSeconds = (dwValue != 0); - - LoadSettingDword(szSettingsKey, L"EnableAutotray", dwValue); - TaskBarSettings.bHideInactiveIcons = (dwValue != 0); - - LoadSettingDword(szAdvancedSettingsKey, L"TaskbarGlomming", dwValue); - TaskBarSettings.bGroupButtons = (dwValue != 0); - - TaskBarSettings.bShowQuickLaunch = TRUE; //FIXME: Where is this stored, and how? - - /* FIXME: The following settings are stored in stuckrects2, do they have to be load here too? */ - TaskBarSettings.bShowClock = TRUE; - TaskBarSettings.bAutoHide = FALSE; - TaskBarSettings.bAlwaysOnTop = FALSE; + SHSetValueW(hkExplorer, NULL, L"EnableAutotray", REG_DWORD, &bHideInactiveIcons, sizeof(bHideInactiveIcons)); + SHSetValueW(hkExplorer, L"Advanced", L"ShowSeconds", REG_DWORD, &bShowSeconds, sizeof(bShowSeconds)); + SHSetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", REG_DWORD, &bGroupButtons, sizeof(bGroupButtons)); + BOOL bAllowSizeMove = !bLock; + SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", REG_DWORD, &bAllowSizeMove, sizeof(bAllowSizeMove)); + sr.cbSize = sizeof(sr); + SHSetValueW(hkExplorer, L"StuckRects2", L"Settings", REG_BINARY, &sr, sizeof(sr)); + /* TODO: AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */ + return TRUE; } -VOID -SaveTaskBarSettings(VOID) +BOOL TaskbarSettings::Load() { - SaveSettingDword(szAdvancedSettingsKey, L"TaskbarSizeMove", TaskBarSettings.bLock); - SaveSettingDword(szAdvancedSettingsKey, L"ShowSeconds", TaskBarSettings.bShowSeconds); - SaveSettingDword(szSettingsKey, L"EnableAutotray", TaskBarSettings.bHideInactiveIcons); - SaveSettingDword(szAdvancedSettingsKey, L"TaskbarGlomming", TaskBarSettings.bGroupButtons); - - /* FIXME: Show Clock, AutoHide and Always on top are stored in the stuckrects2 key but are not written to it with a click on apply. How is this done instead? - AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */ -} + DWORD dwRet, cbSize, dwValue = NULL; -BOOL -LoadSettingDword(IN LPCWSTR pszKeyName, - IN LPCWSTR pszValueName, - OUT DWORD &dwValue) -{ - BOOL ret = FALSE; - HKEY hKey; + cbSize = sizeof(dwValue); + dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", NULL, &dwValue, &cbSize); + bLock = (dwRet == ERROR_SUCCESS) ? (dwValue == 0) : TRUE; - if (RegOpenKeyW(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS) - { - DWORD dwValueLength, dwType; + dwRet = SHGetValueW(hkExplorer, L"Advanced", L"ShowSeconds", NULL, &dwValue, &cbSize); + bShowSeconds = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; - dwValueLength = sizeof(dwValue); - ret = RegQueryValueExW(hKey, pszValueName, NULL, &dwType, (PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD; - - RegCloseKey(hKey); - } - - return ret; -} + dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", NULL, &dwValue, &cbSize); + bGroupButtons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; -BOOL -SaveSettingDword(IN LPCWSTR pszKeyName, - IN LPCWSTR pszValueName, - IN DWORD dwValue) -{ - BOOL ret = FALSE; - HKEY hKey; + dwRet = SHGetValueW(hkExplorer, NULL, L"EnableAutotray", NULL, &dwValue, &cbSize); + bHideInactiveIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; - if (RegCreateKeyW(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS) - { - ret = RegSetValueExW(hKey, pszValueName, 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue)) == ERROR_SUCCESS; + cbSize = sizeof(sr); + dwRet = SHGetValueW(hkExplorer, L"StuckRects2", L"Settings", NULL, &sr, &cbSize); - RegCloseKey(hKey); + /* Make sure we have correct values here */ + if (dwRet != ERROR_SUCCESS || sr.cbSize != sizeof(sr) || cbSize != sizeof(sr)) + { + sr.Position = ABE_BOTTOM; + sr.AutoHide = FALSE; + sr.AlwaysOnTop = TRUE; + sr.SmallIcons = TRUE; + sr.HideClock = FALSE; + sr.Rect.left = sr.Rect.top = 0; + sr.Rect.bottom = sr.Rect.right = 1; + sr.Size.cx = sr.Size.cy = 0; + } + else + { + if (sr.Position > ABE_BOTTOM) + sr.Position = ABE_BOTTOM; } - return ret; + return TRUE; } /* EOF */ diff --git a/base/shell/explorer/taskswnd.cpp b/base/shell/explorer/taskswnd.cpp index 94ee926038..44d0e3e215 100644 --- a/base/shell/explorer/taskswnd.cpp +++ b/base/shell/explorer/taskswnd.cpp @@ -1735,6 +1735,18 @@ public: return TRUE; } + LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + TaskbarSettings* newSettings = (TaskbarSettings*)lParam; + if (newSettings->bGroupButtons != g_TaskbarSettings.bGroupButtons) + { + /* TODO: Toggle grouping */ + g_TaskbarSettings.bGroupButtons = newSettings->bGroupButtons; + } + + return 0; + } + LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { LRESULT Ret = 0; @@ -1828,6 +1840,7 @@ public: MESSAGE_HANDLER(WM_NOTIFY, OnNotify) MESSAGE_HANDLER(TSWM_ENABLEGROUPING, OnEnableGrouping) MESSAGE_HANDLER(TSWM_UPDATETASKBARPOS, OnUpdateTaskbarPos) + MESSAGE_HANDLER(TWM_SETTINGSCHANGED, OnTaskbarSettingsChanged) MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu) MESSAGE_HANDLER(WM_TIMER, OnTimer) MESSAGE_HANDLER(WM_SETFONT, OnSetFont) diff --git a/base/shell/explorer/trayntfy.cpp b/base/shell/explorer/trayntfy.cpp index b79d41b5a3..95c40aa723 100644 --- a/base/shell/explorer/trayntfy.cpp +++ b/base/shell/explorer/trayntfy.cpp @@ -916,7 +916,7 @@ public: if (ClockWndFormats[i].IsTime) { iRet = GetTimeFormat(LOCALE_USER_DEFAULT, - TaskBarSettings.bShowSeconds ? ClockWndFormats[i].dwFormatFlags : TIME_NOSECONDS, + g_TaskbarSettings.bShowSeconds ? ClockWndFormats[i].dwFormatFlags : TIME_NOSECONDS, &LocalTime, ClockWndFormats[i].lpFormat, szLines[i], @@ -988,7 +988,7 @@ public: /* Calculate the due time */ GetLocalTime(&LocalTime); uiDueTime = 1000 - (UINT) LocalTime.wMilliseconds; - if (TaskBarSettings.bShowSeconds) + if (g_TaskbarSettings.bShowSeconds) uiDueTime += (UINT) LocalTime.wSecond * 100; else uiDueTime += (59 - (UINT) LocalTime.wSecond) * 1000; @@ -1046,7 +1046,7 @@ public: uiDueTime = CalculateDueTime(); - if (TaskBarSettings.bShowSeconds) + if (g_TaskbarSettings.bShowSeconds) { uiWait1 = 1000 - 200; uiWait2 = 1000; @@ -1310,15 +1310,7 @@ class CTrayNotifyWnd : SIZE szTrayClockMin; SIZE szTrayNotify; MARGINS ContentMargin; - union - { - DWORD dwFlags; - struct - { - DWORD HideClock : 1; - DWORD IsHorizontal : 1; - }; - }; + BOOL IsHorizontal; public: CTrayNotifyWnd() : @@ -1326,7 +1318,7 @@ public: m_pager(NULL), m_clock(NULL), TrayTheme(NULL), - dwFlags(0) + IsHorizontal(FALSE) { ZeroMemory(&szTrayClockMin, sizeof(szTrayClockMin)); ZeroMemory(&szTrayNotify, sizeof(szTrayNotify)); @@ -1377,10 +1369,10 @@ public: LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { m_clock = new CTrayClockWnd(); - m_clock->_Init(m_hWnd, !HideClock); + m_clock->_Init(m_hWnd, !g_TaskbarSettings.sr.HideClock); m_pager = new CSysPagerWnd(); - m_pager->_Init(m_hWnd, !HideClock); + m_pager->_Init(m_hWnd, !g_TaskbarSettings.sr.HideClock); return TRUE; } @@ -1390,7 +1382,7 @@ public: SIZE szClock = { 0, 0 }; SIZE szTray = { 0, 0 }; - if (!HideClock) + if (!g_TaskbarSettings.sr.HideClock) { if (IsHorizontal) { @@ -1430,7 +1422,7 @@ public: { pSize->cx = 2 * TRAY_NOTIFY_WND_SPACING_X; - if (!HideClock) + if (!g_TaskbarSettings.sr.HideClock) pSize->cx += TRAY_NOTIFY_WND_SPACING_X + szTrayClockMin.cx; pSize->cx += szTray.cx; @@ -1439,7 +1431,7 @@ public: { pSize->cy = 2 * TRAY_NOTIFY_WND_SPACING_Y; - if (!HideClock) + if (!g_TaskbarSettings.sr.HideClock) pSize->cy += TRAY_NOTIFY_WND_SPACING_Y + szTrayClockMin.cy; pSize->cy += szTray.cy; @@ -1453,7 +1445,7 @@ public: VOID Size(IN const SIZE *pszClient) { - if (!HideClock) + if (!g_TaskbarSettings.sr.HideClock) { POINT ptClock; SIZE szClock; @@ -1600,17 +1592,35 @@ public: LRESULT OnShowClock(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - BOOL PrevHidden = HideClock; - HideClock = (wParam == 0); + BOOL PrevHidden = g_TaskbarSettings.sr.HideClock; + g_TaskbarSettings.sr.HideClock = (wParam == 0); - if (m_clock != NULL && PrevHidden != HideClock) + if (m_clock != NULL && PrevHidden != g_TaskbarSettings.sr.HideClock) { - m_clock->ShowWindow(HideClock ? SW_HIDE : SW_SHOW); + m_clock->ShowWindow(g_TaskbarSettings.sr.HideClock ? SW_HIDE : SW_SHOW); } return (LRESULT) (!PrevHidden); } + LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + TaskbarSettings* newSettings = (TaskbarSettings*)lParam; + if (newSettings->bShowSeconds != g_TaskbarSettings.bShowSeconds) + { + g_TaskbarSettings.bShowSeconds = newSettings->bShowSeconds; + /* TODO: Toggle showing seconds */ + } + + if (newSettings->sr.HideClock != g_TaskbarSettings.sr.HideClock) + { + g_TaskbarSettings.sr.HideClock = newSettings->sr.HideClock; + /* TODO: Toggle hiding the clock */ + } + + return 0; + } + LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { const NMHDR *nmh = (const NMHDR *) lParam; @@ -1665,9 +1675,10 @@ public: MESSAGE_HANDLER(TNWM_GETMINIMUMSIZE, OnGetMinimumSize) MESSAGE_HANDLER(TNWM_UPDATETIME, OnUpdateTime) MESSAGE_HANDLER(TNWM_SHOWCLOCK, OnShowClock) + MESSAGE_HANDLER(TWM_SETTINGSCHANGED, OnTaskbarSettingsChanged) END_MSG_MAP() - HWND _Init(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock) + HWND _Init(IN OUT ITrayWindow *TrayWindow) { HWND hWndTrayWindow; @@ -1676,7 +1687,6 @@ public: return NULL; this->TrayWindow = TrayWindow; - this->HideClock = bHideClock; this->hWndNotify = hWndTrayWindow; DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; @@ -1684,13 +1694,13 @@ public: } }; -HWND CreateTrayNotifyWnd(IN OUT ITrayWindow *Tray, BOOL bHideClock, CTrayNotifyWnd** ppinstance) +HWND CreateTrayNotifyWnd(IN OUT ITrayWindow *Tray, CTrayNotifyWnd** ppinstance) { CTrayNotifyWnd * pTrayNotify = new CTrayNotifyWnd(); // TODO: Destroy after the window is destroyed *ppinstance = pTrayNotify; - return pTrayNotify->_Init(Tray, bHideClock); + return pTrayNotify->_Init(Tray); } BOOL diff --git a/base/shell/explorer/trayprop.cpp b/base/shell/explorer/trayprop.cpp index 87cf7a2d8c..03823ccf97 100644 --- a/base/shell/explorer/trayprop.cpp +++ b/base/shell/explorer/trayprop.cpp @@ -21,441 +21,254 @@ #include "precomp.h" -typedef struct _PROPSHEET_INFO +static void SetBitmap(HWND hwnd, HBITMAP* hbmp, UINT uImageId) { - HWND hTaskbarWnd; - HWND hStartWnd; + if (*hbmp) + DeleteObject(*hbmp); - HBITMAP hTaskbarBitmap; - HBITMAP hTrayBitmap; - HBITMAP hStartBitmap; -} PROPSHEET_INFO, *PPROPSHEET_INFO; + *hbmp = (HBITMAP)LoadImageW(hExplorerInstance, + MAKEINTRESOURCEW(uImageId), + IMAGE_BITMAP, + 0, + 0, + LR_DEFAULTCOLOR); + + if (*hbmp && hwnd) + { + BITMAP bm; + GetObject(*hbmp, sizeof(bm), &bm); + ::SetWindowPos(hwnd, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); + SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)*hbmp); + } +} -static BOOL -UpdateBitmaps(PPROPSHEET_INFO pPropInfo) +class CTaskBarSettingsPage : public CPropertyPageImpl<CTaskBarSettingsPage> { - HWND hwndLock, hwndHide, hwndGroup, hwndShowQL, hwndClock, hwndSeconds, hwndHideInactive, hwndModernStart, hwndClassicStart; - HWND hwndTaskbarBitmap, hwndTrayBitmap, hwndStartBitmap; - HWND hwndCustomizeNotifyButton, hwndCustomizeClassicStartButton, hwndCustomizeModernStartButton; - BOOL bLock, bHide, bGroup, bShowQL, bShowClock, bShowSeconds, bHideInactive; - LPTSTR lpTaskBarImageName = NULL, lpTrayImageName = NULL, lpStartImageName = NULL; - BOOL bRet = FALSE; - - hwndLock = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_LOCK); - hwndHide = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_HIDE); - hwndGroup = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_GROUP); - hwndShowQL = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_SHOWQL); - - hwndClock = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_CLOCK); - hwndSeconds = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_SECONDS); - hwndHideInactive = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_HIDEICONS); - - hwndCustomizeNotifyButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_ICONCUST); - - hwndModernStart = GetDlgItem(pPropInfo->hStartWnd, IDC_TASKBARPROP_STARTMENU); - hwndClassicStart = GetDlgItem(pPropInfo->hStartWnd, IDC_TASKBARPROP_STARTMENUCLASSIC); - - hwndCustomizeClassicStartButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_STARTMENUCLASSICCUST); - hwndCustomizeModernStartButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_STARTMENUCUST); - - +private: + HBITMAP m_hbmpTaskbar; + HBITMAP m_hbmpTray; + HWND m_hwndTaskbar; - if (hwndLock && hwndHide && hwndGroup && hwndShowQL && hwndClock && hwndSeconds && hwndHideInactive) + void UpdateDialog() { - bLock = (SendMessage(hwndLock, BM_GETCHECK, 0, 0) == BST_CHECKED); - bHide = (SendMessage(hwndHide, BM_GETCHECK, 0, 0) == BST_CHECKED); - bGroup = (SendMessage(hwndGroup, BM_GETCHECK, 0, 0) == BST_CHECKED); - bShowQL = (SendMessage(hwndShowQL, BM_GETCHECK, 0, 0) == BST_CHECKED); - - bShowClock = (SendMessage(hwndClock, BM_GETCHECK, 0, 0) == BST_CHECKED); - bShowSeconds = (SendMessage(hwndSeconds, BM_GETCHECK, 0, 0) == BST_CHECKED); - bHideInactive = (SendMessage(hwndHideInactive, BM_GETCHECK, 0, 0) == BST_CHECKED); + BOOL bLock = IsDlgButtonChecked(IDC_TASKBARPROP_LOCK); + BOOL bHide = IsDlgButtonChecked(IDC_TASKBARPROP_HIDE); + BOOL bGroup = IsDlgButtonChecked(IDC_TASKBARPROP_GROUP); + BOOL bShowQL = IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL); + BOOL bShowClock = IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK); + BOOL bShowSeconds = IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS); + BOOL bHideInactive = IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS); + UINT uImageId; + + HWND hwndCustomizeNotifyButton = GetDlgItem(IDC_TASKBARPROP_ICONCUST); + HWND hwndSeconds = GetDlgItem(IDC_TASKBARPROP_SECONDS); + HWND hwndTaskbarBitmap = GetDlgItem(IDC_TASKBARPROP_TASKBARBITMAP); + HWND hwndTrayBitmap = GetDlgItem(IDC_TASKBARPROP_NOTIFICATIONBITMAP); if (bHide) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_AUTOHIDE); + uImageId = IDB_TASKBARPROP_AUTOHIDE; else if (bLock && bGroup && bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_GROUP_QL); + uImageId = IDB_TASKBARPROP_LOCK_GROUP_QL; else if (bLock && !bGroup && !bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_NOGROUP_NOQL); + uImageId = IDB_TASKBARPROP_LOCK_NOGROUP_NOQL; else if (bLock && bGroup && !bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_GROUP_NOQL); + uImageId = IDB_TASKBARPROP_LOCK_GROUP_NOQL; else if (bLock && !bGroup && bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_NOGROUP_QL); + uImageId = IDB_TASKBARPROP_LOCK_NOGROUP_QL; else if (!bLock && !bGroup && !bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL); + uImageId = IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL; else if (!bLock && bGroup && !bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_GROUP_NOQL); + uImageId = IDB_TASKBARPROP_NOLOCK_GROUP_NOQL; else if (!bLock && !bGroup && bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_NOGROUP_QL); + uImageId = IDB_TASKBARPROP_NOLOCK_NOGROUP_QL; else if (!bLock && bGroup && bShowQL) - lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_GROUP_QL); - - - if (lpTaskBarImageName) - { - if (pPropInfo->hTaskbarBitmap) - { - DeleteObject(pPropInfo->hTaskbarBitmap); - } - - pPropInfo->hTaskbarBitmap = (HBITMAP)LoadImageW(hExplorerInstance, - lpTaskBarImageName, - IMAGE_BITMAP, - 0, - 0, - LR_DEFAULTCOLOR); - if (pPropInfo->hTaskbarBitmap) - { - hwndTaskbarBitmap = GetDlgItem(pPropInfo->hTaskbarWnd, - IDC_TASKBARPROP_TASKBARBITMAP); - if (hwndTaskbarBitmap) - { - BITMAP bm; - GetObject(pPropInfo->hTaskbarBitmap, sizeof(bm), &bm); - SetWindowPos(hwndTaskbarBitmap, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); - SendMessage(hwndTaskbarBitmap, - STM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)pPropInfo->hTaskbarBitmap); - } - } - } - - if (bHideInactive) - { - EnableWindow(hwndCustomizeNotifyButton, TRUE); - if (bShowClock) - { - EnableWindow(hwndSeconds, TRUE); - if (bShowSeconds) - lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_SECONDS); - else - lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_CLOCK); - } - else - { - SendMessage(hwndSeconds, BM_SETCHECK, BST_UNCHECKED, 0); - EnableWindow(hwndSeconds, FALSE); - lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_NOCLOCK); - } - } - else - { - EnableWindow(hwndCustomizeNotifyButton, FALSE); - if (bShowClock) - { - EnableWindow(hwndSeconds, TRUE); - if (bShowSeconds) - lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_SECONDS); - else - lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_CLOCK); - } - else - { - SendMessage(hwndSeconds, BM_SETCHECK, BST_UNCHECKED, 0); - EnableWindow(hwndSeconds, FALSE); - lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_NOCLOCK); - } - } - - if (lpTrayImageName) - { - if (pPropInfo->hTrayBitmap) - { - DeleteObject(pPropInfo->hTrayBitmap); - } - - pPropInfo->hTrayBitmap = (HBITMAP)LoadImageW(hExplorerInstance, - lpTrayImageName, - IMAGE_BITMAP, - 0, - 0, - LR_DEFAULTCOLOR); - if (pPropInfo->hTrayBitmap) - { - hwndTrayBitmap = GetDlgItem(pPropInfo->hTaskbarWnd, - IDC_TASKBARPROP_NOTIFICATIONBITMAP); - if (hwndTrayBitmap) - { - BITMAP bm; - GetObject(pPropInfo->hTrayBitmap, sizeof(bm), &bm); - SetWindowPos(hwndTrayBitmap, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); - SendMessage(hwndTrayBitmap, - STM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)pPropInfo->hTrayBitmap); - } - } - } + uImageId = IDB_TASKBARPROP_NOLOCK_GROUP_QL; + else + ASSERT(FALSE); + + SetBitmap(hwndTaskbarBitmap, &m_hbmpTaskbar, uImageId); + + ::EnableWindow(hwndCustomizeNotifyButton, bHideInactive); + ::EnableWindow(hwndSeconds, bShowClock); + if (!bShowSeconds) + CheckDlgButton(IDC_TASKBARPROP_SECONDS, BST_UNCHECKED); + + if (bHideInactive && bShowClock && bShowSeconds) + uImageId = IDB_SYSTRAYPROP_HIDE_SECONDS; + else if (bHideInactive && bShowClock && !bShowSeconds) + uImageId = IDB_SYSTRAYPROP_HIDE_CLOCK; + else if (bHideInactive && !bShowClock) + uImageId = IDB_SYSTRAYPROP_HIDE_NOCLOCK; + else if (!bHideInactive && bShowClock && bShowSeconds) + uImageId = IDB_SYSTRAYPROP_SHOW_SECONDS; + else if (!bHideInactive && bShowClock && !bShowSeconds) + uImageId = IDB_SYSTRAYPROP_SHOW_CLOCK; + else if (!bHideInactive && !bShowClock) + uImageId = IDB_SYSTRAYPROP_SHOW_NOCLOCK; + else + ASSERT(FALSE); + + SetBitmap(hwndTrayBitmap, &m_hbmpTray, uImageId); + } + +public: + enum { IDD = IDD_TASKBARPROP_TASKBAR }; + + BEGIN_MSG_MAP(CTaskBarSettingsPage) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_ID_HANDLER(IDC_TASKBARPROP_ICONCUST, OnCustomizeTrayIcons) + COMMAND_RANGE_HANDLER(IDC_TASKBARPROP_FIRST_CMD, IDC_TASKBARPROP_LAST_CMD, OnCtrlCommand) + CHAIN_MSG_MAP(CPropertyPageImpl<CTaskBarSettingsPage>) + END_MSG_MAP() + + CTaskBarSettingsPage(HWND hwnd): + m_hbmpTaskbar(NULL), + m_hbmpTray(NULL), + m_hwndTaskbar(hwnd) + { } - if(hwndClassicStart && hwndModernStart) + ~CTaskBarSettingsPage() { - if(SendMessage(hwndModernStart, BM_GETCHECK, 0, 0) == BST_CHECKED) - { - EnableWindow(hwndCustomizeModernStartButton, TRUE); - EnableWindow(hwndCustomizeClassicStartButton, FALSE); - lpStartImageName = MAKEINTRESOURCEW(IDB_STARTPREVIEW); - } - else - { - EnableWindow(hwndCustomizeModernStartButton, FALSE); - EnableWindow(hwndCustomizeClassicStartButton, TRUE); - lpStartImageName = MAKEINTRESOURCEW(IDB_STARTPREVIEW_CLASSIC); - } - - if (lpStartImageName) - { - if (pPropInfo->hStartBitmap) - { - DeleteObject(pPropInfo->hStartBitmap); - } - - pPropInfo->hStartBitmap = (HBITMAP)LoadImageW(hExplorerInstance, - lpStartImageName, - IMAGE_BITMAP, - 0, - 0, - LR_DEFAULTCOLOR); - if (pPropInfo->hStartBitmap) - { - hwndStartBitmap = GetDlgItem(pPropInfo->hStartWnd, - IDC_TASKBARPROP_STARTMENU_BITMAP); - if (hwndStartBitmap) - { - BITMAP bm; - GetObject(pPropInfo->hStartBitmap, sizeof(bm), &bm); - SetWindowPos(hwndStartBitmap, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); - SendMessage(hwndStartBitmap, - STM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)pPropInfo->hStartBitmap); - } - } - } + if (m_hbmpTaskbar) + DeleteObject(m_hbmpTaskbar); + if (m_hbmpTray) + DeleteObject(m_hbmpTray); } - return bRet; -} + LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) + { + CheckDlgButton(IDC_TASKBARPROP_LOCK, g_TaskbarSettings.bLock ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_TASKBARPROP_HIDE, g_TaskbarSettings.sr.AutoHide ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_TASKBARPROP_ONTOP, g_TaskbarSettings.sr.AlwaysOnTop ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_TASKBARPROP_GROUP, g_TaskbarSettings.bGroupButtons ? BST_CHECKED : BST_UNCHECKED); + //CheckDlgButton(IDC_TASKBARPROP_SHOWQL, g_TaskbarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_TASKBARPROP_CLOCK, (!g_TaskbarSettings.sr.HideClock) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_TASKBARPROP_SECONDS, g_TaskbarSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_TASKBARPROP_HIDEICONS, g_TaskbarSettings.bHideInactiveIcons ? BST_CHECKED : BST_UNCHECKED); + + UpdateDialog(); + return TRUE; + } -static VOID -OnCreateTaskbarPage(HWND hwnd, - PPROPSHEET_INFO pPropInfo) -{ - SetWindowLongPtr(hwnd, - GWLP_USERDATA, - (LONG_PTR)pPropInfo); - - pPropInfo->hTaskbarWnd = hwnd; - - CheckDlgButton(hwnd, IDC_TASKBARPROP_LOCK, TaskBarSettings.bLock ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_HIDE, TaskBarSettings.bAutoHide ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_ONTOP, TaskBarSettings.bAlwaysOnTop ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_GROUP, TaskBarSettings.bGroupButtons ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_SHOWQL, TaskBarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_CLOCK, TaskBarSettings.bShowClock ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_SECONDS, TaskBarSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_TASKBARPROP_HIDEICONS, TaskBarSettings.bHideInactiveIcons ? BST_CHECKED : BST_UNCHECKED); - - UpdateBitmaps(pPropInfo); -} + LRESULT OnCustomizeTrayIcons(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) + { + ShowCustomizeNotifyIcons(hExplorerInstance, m_hWnd); + return 0; + } -static VOID -OnCreateStartPage(HWND hwnd, - PPROPSHEET_INFO pPropInfo) -{ - pPropInfo->hStartWnd = hwnd; + LRESULT OnCtrlCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) + { + UpdateDialog(); + SetModified(TRUE); + return 0; + } - CheckDlgButton(hwnd, IDC_TASKBARPROP_STARTMENUCLASSIC, 1); // HACK: This has to be read from registry! - - UpdateBitmaps(pPropInfo); -} + int OnApply() + { + TaskbarSettings newSettings; + memcpy(&newSettings, &g_TaskbarSettings, sizeof(TaskbarSettings)); + + newSettings.bLock = IsDlgButtonChecked(IDC_TASKBARPROP_LOCK); + newSettings.sr.AutoHide = IsDlgButtonChecked(IDC_TASKBARPROP_HIDE); + newSettings.sr.AlwaysOnTop = IsDlgButtonChecked(IDC_TASKBARPROP_ONTOP); + newSettings.bGroupButtons = IsDlgButtonChecked(IDC_TASKBARPROP_GROUP); + //newSettings.bShowQuickLaunch = IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL); + newSettings.sr.HideClock = !IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK); + newSettings.bShowSeconds = IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS); + newSettings.bHideInactiveIcons = IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS); -INT_PTR CALLBACK -TaskbarPageProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) + SendMessage(m_hwndTaskbar, TWM_SETTINGSCHANGED, 0, (LPARAM)&newSettings); + + return PSNRET_NOERROR; + } +}; + +class CStartMenuSettingsPage : public CPropertyPageImpl<CStartMenuSettingsPage> { - PPROPSHEET_INFO pPropInfo; +private: + HBITMAP m_hbmpStartBitmap; - /* Get the window context */ - pPropInfo = (PPROPSHEET_INFO)GetWindowLongPtrW(hwndDlg, - GWLP_USERDATA); - if (pPropInfo == NULL && uMsg != WM_INITDIALOG) + void UpdateDialog() { - goto HandleDefaultMessage; + HWND hwndCustomizeClassic = GetDlgItem(IDC_TASKBARPROP_STARTMENUCLASSICCUST); + HWND hwndCustomizeModern = GetDlgItem(IDC_TASKBARPROP_STARTMENUCUST); + HWND hwndStartBitmap = GetDlgItem(IDC_TASKBARPROP_STARTMENU_BITMAP); + + BOOL bModern = IsDlgButtonChecked(IDC_TASKBARPROP_STARTMENU); + ::EnableWindow(hwndCustomizeModern, bModern); + ::EnableWindow(hwndCustomizeClassic, !bModern); + + UINT uImageId = bModern ? IDB_STARTPREVIEW : IDB_STARTPREVIEW_CLASSIC; + SetBitmap(hwndStartBitmap, &m_hbmpStartBitmap, uImageId); } - switch (uMsg) +public: + enum { IDD = IDD_TASKBARPROP_STARTMENU }; + + BEGIN_MSG_MAP(CTaskBarSettingsPage) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_ID_HANDLER(IDC_TASKBARPROP_STARTMENUCLASSICCUST, OnStartMenuCustomize) + CHAIN_MSG_MAP(CPropertyPageImpl<CStartMenuSettingsPage>) + END_MSG_MAP() + + CStartMenuSettingsPage(): + m_hbmpStartBitmap(NULL) { - case WM_INITDIALOG: - OnCreateTaskbarPage(hwndDlg, (PPROPSHEET_INFO)((LPPROPSHEETPAGE)lParam)->lParam); - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_TASKBARPROP_LOCK: - case IDC_TASKBARPROP_HIDE: - case IDC_TASKBARPROP_GROUP: - case IDC_TASKBARPROP_SHOWQL: - case IDC_TASKBARPROP_HIDEICONS: - case IDC_TASKBARPROP_CLOCK: - case IDC_TASKBARPROP_SECONDS: - if (HIWORD(wParam) == BN_CLICKED) - { - UpdateBitmaps(pPropInfo); - - /* Enable the 'Apply' button */ - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } - break; - case IDC_TASKBARPROP_ICONCUST: - ShowCustomizeNotifyIcons(hExplorerInstance, hwndDlg); - break; - } - break; - - case WM_NOTIFY: - { - LPNMHDR pnmh = (LPNMHDR)lParam; - - switch (pnmh->code) - { - case PSN_SETACTIVE: - break; - - case PSN_APPLY: - TaskBarSettings.bLock = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_LOCK); - TaskBarSettings.bAutoHide = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_HIDE); - TaskBarSettings.bAlwaysOnTop = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_ONTOP); - TaskBarSettings.bGroupButtons = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_GROUP); - TaskBarSettings.bShowQuickLaunch = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SHOWQL); - TaskBarSettings.bShowClock = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_CLOCK); - TaskBarSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS); - TaskBarSettings.bHideInactiveIcons = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_HIDEICONS); - SaveTaskBarSettings(); - break; - } - - break; - } - - case WM_DESTROY: - if (pPropInfo->hTaskbarBitmap) - { - DeleteObject(pPropInfo->hTaskbarBitmap); - } - if (pPropInfo->hTrayBitmap) - { - DeleteObject(pPropInfo->hTrayBitmap); - } - break; - -HandleDefaultMessage: - default: - return FALSE; } - return FALSE; -} - -static INT_PTR CALLBACK -StartMenuPageProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - switch (uMsg) + ~CStartMenuSettingsPage() { - case WM_INITDIALOG: - OnCreateStartPage(hwndDlg, (PPROPSHEET_INFO)((LPPROPSHEETPAGE)lParam)->lParam); - break; - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_TASKBARPROP_STARTMENUCLASSICCUST: - ShowCustomizeClassic(hExplorerInstance, hwndDlg); - break; - } - break; - } - - case WM_DESTROY: - break; - - case WM_NOTIFY: - { - LPNMHDR pnmh = (LPNMHDR)lParam; - - switch (pnmh->code) - { - case PSN_SETACTIVE: - break; - - case PSN_APPLY: - break; - } - - break; - } + if (m_hbmpStartBitmap) + DeleteObject(m_hbmpStartBitmap); } - return FALSE; -} + LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) + { + CheckDlgButton(IDC_TASKBARPROP_STARTMENUCLASSIC, BST_CHECKED); // HACK: This has to be read from registry! + UpdateDialog(); + return TRUE; + } -static VOID -InitPropSheetPage(PROPSHEETPAGE *psp, - WORD idDlg, - DLGPROC DlgProc, - LPARAM lParam) -{ - ZeroMemory(psp, sizeof(*psp)); - psp->dwSize = sizeof(*psp); - psp->dwFlags = PSP_DEFAULT; - psp->hInstance = hExplorerInstance; - psp->pszTemplate = MAKEINTRESOURCEW(idDlg); - psp->lParam = lParam; - psp->pfnDlgProc = DlgProc; -} + LRESULT OnStartMenuCustomize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) + { + ShowCustomizeClassic(hExplorerInstance, m_hWnd); + return 0; + } + int OnApply() + { + //TODO + return PSNRET_NOERROR; + } +}; VOID -DisplayTrayProperties(IN HWND hwndOwner) +DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar) { - PROPSHEET_INFO propInfo = {0}; PROPSHEETHEADER psh; - PROPSHEETPAGE psp[2]; - WCHAR szCaption[256]; - - if (!LoadStringW(hExplorerInstance, - IDS_TASKBAR_STARTMENU_PROP_CAPTION, - szCaption, - _countof(szCaption))) - { - return; - } + HPROPSHEETPAGE hpsp[2]; + CTaskBarSettingsPage tbSettingsPage(hwndTaskbar); + CStartMenuSettingsPage smSettingsPage; + CStringW caption; + + caption.LoadStringW(IDS_TASKBAR_STARTMENU_PROP_CAPTION); + + hpsp[0] = tbSettingsPage.Create(); + hpsp[1] = smSettingsPage.Create(); ZeroMemory(&psh, sizeof(psh)); psh.dwSize = sizeof(psh); - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE; + psh.dwFlags = PSH_PROPTITLE; psh.hwndParent = hwndOwner; psh.hInstance = hExplorerInstance; psh.hIcon = NULL; - psh.pszCaption = szCaption; - psh.nPages = _countof(psp); + psh.pszCaption = caption.GetString(); + psh.nPages = _countof(hpsp); psh.nStartPage = 0; - psh.ppsp = psp; - - InitPropSheetPage(&psp[0], IDD_TASKBARPROP_TASKBAR, TaskbarPageProc, (LPARAM)&propInfo); - InitPropSheetPage(&psp[1], IDD_TASKBARPROP_STARTMENU, StartMenuPageProc, (LPARAM)&propInfo); + psh.phpage = hpsp; PropertySheet(&psh); } diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index f703955a30..fefd0f0623 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -237,12 +237,6 @@ public: DWORD Flags; struct { - DWORD AutoHide : 1; - DWORD AlwaysOnTop : 1; - DWORD SmSmallIcons : 1; - DWORD HideClock : 1; - DWORD Locked : 1; - /* UI Status */ DWORD InSizeMove : 1; DWORD IsDragging : 1; @@ -411,7 +405,7 @@ public: m_TrayPropertiesOwner = hwnd; - DisplayTrayProperties(hwnd); + DisplayTrayProperties(hwnd, m_hWnd); m_TrayPropertiesOwner = NULL; ::DestroyWindow(hwnd); @@ -494,7 +488,7 @@ public: case ID_LOCKTASKBAR: if (SHRestricted(REST_CLASSICSHELL) == 0) { - Lock(!Locked); + Lock(!g_TaskbarSettings.bLock); } break; @@ -1192,7 +1186,7 @@ GetPrimaryScreenRect: without user interaction. */ rcTray = m_TrayRects[m_Position]; - if (AutoHide) + if (g_TaskbarSettings.sr.AutoHide) { rcTray.left += m_AutoHideOffset.cx; rcTray.right += m_AutoHideOffset.cx; @@ -1273,7 +1267,7 @@ ChangePos: /* If AutoHide is false then change the workarea to exclude the area that the taskbar covers. */ - if (!AutoHide) + if (!g_TaskbarSettings.sr.AutoHide) { switch (m_Position) { @@ -1324,23 +1318,11 @@ ChangePos: ApplyClipping(TRUE); } - typedef struct _TW_STUCKRECTS2 - { - DWORD cbSize; - LONG Unknown; - DWORD dwFlags; - DWORD Position; - SIZE Size; - RECT Rect; - } TW_STRUCKRECTS2, *PTW_STUCKRECTS2; - VOID RegLoadSettings() { DWORD Pos; - TW_STRUCKRECTS2 sr; RECT rcScreen; SIZE WndSize, EdgeSize, DlgFrameSize; - DWORD cbSize = sizeof(sr); SIZE StartBtnSize = m_StartButton.GetSize(); EdgeSize.cx = GetSystemMetrics(SM_CXEDGE); @@ -1348,44 +1330,12 @@ ChangePos: DlgFrameSize.cx = GetSystemMetrics(SM_CXDLGFRAME); DlgFrameSize.cy = GetSystemMetrics(SM_CYDLGFRAME); - if (SHGetValue(hkExplorer, - TEXT("StuckRects2"), - TEXT("Settings"), - NULL, - &sr, - &cbSize) == ERROR_SUCCESS && - sr.cbSize == sizeof(sr)) - { - AutoHide = (sr.dwFlags & ABS_AUTOHIDE) != 0; - AlwaysOnTop = (sr.dwFlags & ABS_ALWAYSONTOP) != 0; - SmSmallIcons = (sr.dwFlags & 0x4) != 0; - HideClock = (sr.dwFlags & 0x8) != 0; - - /* FIXME: Are there more flags? */ + m_Position = g_TaskbarSettings.sr.Position; + rcScreen = g_TaskbarSettings.sr.Rect; + GetScreenRectFromRect(&rcScreen, MONITOR_DEFAULTTONEAREST); -#if WIN7_DEBUG_MODE - m_Position = ABE_LEFT; -#else - if (sr.Position > ABE_BOTTOM) - m_Position = ABE_BOTTOM; - else - m_Position = sr.Position; -#endif - - /* Try to find out which monitor the tray window was located on last. - Here we're only interested in the monitor screen that we think - is the last one used. We're going to determine on which monitor - we really are after calculating the docked position. */ - rcScreen = sr.Rect; - GetScreenRectFromRect( - &rcScreen, - MONITOR_DEFAULTTONEAREST); - } - else + if (!g_TaskbarSettings.sr.Size.cx || !g_TaskbarSettings.sr.Size.cy) { - m_Position = ABE_BOTTOM; - AlwaysOnTop = TRUE; - /* Use the minimum size of the taskbar, we'll use the start button as a minimum for now. Make sure we calculate the entire window size, not just the client size. However, we @@ -1393,36 +1343,17 @@ ChangePos: the start button and bands are not stuck to the screen border. */ if(!m_Theme) { - sr.Size.cx = StartBtnSize.cx + (2 * (EdgeSize.cx + DlgFrameSize.cx)); - sr.Size.cy = StartBtnSize.cy + (2 * (EdgeSize.cy + DlgFrameSize.cy)); + g_TaskbarSettings.sr.Size.cx = StartBtnSize.cx + (2 * (EdgeSize.cx + DlgFrameSize.cx)); + g_TaskbarSettings.sr.Size.cy = StartBtnSize.cy + (2 * (EdgeSize.cy + DlgFrameSize.cy)); } else { - sr.Size.cx = StartBtnSize.cx - EdgeSize.cx; - sr.Size.cy = StartBtnSize.cy - EdgeSize.cy; - if(!Locked) - sr.Size.cy += GetSystemMetrics(SM_CYSIZEFRAME); + g_TaskbarSettings.sr.Size.cx = StartBtnSize.cx - EdgeSize.cx; + g_TaskbarSettings.sr.Size.cy = StartBtnSize.cy - EdgeSize.cy; + if(!g_TaskbarSettings.bLock) + g_TaskbarSettings.sr.Size.cy += GetSystemMetrics(SM_CYSIZEFRAME); } - - /* Use the primary screen by default */ - rcScreen.left = 0; - rcScreen.top = 0; - rcScreen.right = GetSystemMetrics(SM_CXSCREEN); - rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); - GetScreenRectFromRect( - &rcScreen, - MONITOR_DEFAULTTOPRIMARY); } - - if (m_hWnd != NULL) - SetWindowPos( - AlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, - 0, - 0, - 0, - 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - /* Determine a minimum tray window rectangle. The "client" height is zero here since we cannot determine an optimal minimum width when loaded as a vertical tray window. We just need to make sure the values @@ -1440,10 +1371,10 @@ ChangePos: WndSize.cy = StartBtnSize.cy - EdgeSize.cx; } - if (WndSize.cx < sr.Size.cx) - WndSize.cx = sr.Size.cx; - if (WndSize.cy < sr.Size.cy) - WndSize.cy = sr.Size.cy; + if (WndSize.cx < g_TaskbarSettings.sr.Size.cx) + WndSize.cx = g_TaskbarSettings.sr.Size.cx; + if (WndSize.cy < g_TaskbarSettings.sr.Size.cy) + WndSize.cy = g_TaskbarSettings.sr.Size.cy; /* Save the calculated size */ m_TraySize = WndSize; @@ -1940,7 +1871,7 @@ ChangePos: } DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE; - if (AlwaysOnTop) + if (g_TaskbarSettings.sr.AlwaysOnTop) dwExStyle |= WS_EX_TOPMOST; DWORD dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; @@ -1996,18 +1927,18 @@ ChangePos: BOOL STDMETHODCALLTYPE Lock(IN BOOL bLock) { - BOOL bPrevLock = Locked; + BOOL bPrevLock = g_TaskbarSettings.bLock; - if (Locked != bLock) + if (g_TaskbarSettings.bLock != bLock) { - Locked = bLock; + g_TaskbarSettings.bLock = bLock; if (m_TrayBandSite != NULL) { if (!SUCCEEDED(m_TrayBandSite->Lock(bLock))) { /* Reset?? */ - Locked = bPrevLock; + g_TaskbarSettings.bLock = bPrevLock; return bPrevLock; } } @@ -2020,7 +1951,7 @@ ChangePos: RECT rcGripper = {0}; AdjustSizerRect(&rcGripper, Pos); - if(Locked) + if(g_TaskbarSettings.bLock) { m_TrayRects[Pos].top += rcGripper.top; m_TrayRects[Pos].left += rcGripper.left; @@ -2130,13 +2061,13 @@ ChangePos: SetWindowTheme(m_Rebar, L"TaskBar", NULL); /* Create the tray notification window */ - m_TrayNotify = CreateTrayNotifyWnd(this, HideClock, &m_TrayNotifyInstance); + m_TrayNotify = CreateTrayNotifyWnd(this, &m_TrayNotifyInstance); UpdateFonts(); InitShellServices(&m_ShellServices); - if (AutoHide) + if (g_TaskbarSettings.sr.AutoHide) { m_AutoHideState = AUTOHIDE_HIDING; SetTimer(TIMER_ID_AUTOHIDE, AUTOHIDE_DELAY_HIDE, NULL); @@ -2248,7 +2179,7 @@ ChangePos: RECT rcClient; POINT pt; - if (Locked) + if (g_TaskbarSettings.bLock) { /* The user may not be able to resize the tray window. Pretend like the window is not sizeable when the user @@ -2307,7 +2238,7 @@ ChangePos: need to be able to move the window in case the user wants to drag the tray window to another position or in case the user wants to resize the tray window. */ - if (!Locked && GetCursorPos(&ptCursor)) + if (!g_TaskbarSettings.bLock && GetCursorPos(&ptCursor)) { IsDragging = TRUE; m_DraggingPosition = GetDraggingRectFromPt(ptCursor, pRect, &m_DraggingMonitor); @@ -2323,7 +2254,7 @@ ChangePos: { PRECT pRect = (PRECT) lParam; - if (!Locked) + if (!g_TaskbarSettings.bLock) { FitToRebar(pRect); } @@ -2370,7 +2301,7 @@ ChangePos: { InSizeMove = TRUE; IsDragging = FALSE; - if (!Locked) + if (!g_TaskbarSettings.bLock) { /* Remove the clipping on multi monitor systems while dragging around */ ApplyClipping(FALSE); @@ -2381,7 +2312,7 @@ ChangePos: LRESULT OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { InSizeMove = FALSE; - if (!Locked) + if (!g_TaskbarSettings.bLock) { FitToRebar(&m_TrayRects[m_Position]); @@ -2714,7 +2645,7 @@ HandleTrayContextMenu: LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - if (AutoHide) + if (g_TaskbarSettings.sr.AutoHide) { SetTimer(TIMER_ID_MOUSETRACK, MOUSETRACK_INTERVAL, NULL); } @@ -2741,7 +2672,7 @@ HandleTrayContextMenu: { RECT *rc = NULL; /* Ignore WM_NCCALCSIZE if we are not themed or locked */ - if(!m_Theme || Locked) + if(!m_Theme || g_TaskbarSettings.bLock) { bHandled = FALSE; return 0; @@ -2817,6 +2748,41 @@ HandleTrayContextMenu: return 0; } + LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + TaskbarSettings* newSettings = (TaskbarSettings*)lParam; + + /* Propagate the new settings to the children */ + ::SendMessageW(m_TaskSwitch, uMsg, wParam, lParam); + ::SendMessageW(m_TrayNotify, uMsg, wParam, lParam); + + /* Toggle autohide */ + if (newSettings->sr.AutoHide != g_TaskbarSettings.sr.AutoHide) + { + g_TaskbarSettings.sr.AutoHide = newSettings->sr.AutoHide; + memset(&m_AutoHideOffset, 0, sizeof(m_AutoHideOffset)); + m_AutoHideState = AUTOHIDE_SHOWN; + if (!newSettings->sr.AutoHide) + SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER); + else + SetTimer(TIMER_ID_MOUSETRACK, MOUSETRACK_INTERVAL, NULL); + } + + /* Toggle lock state */ + Lock(newSettings->bLock); + + /* Toggle OnTop state */ + if (newSettings->sr.AlwaysOnTop != g_TaskbarSettings.sr.AlwaysOnTop) + { + g_TaskbarSettings.sr.AlwaysOnTop = newSettings->sr.AlwaysOnTop; + HWND hWndInsertAfter = newSettings->sr.AlwaysOnTop ? HWND_TOPMOST : HWND_BOTTOM; + SetWindowPos(hWndInsertAfter, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + } + + g_TaskbarSettings.Save(); + return 0; + } + DECLARE_WND_CLASS_EX(szTrayWndClass, CS_DBLCLKS, COLOR_3DFACE) BEGIN_MSG_MAP(CTrayWindow) @@ -2872,6 +2838,7 @@ HandleTrayContextMenu: MESSAGE_HANDLER(WM_CLOSE, OnDoExitWindows) MESSAGE_HANDLER(WM_HOTKEY, OnHotkey) MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize) + MESSAGE_HANDLER(TWM_SETTINGSCHANGED, OnTaskbarSettingsChanged) ALT_MSG_MAP(1) END_MSG_MAP() @@ -3032,7 +2999,7 @@ public: CheckMenuItem(hPopup, ID_LOCKTASKBAR, - MF_BYCOMMAND | (TrayWnd->Locked ? MF_CHECKED : MF_UNCHECKED)); + MF_BYCOMMAND | (g_TaskbarSettings.bLock ? MF_CHECKED : MF_UNCHECKED)); UINT idCmdNext; idCmdNext = Shell_MergeMenus(hPopup, menubase, indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS | MM_ADDSEPARATOR);
7 years, 1 month
1
0
0
0
[reactos] 02/02: [RDBSS] Implement RxQueryNameInfo() and RxConjureOriginalName()
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc578af6df1c6299fc225…
commit cc578af6df1c6299fc2256559dfea80ef172cfd2 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Tue Oct 31 23:03:16 2017 +0100 [RDBSS] Implement RxQueryNameInfo() and RxConjureOriginalName() --- sdk/include/ddk/rxprocs.h | 16 ++++ sdk/lib/drivers/rdbsslib/rdbss.c | 165 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 179 insertions(+), 2 deletions(-) diff --git a/sdk/include/ddk/rxprocs.h b/sdk/include/ddk/rxprocs.h index 819ba72d03..5c74496be9 100644 --- a/sdk/include/ddk/rxprocs.h +++ b/sdk/include/ddk/rxprocs.h @@ -75,6 +75,22 @@ RxFindOrCreateConnections( _In_ PRX_CONNECTION_ID RxConnectionId); #endif +typedef enum _RX_NAME_CONJURING_METHODS +{ + VNetRoot_As_Prefix, + VNetRoot_As_UNC_Name, + VNetRoot_As_DriveLetter +} RX_NAME_CONJURING_METHODS; + +VOID +RxConjureOriginalName( + _Inout_ PFCB Fcb, + _Inout_ PFOBX Fobx, + _Out_ PULONG ActualNameLength, + _Out_writes_bytes_( *LengthRemaining) PWCHAR OriginalName, + _Inout_ PLONG LengthRemaining, + _In_ RX_NAME_CONJURING_METHODS NameConjuringMethod); + #if (_WIN32_WINNT >= 0x0600) NTSTATUS RxCompleteMdl( diff --git a/sdk/lib/drivers/rdbsslib/rdbss.c b/sdk/lib/drivers/rdbsslib/rdbss.c index 4f888c8c13..154c63ad72 100644 --- a/sdk/lib/drivers/rdbsslib/rdbss.c +++ b/sdk/lib/drivers/rdbsslib/rdbss.c @@ -4786,6 +4786,134 @@ RxCompleteMdl( return STATUS_SUCCESS; } +/* + * @implemented + */ +VOID +RxConjureOriginalName( + PFCB Fcb, + PFOBX Fobx, + PULONG ActualNameLength, + PWCHAR OriginalName, + PLONG LengthRemaining, + RX_NAME_CONJURING_METHODS NameConjuringMethod) +{ + PWSTR Prefix, Name; + PV_NET_ROOT VNetRoot; + USHORT PrefixLength, NameLength, ToCopy; + + PAGED_CODE(); + + VNetRoot = Fcb->VNetRoot; + /* We will use the prefix contained in NET_ROOT, if we don't have + * a V_NET_ROOT, or if it wasn't null deviced or if we already have + * a UNC path */ + if (VNetRoot == NULL || VNetRoot->PrefixEntry.Prefix.Buffer[1] != L';' || + BooleanFlagOn(Fobx->Flags, FOBX_FLAG_UNC_NAME)) + { + Prefix = ((PNET_ROOT)Fcb->pNetRoot)->PrefixEntry.Prefix.Buffer; + PrefixLength = ((PNET_ROOT)Fcb->pNetRoot)->PrefixEntry.Prefix.Length; + NameLength = 0; + + /* In that case, keep track that we will have a prefix as buffer */ + NameConjuringMethod = VNetRoot_As_Prefix; + } + else + { + ASSERT(NodeType(VNetRoot) == RDBSS_NTC_V_NETROOT); + + /* Otherwise, return the prefix from our V_NET_ROOT */ + Prefix = VNetRoot->PrefixEntry.Prefix.Buffer; + PrefixLength = VNetRoot->PrefixEntry.Prefix.Length; + NameLength = VNetRoot->NamePrefix.Length; + + /* If we want a UNC path, skip potential device */ + if (NameConjuringMethod == VNetRoot_As_UNC_Name) + { + do + { + ++Prefix; + PrefixLength -= sizeof(WCHAR); + } while (PrefixLength > 0 && Prefix[0] != L'\\'); + } + } + + /* If we added an extra backslash, skip it */ + if (BooleanFlagOn(Fcb->FcbState, FCB_STATE_ADDEDBACKSLASH)) + { + NameLength += sizeof(WCHAR); + } + + /* If we're asked for a drive letter, skip the prefix */ + if (NameConjuringMethod == VNetRoot_As_DriveLetter) + { + PrefixLength = 0; + + /* And make sure we arrive at a backslash */ + if (Fcb->FcbTableEntry.Path.Length > NameLength && + Fcb->FcbTableEntry.Path.Buffer[NameLength / sizeof(WCHAR)] != L'\\') + { + NameLength -= sizeof(WCHAR); + } + } + else + { + /* Prepare to copy the prefix, make sure not to overflow */ + if (*LengthRemaining >= PrefixLength) + { + /* Copy everything */ + ToCopy = PrefixLength; + *LengthRemaining = *LengthRemaining - PrefixLength; + } + else + { + /* Copy as much as we can */ + ToCopy = *LengthRemaining; + /* And return failure */ + *LengthRemaining = -1; + } + + /* Copy the prefix */ + RtlCopyMemory(OriginalName, Prefix, ToCopy); + } + + /* Do we have a name to copy now? */ + if (Fcb->FcbTableEntry.Path.Length > NameLength) + { + ToCopy = Fcb->FcbTableEntry.Path.Length - NameLength; + Name = Fcb->FcbTableEntry.Path.Buffer; + } + else + { + /* Just use slash for now */ + ToCopy = sizeof(WCHAR); + NameLength = 0; + Name = L"\\"; + } + + /* Total length we will have in the output buffer (if everything is alright) */ + *ActualNameLength = ToCopy + PrefixLength; + /* If we still have room to write data */ + if (*LengthRemaining != -1) + { + /* If we can copy everything, it's fine! */ + if (*LengthRemaining > ToCopy) + { + *LengthRemaining = *LengthRemaining - ToCopy; + } + /* Otherwise, copy as much as possible, and return failure */ + else + { + ToCopy = *LengthRemaining; + *LengthRemaining = -1; + } + + /* Copy name after the prefix */ + RtlCopyMemory(Add2Ptr(OriginalName, PrefixLength), + Add2Ptr(Name, NameLength), ToCopy); + } +} + /* * @implemented */ @@ -8012,13 +8140,46 @@ RxQueryInternalInfo( return STATUS_NOT_IMPLEMENTED; } +/* + * @implemented + */ NTSTATUS RxQueryNameInfo( PRX_CONTEXT RxContext, PFILE_NAME_INFORMATION NameInfo) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PFCB Fcb; + PFOBX Fobx; + PAGED_CODE(); + + DPRINT("RxQueryNameInfo(%p, %p)\n", RxContext, NameInfo); + + /* Check we can at least copy name size */ + if (RxContext->Info.LengthRemaining < FIELD_OFFSET(FILE_NAME_INFORMATION, FileName)) + { + DPRINT1("Buffer too small: %d\n", RxContext->Info.LengthRemaining); + RxContext->Info.Length = 0; + return STATUS_BUFFER_OVERFLOW; + } + + Fcb = (PFCB)RxContext->pFcb; + Fobx = (PFOBX)RxContext->pFobx; + /* Get the UNC name */ + RxConjureOriginalName(Fcb, Fobx, &NameInfo->FileNameLength, &NameInfo->FileName[0], + &RxContext->Info.Length, VNetRoot_As_UNC_Name); + + /* If RxConjureOriginalName returned a negative len (-1) then output buffer + * was too small, return the appropriate length & status. + */ + if (RxContext->Info.LengthRemaining < 0) + { + DPRINT1("Buffer too small!\n"); + RxContext->Info.Length = 0; + return STATUS_BUFFER_OVERFLOW; + } + + /* All correct */ + return STATUS_SUCCESS; } NTSTATUS
7 years, 1 month
1
0
0
0
[reactos] 01/02: [RXCE] Implement RxAcquireExclusiveFcbResourceInMRx()
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f5104a00424aa532ce456…
commit f5104a00424aa532ce45631d331bce9f70dc6b5d Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Tue Oct 31 21:34:36 2017 +0100 [RXCE] Implement RxAcquireExclusiveFcbResourceInMRx() --- sdk/lib/drivers/rxce/rxce.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/lib/drivers/rxce/rxce.c b/sdk/lib/drivers/rxce/rxce.c index 2c91c0ba17..7473a2a4fa 100644 --- a/sdk/lib/drivers/rxce/rxce.c +++ b/sdk/lib/drivers/rxce/rxce.c @@ -174,13 +174,15 @@ BOOLEAN DumpDispatchRoutine = FALSE; /* FUNCTIONS ****************************************************************/ +/* + * @implemented + */ NTSTATUS NTAPI RxAcquireExclusiveFcbResourceInMRx( _Inout_ PMRX_FCB Fcb) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + return RxAcquireExclusiveFcb(NULL, (PFCB)Fcb); } /*
7 years, 1 month
1
0
0
0
[reactos] 01/01: [SERIAL] Fix Serial{Get, Clear}PerfStats() to become proper PKSYNCHRONIZE_ROUTINE routines and get rid of the related casts. Brought to you by Thomas Faber. CORE-11799 (#94)
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56cc2ca11592fd2846c1d…
commit 56cc2ca11592fd2846c1daa6ca7414aa7bc71f8a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Oct 31 15:44:39 2017 +0100 [SERIAL] Fix Serial{Get,Clear}PerfStats() to become proper PKSYNCHRONIZE_ROUTINE routines and get rid of the related casts. Brought to you by Thomas Faber. CORE-11799 (#94) --- drivers/serial/serial/devctrl.c | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/drivers/serial/serial/devctrl.c b/drivers/serial/serial/devctrl.c index 189f97eba2..74b81395c3 100644 --- a/drivers/serial/serial/devctrl.c +++ b/drivers/serial/serial/devctrl.c @@ -158,36 +158,37 @@ SerialSetLineControl( return Status; } -static BOOLEAN -SerialClearPerfStats( - IN PSERIAL_DEVICE_EXTENSION DeviceExtension) +static +BOOLEAN +NTAPI +SerialClearPerfStats(IN PVOID SynchronizeContext) { - ASSERT(DeviceExtension); - - RtlZeroMemory(&DeviceExtension->SerialPerfStats, sizeof(SERIALPERF_STATS)); - DeviceExtension->BreakInterruptErrorCount = 0; - return TRUE; + PSERIAL_DEVICE_EXTENSION DeviceExtension = SynchronizeContext; + ASSERT(DeviceExtension); + RtlZeroMemory(&DeviceExtension->SerialPerfStats, sizeof(SERIALPERF_STATS)); + DeviceExtension->BreakInterruptErrorCount = 0; + return TRUE; } -static BOOLEAN -SerialGetPerfStats(IN PIRP pIrp) +static +BOOLEAN +NTAPI +SerialGetPerfStats(IN PVOID SynchronizeContext) { - PSERIAL_DEVICE_EXTENSION pDeviceExtension; - - ASSERT(pIrp); - pDeviceExtension = (PSERIAL_DEVICE_EXTENSION) - IoGetCurrentIrpStackLocation(pIrp)->DeviceObject->DeviceExtension; - - /* - * we assume buffer is big enough to hold SerialPerfStats structure - * caller must verify this - */ - RtlCopyMemory( - pIrp->AssociatedIrp.SystemBuffer, - &pDeviceExtension->SerialPerfStats, - sizeof(SERIALPERF_STATS) - ); - return TRUE; + PIRP pIrp = SynchronizeContext; + PSERIAL_DEVICE_EXTENSION pDeviceExtension; + + ASSERT(pIrp); + pDeviceExtension = IoGetCurrentIrpStackLocation(pIrp)->DeviceObject->DeviceExtension; + + /* + * we assume buffer is big enough to hold SerialPerfStats structure + * caller must verify this + */ + RtlCopyMemory(pIrp->AssociatedIrp.SystemBuffer, + &pDeviceExtension->SerialPerfStats, + sizeof(SERIALPERF_STATS)); + return TRUE; } static NTSTATUS @@ -309,7 +310,7 @@ SerialDeviceControl( TRACE_(SERIAL, "IOCTL_SERIAL_CLEAR_STATS\n"); KeSynchronizeExecution( DeviceExtension->Interrupt, - (PKSYNCHRONIZE_ROUTINE)SerialClearPerfStats, + SerialClearPerfStats, DeviceExtension); Status = STATUS_SUCCESS; break; @@ -519,7 +520,7 @@ SerialDeviceControl( else { KeSynchronizeExecution(DeviceExtension->Interrupt, - (PKSYNCHRONIZE_ROUTINE)SerialGetPerfStats, Irp); + SerialGetPerfStats, Irp); Information = sizeof(SERIALPERF_STATS); Status = STATUS_SUCCESS; }
7 years, 1 month
1
0
0
0
[reactos] 01/01: [XDK][DDK] Take the gcc path for __assert_annotation{A, W} and __CREATE_NTOS_DATA_IMPORT_ALIAS when compiling with clang-cl. Include kdfuncs.h before rtlfuncs.h to have DbgPrint() defined before using it. CORE-11799 (#94)
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9556390f8fcc4ae629daa…
commit 9556390f8fcc4ae629daaae45c9fa1b2f859689f Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Oct 31 15:19:49 2017 +0100 [XDK][DDK] Take the gcc path for __assert_annotation{A,W} and __CREATE_NTOS_DATA_IMPORT_ALIAS when compiling with clang-cl. Include kdfuncs.h before rtlfuncs.h to have DbgPrint() defined before using it. CORE-11799 (#94) --- sdk/include/xdk/rtlfuncs.h | 2 +- sdk/include/xdk/wdm.template.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/include/xdk/rtlfuncs.h b/sdk/include/xdk/rtlfuncs.h index b86be14a3c..ac5214336e 100644 --- a/sdk/include/xdk/rtlfuncs.h +++ b/sdk/include/xdk/rtlfuncs.h @@ -3200,7 +3200,7 @@ RtlCheckBit( #define RtlUlongByteSwap(_x) _byteswap_ulong((_x)) #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x)) -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) # define __assert_annotationA(msg) __annotation(L"Debug", L"AssertFail", L ## msg) # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg) #else diff --git a/sdk/include/xdk/wdm.template.h b/sdk/include/xdk/wdm.template.h index 1f7b392a1a..9893977c09 100644 --- a/sdk/include/xdk/wdm.template.h +++ b/sdk/include/xdk/wdm.template.h @@ -150,7 +150,7 @@ $define(USHORT=USHORT) #define __IMPORTSYMBOL(_Name) "__imp_"#_Name #define __IMPORTNAME(_Name) __imp_##_Name #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \ __pragma(comment(linker, "/alternatename:"__SYMBOL(_Name) "=" __IMPORTSYMBOL(_Name))) #else /* !_MSC_VER */ @@ -251,6 +251,7 @@ $include (obtypes.h) $include (pstypes.h) $include (wmitypes.h) +$include (kdfuncs.h) $include (kefuncs.h) $include (rtlfuncs.h) $include (mmfuncs.h) @@ -262,7 +263,6 @@ $include (exfuncs.h) $include (obfuncs.h) $include (psfuncs.h) $include (wmifuncs.h) -$include (kdfuncs.h) $include (halfuncs.h) $include (nttmapi.h) $include (zwfuncs.h)
7 years, 1 month
1
0
0
0
[reactos] 01/01: [LIB/ATL] Take the gcc code path for the unused macros when compiling with clang. CORE-11799 (#94)
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a75904fe6603de8a296d9…
commit a75904fe6603de8a296d99e7d15585bb465eebf5 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Oct 31 14:44:07 2017 +0100 [LIB/ATL] Take the gcc code path for the unused macros when compiling with clang. CORE-11799 (#94) --- sdk/lib/atl/atlwin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/lib/atl/atlwin.h b/sdk/lib/atl/atlwin.h index 3f68348a4e..76b1073ed5 100644 --- a/sdk/lib/atl/atlwin.h +++ b/sdk/lib/atl/atlwin.h @@ -20,7 +20,7 @@ #pragma once -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) #define GCCU(x) x __attribute__((unused)) #define Unused(x) #else
7 years, 1 month
1
0
0
0
[reactos] 01/01: [STORPORT] Check status code of the call to PortFdoConnectInterrupt(). CORE-13866
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58bb4b31bc47361751c96…
commit 58bb4b31bc47361751c965afbb1ea521f328ed37 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Tue Oct 31 14:09:04 2017 +0100 [STORPORT] Check status code of the call to PortFdoConnectInterrupt(). CORE-13866 --- drivers/storage/port/storport/fdo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/storage/port/storport/fdo.c b/drivers/storage/port/storport/fdo.c index 3c49619b23..92a5a7f9a1 100644 --- a/drivers/storage/port/storport/fdo.c +++ b/drivers/storage/port/storport/fdo.c @@ -139,9 +139,13 @@ PortFdoStartMiniport( return Status; } - + /* Connect the configured interrupt */ Status = PortFdoConnectInterrupt(DeviceExtension); - + if (!NT_SUCCESS(Status)) + { + DPRINT1("PortFdoConnectInterrupt() failed (Status 0x%08lx)\n", Status); + return Status; + } /* Call the miniports HwInitialize function */ Status = MiniportHwInitialize(&DeviceExtension->Miniport);
7 years, 1 month
1
0
0
0
[reactos] 01/01: [LIBXML2] Do not rely on nan() when compiling with clang. CORE-11799 (#94)
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7571d351ce624bb0a9ce8…
commit 7571d351ce624bb0a9ce873218987b5b06e8a053 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Oct 31 14:10:03 2017 +0100 [LIBXML2] Do not rely on nan() when compiling with clang. CORE-11799 (#94) --- sdk/lib/3rdparty/libxml2/trionan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/lib/3rdparty/libxml2/trionan.c b/sdk/lib/3rdparty/libxml2/trionan.c index 6fbabb5dbd..71f1b1b9b3 100644 --- a/sdk/lib/3rdparty/libxml2/trionan.c +++ b/sdk/lib/3rdparty/libxml2/trionan.c @@ -327,7 +327,7 @@ trio_nan(TRIO_NOARGS) if (result == 0.0) { -#if defined(TRIO_COMPILER_SUPPORTS_C99) +#if defined(TRIO_COMPILER_SUPPORTS_C99) && !defined(__clang__) result = nan(""); #elif defined(NAN) && defined(__STDC_IEC_559__)
7 years, 1 month
1
0
0
0
[reactos] 01/01: [XDK/NTBASEDEF] Use __builtin_offsetof to define FIELD_OFFSET when compiling with clang-cl. CORE-11799 (#94)
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8ffffbb294027faf634d6…
commit 8ffffbb294027faf634d613b19501c7992808922 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Oct 31 13:54:41 2017 +0100 [XDK/NTBASEDEF] Use __builtin_offsetof to define FIELD_OFFSET when compiling with clang-cl. CORE-11799 (#94) --- sdk/include/xdk/ntbasedef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/xdk/ntbasedef.h b/sdk/include/xdk/ntbasedef.h index f41ea8f324..a1270d2428 100644 --- a/sdk/include/xdk/ntbasedef.h +++ b/sdk/include/xdk/ntbasedef.h @@ -104,7 +104,7 @@ #endif /* Returns the byte offset of the specified structure's member */ -#ifndef __GNUC__ +#if !defined(__GNUC__) && !defined(__clang__) #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field)) #else #define FIELD_OFFSET(Type, Field) ((LONG)__builtin_offsetof(Type, Field))
7 years, 1 month
1
0
0
0
[reactos] 01/01: [CRT/INTRIN] Use the gcc intrinsic equivalents when compiling with clang-cl and skip the ones that are already supported/built-in. CORE-11799 (#94)
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dde1b98a783b00cf0965a…
commit dde1b98a783b00cf0965a7d50ec818ee53504f46 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 30 22:51:00 2017 +0100 [CRT/INTRIN] Use the gcc intrinsic equivalents when compiling with clang-cl and skip the ones that are already supported/built-in. CORE-11799 (#94) --- sdk/include/crt/intrin.h | 2 +- sdk/include/crt/mingw32/intrin_x86.h | 70 +++++++++++++++++++++++++++++++----- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/sdk/include/crt/intrin.h b/sdk/include/crt/intrin.h index cc25401f8c..8dc1944fe7 100644 --- a/sdk/include/crt/intrin.h +++ b/sdk/include/crt/intrin.h @@ -1012,7 +1012,7 @@ long _InterlockedIncrement(_Interlocked_operand_ long volatile * _Addend); } #endif /* __cplusplus */ -#if defined(__GNUC__) && defined(_WIN32) // We can't use __MINGW32__ here +#if (defined(__GNUC__) || defined(__clang__)) && defined(_WIN32) // We can't use __MINGW32__ here # include "mingw32/intrin.h" #elif defined(_MSC_VER) # include "msc/intrin.h" diff --git a/sdk/include/crt/mingw32/intrin_x86.h b/sdk/include/crt/mingw32/intrin_x86.h index 1b3e8e0991..f474a818d5 100644 --- a/sdk/include/crt/mingw32/intrin_x86.h +++ b/sdk/include/crt/mingw32/intrin_x86.h @@ -89,6 +89,7 @@ __INTRIN_INLINE void* __cdecl memcpy(void* dest, const void* source, size_t num) /*** Memory barriers ***/ +#ifndef __clang__ __INTRIN_INLINE void _ReadWriteBarrier(void) { __asm__ __volatile__("" : : : "memory"); @@ -116,6 +117,7 @@ __INTRIN_INLINE void _mm_sfence(void) __asm__ __volatile__("sfence"); _WriteBarrier(); } +#endif /* !__clang__ */ #ifdef __x86_64__ __INTRIN_INLINE void __faststorefence(void) @@ -321,6 +323,8 @@ __INTRIN_INLINE long long _InterlockedIncrement64(volatile long long * lpAddend) #else /* (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 */ +#ifndef __clang__ + __INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * Destination, char Exchange, char Comperand) { char retval = Comperand; @@ -571,6 +575,8 @@ __INTRIN_INLINE short _InterlockedIncrement16(volatile short * lpAddend) return _InterlockedExchangeAdd16(lpAddend, 1) + 1; } +#endif /* !__clang__ */ + #if defined(__x86_64__) __INTRIN_INLINE long long _InterlockedDecrement64(volatile long long * lpAddend) { @@ -594,6 +600,7 @@ __INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * Des #else +#ifndef __clang__ __INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * Destination, long long Exchange, long long Comperand) { long long retval = Comperand; @@ -610,6 +617,7 @@ __INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * Des return retval; } +#endif /* !__clang__ */ #endif @@ -647,12 +655,14 @@ __INTRIN_INLINE unsigned char _interlockedbittestandreset64(volatile long long * } #endif +#ifndef __clang__ __INTRIN_INLINE unsigned char _interlockedbittestandset(volatile long * a, long b) { unsigned char retval; __asm__("lock; btsl %[b], %[a]; setc %b[retval]" : [retval] "=q" (retval), [a] "+m" (*a) : [b] "Ir" (b) : "memory"); return retval; } +#endif /* !__clang__ */ #if defined(__x86_64__) __INTRIN_INLINE unsigned char _interlockedbittestandset64(volatile long long * a, long long b) @@ -665,6 +675,7 @@ __INTRIN_INLINE unsigned char _interlockedbittestandset64(volatile long long * a /*** String operations ***/ +#ifndef __clang__ /* NOTE: we don't set a memory clobber in the __stosX functions because Visual C++ doesn't */ __INTRIN_INLINE void __stosb(unsigned char * Dest, unsigned char Data, size_t Count) { @@ -675,6 +686,7 @@ __INTRIN_INLINE void __stosb(unsigned char * Dest, unsigned char Data, size_t Co "[Dest]" (Dest), "a" (Data), "[Count]" (Count) ); } +#endif __INTRIN_INLINE void __stosw(unsigned short * Dest, unsigned short Data, size_t Count) { @@ -861,6 +873,8 @@ __INTRIN_INLINE void __writefsdword(unsigned long Offset, unsigned long Data) __asm__ __volatile__("movl %k[Data], %%fs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "ir" (Data) : "memory"); } +#ifndef __clang__ + __INTRIN_INLINE unsigned char __readfsbyte(unsigned long Offset) { unsigned char value; @@ -882,6 +896,8 @@ __INTRIN_INLINE unsigned long __readfsdword(unsigned long Offset) return value; } +#endif /* !__clang__ */ + __INTRIN_INLINE void __incfsbyte(unsigned long Offset) { __asm__ __volatile__("incb %%fs:%a[Offset]" : : [Offset] "ir" (Offset) : "memory"); @@ -927,6 +943,8 @@ __INTRIN_INLINE void __addfsdword(unsigned long Offset, unsigned long Data) /*** Bit manipulation ***/ +#ifndef __clang__ + __INTRIN_INLINE unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask) { __asm__("bsfl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask)); @@ -939,6 +957,8 @@ __INTRIN_INLINE unsigned char _BitScanReverse(unsigned long * Index, unsigned lo return Mask ? 1 : 0; } +#endif /* !__clang__ */ + /* NOTE: again, the bizarre implementation follows Visual C++ */ __INTRIN_INLINE unsigned char _bittest(const long * a, long b) { @@ -1058,6 +1078,8 @@ __INTRIN_INLINE unsigned char _bittestandcomplement64(long long * a, long long b #endif +#ifndef __clang__ + __INTRIN_INLINE unsigned char __cdecl _rotl8(unsigned char value, unsigned char shift) { unsigned char retval; @@ -1079,6 +1101,8 @@ __INTRIN_INLINE unsigned int __cdecl _rotl(unsigned int value, int shift) return retval; } +#endif /* !__clang__ */ + #ifdef __x86_64__ __INTRIN_INLINE unsigned long long _rotl64(unsigned long long value, int shift) { @@ -1086,13 +1110,17 @@ __INTRIN_INLINE unsigned long long _rotl64(unsigned long long value, int shift) __asm__("rolq %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift)); return retval; } -#else +#else /* __x86_64__ */ +#ifndef __clang__ __INTRIN_INLINE unsigned long long __cdecl _rotl64(unsigned long long value, int shift) { /* FIXME: this is probably not optimal */ return (value << shift) | (value >> (64 - shift)); } -#endif +#endif /* !__clang__ */ +#endif /* __x86_64__ */ + +#ifndef __clang__ __INTRIN_INLINE unsigned int __cdecl _rotr(unsigned int value, int shift) { @@ -1115,6 +1143,8 @@ __INTRIN_INLINE unsigned short __cdecl _rotr16(unsigned short value, unsigned ch return retval; } +#endif /* !__clang__ */ + #ifdef __x86_64__ __INTRIN_INLINE unsigned long long _rotr64(unsigned long long value, int shift) { @@ -1122,13 +1152,17 @@ __INTRIN_INLINE unsigned long long _rotr64(unsigned long long value, int shift) __asm__("rorq %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift)); return retval; } -#else +#else /* __x86_64__ */ +#ifndef __clang__ __INTRIN_INLINE unsigned long long __cdecl _rotr64(unsigned long long value, int shift) { /* FIXME: this is probably not optimal */ return (value >> shift) | (value << (64 - shift)); } -#endif +#endif /* !__clang__ */ +#endif /* __x86_64__ */ + +#ifndef __clang__ __INTRIN_INLINE unsigned long __cdecl _lrotl(unsigned long value, int shift) { @@ -1144,6 +1178,8 @@ __INTRIN_INLINE unsigned long __cdecl _lrotr(unsigned long value, int shift) return retval; } +#endif /* !__clang__ */ + /* NOTE: in __ll_lshift, __ll_rshift and __ull_rshift we use the "A" constraint (edx:eax) for the Mask argument, because it's the only way GCC @@ -1242,6 +1278,8 @@ __INTRIN_INLINE unsigned short __lzcnt16(unsigned short value) return __builtin_clz(value); } +#ifndef __clang__ + __INTRIN_INLINE unsigned int __popcnt(unsigned int value) { return __builtin_popcount(value); @@ -1252,6 +1290,8 @@ __INTRIN_INLINE unsigned short __popcnt16(unsigned short value) return __builtin_popcount(value); } +#endif /* !__clang__ */ + #ifdef __x86_64__ __INTRIN_INLINE unsigned long long __lzcnt64(unsigned long long value) { @@ -1266,6 +1306,8 @@ __INTRIN_INLINE unsigned long long __popcnt64(unsigned long long value) /*** 64-bit math ***/ +#ifndef __clang__ + __INTRIN_INLINE long long __emul(int a, int b) { long long retval; @@ -1280,6 +1322,8 @@ __INTRIN_INLINE unsigned long long __emulu(unsigned int a, unsigned int b) return retval; } +#endif /* !__clang__ */ + __INTRIN_INLINE long long __cdecl _abs64(long long value) { return (value >= 0) ? value : -value; @@ -1435,6 +1479,7 @@ __INTRIN_INLINE void __cpuidex(int CPUInfo[4], int InfoType, int ECXValue) __asm__ __volatile__("cpuid" : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : "a" (InfoType), "c" (ECXValue)); } +#ifndef __clang__ __INTRIN_INLINE unsigned long long __rdtsc(void) { #ifdef __x86_64__ @@ -1447,6 +1492,7 @@ __INTRIN_INLINE unsigned long long __rdtsc(void) return retval; #endif } +#endif /* !__clang__ */ __INTRIN_INLINE void __writeeflags(uintptr_t Value) { @@ -1462,14 +1508,12 @@ __INTRIN_INLINE uintptr_t __readeflags(void) /*** Interrupts ***/ -#ifdef __clang__ -#define __debugbreak() __asm__("int $3") -#else +#ifndef __clang__ + __INTRIN_INLINE void __cdecl __debugbreak(void) { __asm__("int $3"); } -#endif __INTRIN_INLINE void __ud2(void) { @@ -1481,6 +1525,8 @@ __INTRIN_INLINE void __int2c(void) __asm__("int $0x2c"); } +#endif /* !__clang__ */ + __INTRIN_INLINE void __cdecl _disable(void) { __asm__("cli" : : : "memory"); @@ -1496,12 +1542,14 @@ __INTRIN_INLINE void __halt(void) __asm__("hlt" : : : "memory"); } +#ifndef __clang__ __declspec(noreturn) __INTRIN_INLINE void __fastfail(unsigned int Code) { __asm__("int $0x29" : : "c"(Code) : "memory"); __builtin_unreachable(); } +#endif /*** Protected memory management ***/ @@ -1579,10 +1627,12 @@ __INTRIN_INLINE void __writecr4(unsigned int Data) __asm__("mov %[Data], %%cr4" : : [Data] "r" (Data) : "memory"); } +#ifndef __clang__ __INTRIN_INLINE void __writecr8(unsigned int Data) { __asm__("mov %[Data], %%cr8" : : [Data] "r" (Data) : "memory"); } +#endif __INTRIN_INLINE unsigned long __readcr0(void) { @@ -1612,12 +1662,14 @@ __INTRIN_INLINE unsigned long __readcr4(void) return value; } +#ifndef __clang__ __INTRIN_INLINE unsigned long __readcr8(void) { unsigned long value; __asm__ __volatile__("mov %%cr8, %[value]" : [value] "=r" (value)); return value; } +#endif #endif /* __x86_64__ */ @@ -1822,10 +1874,12 @@ __INTRIN_INLINE void _sgdt(void *Destination) /*** Misc operations ***/ +#ifndef __clang__ __INTRIN_INLINE void _mm_pause(void) { __asm__ __volatile__("pause" : : : "memory"); } +#endif __INTRIN_INLINE void __nop(void) {
7 years, 1 month
1
0
0
0
← Newer
1
2
3
4
...
28
Older →
Jump to page:
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
Results per page:
10
25
50
100
200