Skip to content

Commit e1cf3b7

Browse files
committed
Clean up #if BLOCKs
Resolve most #if/#endif blocks for either support or not. Remaining: - Mica on Win11 - Improve Accessibility
1 parent dd6a99c commit e1cf3b7

File tree

2 files changed

+13
-102
lines changed

2 files changed

+13
-102
lines changed

Samples/Islands/DrawingIsland/DrawingIslandComponents/DrawingIsland.cpp

Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,6 @@ namespace winrt::DrawingIslandComponents::implementation
4747
// Just adding EnqueueFromBackgroundThread method for testing.
4848
EnqueueFromBackgroundThread();
4949

50-
#if FALSE
51-
// Get notifications for island disconnection.
52-
(void)m_island.Connected(
53-
[&](auto&& ...)
54-
{
55-
return Island_OnConnected();
56-
});
57-
58-
(void)m_island.Disconnected(
59-
[&](auto&& ...)
60-
{
61-
return Island_OnDisconnected();
62-
});
63-
#endif
64-
6550
(void)m_island.Closed(
6651
[&]()
6752
{
@@ -74,13 +59,8 @@ namespace winrt::DrawingIslandComponents::implementation
7459

7560
DrawingIsland::~DrawingIsland()
7661
{
77-
#if FALSE
78-
m_siteBridge = nullptr;
79-
#endif
80-
#if TRUE
8162
m_fragmentRoot = nullptr;
8263
m_fragmentFactory = nullptr;
83-
#endif
8464
m_compositor = nullptr;
8565
}
8666

@@ -96,6 +76,7 @@ namespace winrt::DrawingIslandComponents::implementation
9676
m_backgroundBrushC = nullptr;
9777
m_backgroundVisual = nullptr;
9878

79+
// TODO: Enable Mica on Win 11
9980
#if FALSE
10081
// Destroy SystemBackdropController objects.
10182
if (m_backdropController != nullptr)
@@ -149,6 +130,7 @@ namespace winrt::DrawingIslandComponents::implementation
149130
updateThread1.join();
150131
}
151132

133+
152134
IFACEMETHODIMP
153135
DrawingIsland::OnDirectMessage(
154136
IInputPreTranslateKeyboardSourceInterop* /*source*/,
@@ -175,6 +157,7 @@ namespace winrt::DrawingIslandComponents::implementation
175157
return S_OK;
176158
}
177159

160+
178161
IFACEMETHODIMP
179162
DrawingIsland::OnTreeMessage(
180163
IInputPreTranslateKeyboardSourceInterop* /*source*/,
@@ -240,6 +223,7 @@ namespace winrt::DrawingIslandComponents::implementation
240223
}
241224
}
242225

226+
243227
void
244228
DrawingIsland::Input_Initialize()
245229
{
@@ -445,7 +429,6 @@ namespace winrt::DrawingIslandComponents::implementation
445429
}
446430

447431

448-
#if TRUE
449432
void
450433
DrawingIsland::Accessibility_Initialize()
451434
{
@@ -454,25 +437,6 @@ namespace winrt::DrawingIslandComponents::implementation
454437

455438
m_fragmentFactory = winrt::make_self<NodeSimpleFragmentFactory>();
456439

457-
#if FALSE
458-
if (m_crossProcUIA)
459-
{
460-
m_fragmentRoot->SetName(L"CrossProc Island");
461-
}
462-
else if (m_siteBridge != nullptr)
463-
{
464-
auto desktopChildBridge = m_siteBridge.try_as<winrt::IDesktopChildSiteBridge>();
465-
if (desktopChildBridge != nullptr)
466-
{
467-
m_fragmentRoot->SetName(L"Child Island");
468-
}
469-
else
470-
{
471-
m_fragmentRoot->SetName(L"Popup Island");
472-
}
473-
}
474-
#endif
475-
476440
(void)m_island.AutomationProviderRequested({ this, &DrawingIsland::Accessibility_OnAutomationProviderRequested });
477441
}
478442

@@ -488,7 +452,6 @@ namespace winrt::DrawingIslandComponents::implementation
488452

489453
args.Handled(true);
490454
}
491-
#endif
492455

