Skip to content

Commit 88a0d48

Browse files
committed
Win11下没有获取到任务栏通知区位置时,任务栏窗口距离右侧的位置从配置文件中的taskbar_right_space_win11读取
1 parent 4065508 commit 88a0d48

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

TrafficMonitor/CommonData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ struct TaskBarSettingData : public PublicSettingData
315315
void ValidWindowOffsetLeft();
316316
bool avoid_overlap_with_widgets{ false }; //避免与右侧小组件重叠
317317
int taskbar_left_space_win11{}; //Windows11下,任务栏小工具的宽度
318+
int taskbar_right_space_win11{}; //Windows11下,任务栏窗口距离任务栏右侧的宽度(仅当无法获取到任务栏TrayNotifyWnd窗口的位置时有效)
318319

319320
bool show_netspeed_figure{ false }; //是否显示网速占用图
320321
int netspeed_figure_max_value; //网速占用图的最大值

TrafficMonitor/TrafficMonitor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ void CTrafficMonitorApp::LoadConfig()
252252
m_taskbar_data.ValidWindowOffsetLeft();
253253
m_taskbar_data.avoid_overlap_with_widgets = ini.GetBool(_T("task_bar"), _T("avoid_overlap_with_widgets"), false);
254254
m_taskbar_data.taskbar_left_space_win11 = ini.GetInt(L"task_bar", L"taskbar_left_space_win11", 160);
255+
m_taskbar_data.taskbar_right_space_win11 = ini.GetInt(L"task_bar", L"taskbar_right_space_win11", 280);
255256

256257
if (m_win_version.IsWindows10OrLater()) //只有Win10才支持自动适应系统深色/浅色主题
257258
m_taskbar_data.auto_adapt_light_theme = ini.GetBool(L"task_bar", L"auto_adapt_light_theme", false);
@@ -416,6 +417,7 @@ void CTrafficMonitorApp::SaveConfig()
416417
ini.WriteInt(L"task_bar", L"window_offset_left", m_taskbar_data.window_offset_left);
417418
ini.WriteBool(L"task_bar", L"avoid_overlap_with_widgets", m_taskbar_data.avoid_overlap_with_widgets);
418419
ini.WriteInt(L"task_bar", L"taskbar_left_space_win11", m_taskbar_data.taskbar_left_space_win11);
420+
ini.WriteInt(L"task_bar", L"taskbar_right_space_win11", m_taskbar_data.taskbar_right_space_win11);
419421

420422
ini.WriteBool(L"task_bar", L"auto_adapt_light_theme", m_taskbar_data.auto_adapt_light_theme);
421423
ini.WriteInt(L"task_bar", L"dark_default_style", m_taskbar_data.dark_default_style);

TrafficMonitor/Win11TaskbarDlg.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ void CWin11TaskbarDlg::AdjustTaskbarWndPos(bool force_adjust)
2929
//{
3030
//通知区窗口的水平位置
3131
int notify_x_pos = m_rcNotify.left;
32-
//Win11副屏没有通知区窗口,这里使用固定的值
33-
if (m_is_secondary_display)
34-
notify_x_pos = m_rcTaskbar.Width() - DPI(88);
35-
//如果不是副屏,但是没有获取到通知区域的位置,也使用一个固定值
36-
else if (notify_x_pos == 0)
37-
notify_x_pos = m_rcTaskbar.Width() - DPI(220);
32+
//没有获取到通知区位置的情况
33+
if (notify_x_pos == 0)
34+
{
35+
//Win11副屏没有通知区窗口,这里使用固定的值(88像素的系统时间区域)
36+
if (m_is_secondary_display)
37+
notify_x_pos = m_rcTaskbar.Width() - DPI(88);
38+
//如果不是副屏,但是仍然没有获取到通知区域的位置,使用配置文件中taskbar_right_space_win11指定的值
39+
else
40+
notify_x_pos = m_rcTaskbar.Width() - DPI(theApp.m_taskbar_data.taskbar_right_space_win11);
41+
}
3842
//如果显示了小组件,并且任务栏靠左显示,则留出小组件的位置
3943
if (theApp.m_taskbar_data.avoid_overlap_with_widgets && CWindowsSettingHelper::IsTaskbarWidgetsBtnShown() && !CWindowsSettingHelper::IsTaskbarCenterAlign())
4044
m_rect.MoveToX(notify_x_pos - m_rect.Width() + 2 - DPI(theApp.m_taskbar_data.taskbar_left_space_win11));

0 commit comments

Comments
 (0)