Skip to content

Commit

Permalink
Open tabs in background by default
Browse files Browse the repository at this point in the history
This change restores the behaviour of opening new tabs in the
background by default.

This functionality had been changed when the new tabs bar was
implemented. The reason was that opening a tab in the background
leaves it in an uninitialized state until the user clicks on
that tab, and this made it difficult to keep the tabs bar
updated in real time.

We will use the domain name as the title of background tabs
until the user clicks on them (this was empty previously).
  • Loading branch information
felipeerias committed Feb 4, 2025
1 parent 1e871dd commit 07821ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ private Session addSession(@NonNull Session aSession) {
mStoreSubscription.resume();
}

for (SessionChangeListener listener : mSessionChangeListeners) {
listener.onSessionAdded(aSession);
}

return aSession;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.igalia.wolvic.browser.engine.SessionStore;
import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.ui.widgets.WindowWidget;
import com.igalia.wolvic.utils.StringUtils;
import com.igalia.wolvic.utils.UrlUtils;

import java.util.Objects;
Expand Down Expand Up @@ -99,8 +100,14 @@ public void attachToSession(@Nullable Session aSession) {
mSession.addNavigationListener(this);
mSession.addSessionChangeListener(this);

mTitle.setText(mSession.getCurrentTitle());
mSubtitle.setText(UrlUtils.stripProtocol(mSession.getCurrentUri()));
String title = mSession.getCurrentTitle();
String uri = mSession.getCurrentUri();
if (StringUtils.isEmpty(title)) {
title = UrlUtils.stripCommonSubdomains(UrlUtils.getHost(uri));
}
mTitle.setText(title);
mSubtitle.setText(UrlUtils.stripProtocol(uri));

SessionStore.get().getBrowserIcons().loadIntoView(
mFavicon, mSession.getCurrentUri(), IconRequest.Size.DEFAULT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void setContextElement(WSession.ContentDelegate.ContextElement aContextEl
// Open link in a new tab
mItems.add(new MenuWidget.MenuItem(getContext().getString(R.string.context_menu_open_link_new_tab_1), 0, () -> {
if (!StringUtils.isEmpty(aContextElement.linkUri)) {
widgetManager.openNewTabForeground(aContextElement.linkUri);
widgetManager.openNewTab(aContextElement.linkUri);
TelemetryService.Tabs.openedCounter(TelemetryService.Tabs.TabSource.CONTEXT_MENU);
}
onDismiss();
Expand Down

0 comments on commit 07821ef

Please sign in to comment.