493456

494457
winrt::Visual
@@ -514,8 +477,6 @@ namespace winrt::DrawingIslandComponents::implementation
514477
}
515478

516479

517-
// Continue converting to inspect CTRL key.
518-
519480
void
520481
DrawingIsland::Input_OnLeftButtonPressed(
521482
const winrt::PointerEventArgs& args)
@@ -533,12 +494,14 @@ namespace winrt::DrawingIslandComponents::implementation
533494
}
534495
}
535496

497+
536498
void
537499
DrawingIsland::Input_OnPointerReleased()
538500
{
539501
m_selectedVisual = nullptr;
540502
}
541503

504+
542505
void
543506
DrawingIsland::LeftClickAndRelease(
544507
const float2 currentPoint)
@@ -547,6 +510,7 @@ namespace winrt::DrawingIslandComponents::implementation
547510
Input_OnPointerReleased();
548511
}
549512

513+
550514
void
551515
DrawingIsland::RightClickAndRelease(
552516
const float2 currentPoint)
@@ -555,6 +519,7 @@ namespace winrt::DrawingIslandComponents::implementation
555519
Input_OnPointerReleased();
556520
}
557521

522+
558523
void
559524
DrawingIsland::OnLeftClick(
560525
const float2 point,
@@ -578,17 +543,6 @@ namespace winrt::DrawingIslandComponents::implementation
578543
{
579544
Output_AddVisual(point, controlPressed);
580545
}
581-
582-
#if FALSE
583-
// Only transfer focus when we are hosted inside a DesktopChildSiteBridge. When we are
584-
// hosted inside a PopupWindowSiteBridge, we expect to control focus and activaton by
585-
// setting InputPointerSource->ActivationBehavior.
586-
auto desktopChildBridge = m_siteBridge.try_as<winrt::IDesktopChildSiteBridge>();
587-
if (desktopChildBridge != nullptr)
588-
{
589-
m_focusController.TrySetFocus();
590-
}
591-
#endif
592546
}
593547

594548

@@ -633,13 +587,6 @@ namespace winrt::DrawingIslandComponents::implementation
633587
Output_UpdateCurrentColorVisual();
634588
}
635589

636-
#if FALSE
637-
void
638-
DrawingIsland::Island_OnConnected()
639-
{
640-
SetLayoutDirectionForVisuals();
641-
}
642-
#endif
643590

644591
void
645592
DrawingIsland::SetLayoutDirectionForVisuals()
@@ -660,20 +607,14 @@ namespace winrt::DrawingIslandComponents::implementation
660607
m_prevLayout = m_island.LayoutDirection();
661608
}
662609

663-
#if FALSE
664-
void
665-
DrawingIsland::Island_OnDisconnected()
666-
{
667-
668-
}
669-
#endif
670610

671611
void
672612
DrawingIsland::Island_OnClosed()
673613
{
674614

675615
}
676616

617+
677618
void
678619
DrawingIsland::Output_Initialize()
679620
{
@@ -720,15 +661,12 @@ namespace winrt::DrawingIslandComponents::implementation
720661
m_offset.x = -BlockSize / 2.0f;
721662
m_offset.y = -BlockSize / 2.0f;
722663

723-
#if TRUE
724664
CreateUIAProviderForVisual();
725665

726666
Accessibility_UpdateScreenCoordinates(m_selectedVisual);
727-
#endif
728667
}
729668

730669

731-
#if TRUE
732670
void
733671
DrawingIsland::Accessibility_UpdateScreenCoordinates(
734672
const winrt::Visual & visual)
@@ -769,7 +707,6 @@ namespace winrt::DrawingIslandComponents::implementation
769707
// Finally set up parent chain
770708
fragment->SetParent(m_fragmentRoot);
771709
}
772-
#endif
773710

774711

775712
void
@@ -781,6 +718,7 @@ namespace winrt::DrawingIslandComponents::implementation
781718
}
782719

783720

721+
// TODO: Enable Mica on Win 11
784722
#if FALSE
785723
void
786724
DrawingIsland::SystemBackdrop_Initialize()

