eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
112 stars 135 forks source link

The 'Search With Google' action in macOS' context menu doesn't respect the 'Default web browser' setting #1215

Open n5a5 opened 4 months ago

n5a5 commented 4 months ago

Describe the bug On macOS, the 'Search With Google' action in the context menu opens Google search in Safari even if another browser is set as default.

To Reproduce

  1. On macOS, set a non-safari browser as default (I used Brave)
  2. In Eclipse IDE for RCP and RAP devs 2024-03, click Eclipse -> About Eclipse -> Installation Details -> Configuration.
  3. Select any text, invoke the context menu, and click 'Search With Google'.
  4. The selected text is searched in Safari.

Expected behavior The text should be searched in the default browser.

Environment:

  1. Select the platform(s) on which the behavior is seen:

      • [ ] All OS
      • [ ] Windows
      • [ ] Linux
      • [x] macOS
  2. Additional OS info (e.g. OS version, Linux Desktop, etc)

macOS 14.4.1.

  1. JRE/JDK version 17.0.6, 17.0.10+7

Workaround (or) Additional context To be fair, native macOS applications such as TextEdit and Mail do not respect this setting either. However, all the third-party apps I tried (Slack, IntelliJ IDEA, Notion) invoke the default browser, and it seems like the correct behavior.

Originally reported here: https://github.com/dbeaver/dbeaver/issues/26611.

Phillipus commented 4 months ago

I doubt this can be changed. SWT Components on Mac such as the Text control and the Browser integrate as native Mac components, and selecting "Search With Google" on native Mac components will open it in Safari in spite of setting another Browser as default.

JTMosaic commented 4 months ago

Highlighting a word in Slack on MacOS and selecting "Search with Google..." opens in the default browser. So, this should be possible, no?

Phillipus commented 4 months ago

Highlighting a word in Slack on MacOS and selecting "Search with Google..." opens in the default browser. So, this should be possible, no?

It seems that this is an integrated service on Mac components. See this and this. The conclusion is that the "Search with Google" service is provided by Safari, and is not meant to work with other browsers.

JTMosaic commented 4 months ago

Thanks, @Phillipus! The second link resolves the issue. Turning off the built-in "Search with Google" service allows Eclipse to use the default browser.

Phillipus commented 4 months ago

Turning off the built-in "Search with Google" service allows Eclipse to use the default browser.

@JTMosaic How did you do that? Disabling it in the Services dialog has no effect for me (Sonoma).

JTMosaic commented 4 months ago

I just noticed something. There are two different context-based searches in DBeaver (based on Eclipse)

There is a one in free-text, such as a script, that reads: image

and one that appears in the results pane that reads: image

The latter appears to use SWT and only opens in Safari while the former, as the tooltip says, opens in the default browser.

This would seem to indicate that it is possible for Eclipse to use the default browser but it isn't implemented consistently?

Phillipus commented 4 months ago

This would seem to indicate that it is possible for Eclipse to use the default browser but it isn't implemented consistently?

I would think that DBeaver added that option as a custom menu item.

JTMosaic commented 4 months ago

So you're saying that vanilla Eclipse doesn't have the "Search selected text with Google" option? Then this may be a DBeaver issue and not an Eclipse issue, per se. Assuming the results grid isn't a SWT component in which case this may be unsolvable

Phillipus commented 4 months ago

I guess it depends what the DBeaver control is. If it's a non-native component such as StyledText, or they've defined their own context menu, then the native Mac services menu won't show. If the control is a SWT Text control, for example, it will. I don't think it's possible for SWT to hook into the native services menu.

At any rate the "Search with Google" menu item is provided by Safari as a "service" so it can't be changed.

n5a5 commented 4 months ago

I would think that DBeaver added that option as a custom menu item. So you're saying that vanilla Eclipse doesn't have the "Search selected text with Google" option?

That's correct. It's a custom menu item added by DBeaver.

Thank you for clarifications @Phillipus. Now we have a couple of questions left: a) How does Slack respect the default browser setting, and b) Do we want the Eclipse Platform to follow Slack's route?

In any case, I find this a pretty minor thing, and I would rather see SWT developers spending time on something more substantial. What say you @JTMosaic?

Phillipus commented 4 months ago

Thank you for clarifications @Phillipus. Now we have a couple of questions left: a) How does Slack respect the default browser setting

I don't use Slack so I don't know. Is the context menu there actually Mac's native Service menu, or perhaps they added their own service menu item?

and b) Do we want the Eclipse Platform to follow Slack's route?

For the reasons above this will be unlikely. The "Search with Google" menu item is provided by Safari as a "service". I doubt anyone will spend any time on this (but who knows?). ;-)

JTMosaic commented 4 months ago

@n5a5 I agree. I see this as a DBeaver issue more than an Eclipse issue but I think the discussion was helpful for all involved.