Skip to content

Commit 2de5181

Browse files
committed
Update UI.cpp
1 parent 69b86f9 commit 2de5181

1 file changed

Lines changed: 65 additions & 19 deletions

File tree

src/UI.cpp

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,12 @@ void UI::HandleDrmLoading(uint64_t tab_id, bool is_loading)
783783
if (is_loading)
784784
{
785785
// Show the DRM tab now that it's actually loading, but only if no overlays are open
786+
// Note: suggestions_overlay_ is excluded because it doesn't hide the DRM tab
786787
auto drm_it = drm_tabs_.find(tab_id);
787788
if (drm_it != drm_tabs_.end() && drm_it->second)
788789
{
789790
// Only show if this is the active tab and no overlays are covering the content
790-
if (tab_id == active_tab_id_ && !menu_overlay_ && !downloads_overlay_ && !context_menu_overlay_ && !suggestions_overlay_)
791+
if (tab_id == active_tab_id_ && !menu_overlay_ && !downloads_overlay_ && !context_menu_overlay_)
791792
drm_it->second->Show();
792793
}
793794

@@ -1633,11 +1634,20 @@ void UI::OnAddressBarNavigate(const JSObject &obj, const JSArgs &args)
16331634
// Record immediately so History UI updates quickly (dedup inside RecordHistory)
16341635
RecordHistory(url, String(""));
16351636

1636-
// Check if this is a DRM site
1637+
// If currently on a DRM site, always close it and navigate in standard tab
1638+
// This simplifies URL changes on DRM sites
1639+
auto drm_it = drm_tabs_.find(active_tab_id_);
1640+
if (drm_it != drm_tabs_.end() && drm_it->second)
1641+
{
1642+
// Close the DRM tab first
1643+
HideDrmTab(active_tab_id_);
1644+
}
1645+
1646+
// Check if the new URL is a DRM site
16371647
if (MaybeOpenDrmTab(active_tab_id_, url_utf8, true))
16381648
return;
16391649

1640-
// Not a DRM site - close any existing DRM tab and show Ultralight tab
1650+
// Not a DRM site - ensure Ultralight tab is shown and navigate
16411651
HideAllDrmTabs();
16421652
if (!tabs_.empty())
16431653
{
@@ -2443,7 +2453,16 @@ void UI::ShowDownloadsOverlay()
24432453
// Hide active DRM WebView2 tab so overlay appears on top
24442454
auto drm_it = drm_tabs_.find(active_tab_id_);
24452455
if (drm_it != drm_tabs_.end() && drm_it->second)
2456+
{
24462457
drm_it->second->Hide();
2458+
// Show Ultralight tab with solid background to cover any residual rendering
2459+
auto tab_it = tabs_.find(active_tab_id_);
2460+
if (tab_it != tabs_.end() && tab_it->second)
2461+
{
2462+
tab_it->second->view()->LoadHTML(R"(<html><head><style>html,body{margin:0;padding:0;background:#1a1a2e;width:100%;height:100%}</style></head><body></body></html>)");
2463+
tab_it->second->Show(); // Show it so the solid background covers everything
2464+
}
2465+
}
24472466

24482467
ultralight::ViewConfig cfg;
24492468
cfg.is_transparent = true;
@@ -2493,6 +2512,7 @@ void UI::HideDownloadsOverlay()
24932512
downloads_overlay_ = nullptr;
24942513

24952514
// Restore active DRM WebView2 tab if no other overlays are open
2515+
// Note: suggestions_overlay_ is excluded because it doesn't hide the DRM tab
24962516
if (!menu_overlay_ && !context_menu_overlay_)
24972517
{
24982518
auto drm_it = drm_tabs_.find(active_tab_id_);
@@ -3289,7 +3309,16 @@ void UI::ShowMenuOverlay()
32893309
// Hide active DRM WebView2 tab so overlay appears on top
32903310
auto drm_it = drm_tabs_.find(active_tab_id_);
32913311
if (drm_it != drm_tabs_.end() && drm_it->second)
3312+
{
32923313
drm_it->second->Hide();
3314+
// Show Ultralight tab with solid background to cover any residual rendering
3315+
auto tab_it = tabs_.find(active_tab_id_);
3316+
if (tab_it != tabs_.end() && tab_it->second)
3317+
{
3318+
tab_it->second->view()->LoadHTML(R"(<html><head><style>html,body{margin:0;padding:0;background:#1a1a2e;width:100%;height:100%}</style></head><body></body></html>)");
3319+
tab_it->second->Show(); // Show it so the solid background covers everything
3320+
}
3321+
}
32933322

32943323
// Create a transparent View so only the dropdown is visible over content
32953324
ultralight::ViewConfig cfg;
@@ -3324,6 +3353,7 @@ void UI::HideMenuOverlay()
33243353
menu_overlay_ = nullptr;
33253354

33263355
// Restore active DRM WebView2 tab if no other overlays are open
3356+
// Note: suggestions_overlay_ is excluded because it doesn't hide the DRM tab
33273357
if (!downloads_overlay_ && !context_menu_overlay_)
33283358
{
33293359
auto drm_it = drm_tabs_.find(active_tab_id_);
@@ -3334,16 +3364,32 @@ void UI::HideMenuOverlay()
33343364

33353365
void UI::ShowContextMenuOverlay(int x, int y, const ultralight::String &json_info)
33363366
{
3337-
// Recreate view each time for simplicity
3367+
// Recreate view each time for simplicity - but don't restore DRM tab during recreation
33383368
if (context_menu_overlay_)
33393369
{
3340-
HideContextMenuOverlay();
3370+
// Just destroy the old overlay without restoring DRM tab
3371+
context_menu_overlay_->Hide();
3372+
context_menu_overlay_->Unfocus();
3373+
if (overlay_)
3374+
overlay_->Focus();
3375+
context_menu_overlay_->view()->set_load_listener(nullptr);
3376+
context_menu_overlay_ = nullptr;
3377+
pending_ctx_info_json_ = "";
33413378
}
33423379

33433380
// Hide active DRM WebView2 tab so overlay appears on top
33443381
auto drm_it = drm_tabs_.find(active_tab_id_);
33453382
if (drm_it != drm_tabs_.end() && drm_it->second)
3383+
{
33463384
drm_it->second->Hide();
3385+
// Show Ultralight tab with solid background to cover any residual rendering
3386+
auto tab_it = tabs_.find(active_tab_id_);
3387+
if (tab_it != tabs_.end() && tab_it->second)
3388+
{
3389+
tab_it->second->view()->LoadHTML(R"(<html><head><style>html,body{margin:0;padding:0;background:#1a1a2e;width:100%;height:100%}</style></head><body></body></html>)");
3390+
tab_it->second->Show(); // Show it so the solid background covers everything
3391+
}
3392+
}
33473393

33483394
ultralight::ViewConfig cfg;
33493395
cfg.is_transparent = true;
@@ -3379,6 +3425,7 @@ void UI::HideContextMenuOverlay()
33793425
pending_ctx_info_json_ = "";
33803426

33813427
// Restore active DRM WebView2 tab if no other overlays are open
3428+
// Note: suggestions_overlay_ is excluded because it doesn't hide the DRM tab
33823429
if (!menu_overlay_ && !downloads_overlay_)
33833430
{
33843431
auto drm_it = drm_tabs_.find(active_tab_id_);
@@ -4392,14 +4439,20 @@ void UI::LoadSuggestionsFaviconsFlag()
43924439

43934440
void UI::ShowSuggestionsOverlay(int x, int y, int width, const ultralight::String &json_items)
43944441
{
4395-
// Recreate each time for simplicity
4442+
// Recreate each time for simplicity - but don't restore DRM tab during recreation
43964443
if (suggestions_overlay_)
4397-
HideSuggestionsOverlay();
4444+
{
4445+
// Just destroy the old overlay without restoring DRM tab
4446+
suggestions_overlay_->Hide();
4447+
suggestions_overlay_->Unfocus();
4448+
suggestions_overlay_->view()->set_load_listener(nullptr);
4449+
suggestions_overlay_ = nullptr;
4450+
pending_sugg_json_ = "";
4451+
}
43984452

4399-
// Hide active DRM WebView2 tab so overlay appears on top
4400-
auto drm_it = drm_tabs_.find(active_tab_id_);
4401-
if (drm_it != drm_tabs_.end() && drm_it->second)
4402-
drm_it->second->Hide();
4453+
// NOTE: Don't hide DRM tab for suggestions - it's a small dropdown that appears
4454+
// in the URL bar area, not covering the main content. Hiding/showing DRM tab
4455+
// causes flickering and input issues.
44034456

44044457
ultralight::ViewConfig cfg;
44054458
cfg.is_transparent = true;
@@ -4430,14 +4483,7 @@ void UI::HideSuggestionsOverlay()
44304483
suggestions_overlay_->view()->set_load_listener(nullptr);
44314484
suggestions_overlay_ = nullptr;
44324485
pending_sugg_json_ = "";
4433-
4434-
// Restore active DRM WebView2 tab if no other overlays are open
4435-
if (!menu_overlay_ && !downloads_overlay_ && !context_menu_overlay_)
4436-
{
4437-
auto drm_it = drm_tabs_.find(active_tab_id_);
4438-
if (drm_it != drm_tabs_.end() && drm_it->second)
4439-
drm_it->second->Show();
4440-
}
4486+
// NOTE: Don't restore DRM tab here - suggestions don't hide it in the first place
44414487
}
44424488

44434489
void UI::OnOpenSuggestionsOverlay(const JSObject &obj, const JSArgs &args)

0 commit comments

Comments
 (0)