Samples/Islands/DrawingIsland/DrawingIslandComponents/DrawingIsland.h

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ namespace winrt::DrawingIslandComponents::implementation
5252
void RightClickAndRelease(
5353
const float2 currentPoint);
5454

55-
#if FALSE
56-
void SetHostBridge(
57-
const winrt::IContentSiteBridge& bridge)
58-
{
59-
m_siteBridge = bridge;
60-
61-
Accessibility_Initialize();
62-
}
63-
#endif
64-
6555
void SetBackroundOpacity(float backgroundOpacity)
6656
{
6757
m_backgroundOpacity = backgroundOpacity;
@@ -93,7 +83,6 @@ namespace winrt::DrawingIslandComponents::implementation
9383
_Inout_ bool* handled);
9484

9585
private:
96-
#if TRUE
9786
void Accessibility_Initialize();
9887

9988
void Accessibility_OnAutomationProviderRequested(
@@ -104,7 +93,6 @@ namespace winrt::DrawingIslandComponents::implementation
10493
const winrt::Visual& visual);
10594

10695
void CreateUIAProviderForVisual();
107-
#endif
10896

10997
void EnqueueFromBackgroundThread();
11098

@@ -134,16 +122,8 @@ namespace winrt::DrawingIslandComponents::implementation
134122

135123
void Island_OnStateChanged();
136124

137-
#if FALSE
138-
void Island_OnConnected();
139-
140-
void Island_OnDisconnected();
141-
#endif
142-
143125
void Island_OnClosed();
144126

145-
void LightDismiss_Initialize();
146-
147127
void OnLeftClick(
148128
const float2 point,
149129
bool controlPressed);
@@ -159,6 +139,7 @@ namespace winrt::DrawingIslandComponents::implementation
159139

160140
void Output_UpdateCurrentColorVisual();
161141

142+
// TODO: Enable Mica on Win 11
162143
#if FALSE
163144
void SystemBackdrop_Initialize();
164145
#endif
@@ -203,10 +184,8 @@ namespace winrt::DrawingIslandComponents::implementation
203184
L"LightSkyBlue",
204185
};
205186

206-
#if TRUE
207187
winrt::com_ptr<NodeSimpleFragmentFactory> m_fragmentFactory{ nullptr };
208188
winrt::com_ptr<IslandFragmentRoot> m_fragmentRoot{ nullptr };
209-
#endif
210189

211190
winrt::Compositor m_compositor{ nullptr };
212191
winrt::ContentIsland m_island{ nullptr };
@@ -223,6 +202,8 @@ namespace winrt::DrawingIslandComponents::implementation
223202
winrt::SpriteVisual m_backgroundVisual{ nullptr };
224203
winrt::RectangleClip m_backgroundClip{ nullptr };
225204
winrt::RectangleClip m_backdropClip{ nullptr };
205+
206+
// TODO: Enable Mica on Win 11
226207
#if FALSE
227208
winrt::ContentExternalBackdropLink m_backdropLink{ nullptr };
228209
winrt::ICompositionSupportsSystemBackdrop m_backdropTarget{ nullptr };
@@ -239,20 +220,12 @@ namespace winrt::DrawingIslandComponents::implementation
239220
winrt::CompositionColorBrush m_colorBrushes[_countof(s_colors)]{ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
240221
winrt::CompositionColorBrush m_halfTransparentColorBrushes[_countof(s_colors)]{ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
241222

242-
#if FALSE
243-
// Popups
244-
// https://task.ms/32440118: Add ContentIsland.SiteBridge to avoid this workaround
245-
winrt::IContentSiteBridge m_siteBridge{ nullptr };
246-
#endif
247-
248223
boolean m_ignoreLeftButtonPressed = false;
249224
boolean m_useSystemBackdrop = false;
250225
float m_prevRasterizationScale = 0;
251226
winrt::ContentLayoutDirection m_prevLayout = winrt::ContentLayoutDirection::LeftToRight;
252227

253-
#if TRUE
254228
std::map<winrt::Visual, winrt::com_ptr<NodeSimpleFragment>> m_visualToFragmentMap;
255-
#endif
256229
};
257230
}
258231

0 commit comments

Comments
 (0)