Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for window transparency #949

Merged
merged 11 commits into from
Jan 12, 2015
Merged

Add support for window transparency #949

merged 11 commits into from
Jan 12, 2015

Conversation

zcbenz
Copy link
Member

@zcbenz zcbenz commented Dec 23, 2014

  • Patch chromium to support window transparency
    • Mac
    • Windows
    • Linux
  • Implement on atom-shell side
    • Mac
    • Windows
    • Linux
  • Window shadow on Mac
  • Click through transparent parts of window
  • Resizable transparent window
  • Set window shape

Patches in libchromiumcontent:
https://github.com/brightray/libchromiumcontent/blob/atom/patches/use_transparent_window.patch
https://github.com/brightray/libchromiumcontent/blob/atom/patches/render_widget_host_view_mac.patch

Fixes #381.

zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 23, 2014
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 23, 2014
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949
@zcbenz
Copy link
Member Author

zcbenz commented Dec 23, 2014

The native window shadow does not show for transparent window on Mac when the window is created, the shadow only shows after the focus is switched to/from other windows. This is strange, but since we can draw shadows directly in HTML, we just disable native window shadow for now.

@zcbenz
Copy link
Member Author

zcbenz commented Dec 23, 2014

Another problem with transparent window is that you can not click through the transparent areas in the window, because the web page's underlying view still covers the whole window. One solution is to calculate whether the point is transparent when user clicks on the page, and then decide whether to ignore the mouse event, but this solution is quite expensive and needs some more patches in Chromium.

In Chromium they also have support for transparent background in web pages (but without support on Mac), and they also have the same problem with us. What they did to solve it is to provide a API to specify the shape of window, so instead of calculating which area can be clicked through, they just let the users decide. I think we should take this approach too.

@zcbenz
Copy link
Member Author

zcbenz commented Dec 23, 2014

One limitation of transparent window is you can not apply blur effects on background, the blur effect is only calculated on HTML elements, so you can not implement Yosemite style toolbar with pure HTML. I am not sure whether this is a operating system limitation or a Chrome bug.

An example without blur:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <style type="text/css" media="screen">
    .back {
      -webkit-app-region: drag;
      width: 400px;
      height: 80px;
      text-align: center;
      background-color: #555;
      border-radius: 10px;
      box-shadow: 0px 2px 8px 0px rgba(0,0,0,0.7);
      -webkit-filter: blur(4px);
      opacity: 0.4;
    }
    .title {
      float: left;
      margin: 30px 0 0 170px;
    }
  </style>
</head>
<body>
<div class="title">Atom Shell</div>
<div class="back"></div>
</body>
</html>

screen shot 2014-12-23 at 1 49 13 pm

After we add following style rule:

    .back {
      -webkit-filter: blur(4px);
    }

screen shot 2014-12-23 at 1 49 27 pm

@zcbenz
Copy link
Member Author

zcbenz commented Dec 24, 2014

I have made transparent window work on Windows and Linux, and we need no patch to libchromiumcontent, which is quite good.

But to use transparent window on Linux we have to disable GPU acceleration, and users must put --enable-transparent-visuals --disable-gpu in the command line. This bug is tracked at an upstream bug.

@anaisbetts
Copy link
Contributor

😍

@lynchpin4
Copy link

your the man zcbenz ! +1

@zcbenz
Copy link
Member Author

zcbenz commented Dec 31, 2014

Enabling clicking through the transparent areas is possible, but it requires disabling GPU acceleration on all platforms, which doesn't seems a solution to me. So I'll choose to add API to set window shape.

@zcbenz
Copy link
Member Author

zcbenz commented Jan 2, 2015

Clipping a window on Mac into a custom shape seems quite difficult in Chromium, traditional ways only work if we have GPU acceleration turned off, and I'm not familiar with how GPU acceleration works in Chromium. In upstream there is an issue to implement window shape API on Mac, I think we should wait for it instead of spending too much time hacking on it.

@anaisbetts
Copy link
Contributor

@zcbenz Can you keep this PR open while we wait? We're using this version at the moment and since we don't care too much about clickthrough it works for us quite well

@zcbenz
Copy link
Member Author

zcbenz commented Jan 2, 2015

@paulcbetts Sure, feedbacks are welcomed!

@anaisbetts
Copy link
Contributor

@zcbenz So far, everything is 💎

zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Jan 7, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Jan 7, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Jan 9, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Jan 9, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Sep 7, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Sep 26, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Sep 30, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995

5. Disable beeps when pressing certain keys.
electron/electron#2617
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Oct 14, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Oct 27, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
clebeaupin pushed a commit to clebeaupin/libchromiumcontent that referenced this pull request Nov 14, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 7, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 7, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 7, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 8, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 8, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 8, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Dec 8, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Oct 23, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Nov 2, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Nov 12, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Nov 18, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Nov 22, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Dec 4, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Dec 8, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Dec 15, 2017
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Jan 2, 2018
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Jan 4, 2018
zcbenz pushed a commit to electron/libchromiumcontent that referenced this pull request Jan 30, 2018
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Feb 21, 2018
alexeykuzmin added a commit to electron/libchromiumcontent that referenced this pull request Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for window transparency
8 participants