Skip to content

Add support for window transparency#949

Merged
zcbenz merged 11 commits intomasterfrom
window-transparency
Jan 12, 2015
Merged

Add support for window transparency#949
zcbenz merged 11 commits intomasterfrom
window-transparency

Conversation

@zcbenz
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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 zcbenz force-pushed the window-transparency branch from 80bb71c to 85685fe Compare December 23, 2014 23:56
@zcbenz
Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor

😍

@lynchpin4
Copy link
Copy Markdown

your the man zcbenz ! +1

@zcbenz
Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor Author

zcbenz commented Jan 2, 2015

@paulcbetts Sure, feedbacks are welcomed!

@anaisbetts
Copy link
Copy Markdown
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 Apr 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
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Apr 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 Apr 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 Apr 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 Apr 10, 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 Apr 10, 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 Apr 21, 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 Apr 21, 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 Apr 21, 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 Apr 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
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request Apr 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
zcbenz added a commit to electron/libchromiumcontent that referenced this pull request May 5, 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 May 5, 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 May 10, 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 May 12, 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 May 12, 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 May 12, 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 May 12, 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 May 22, 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 May 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 May 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 May 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 May 29, 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 May 29, 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 May 29, 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
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