overlay.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <style>
  7. :root {
  8. --fallback-title-bar-height: 40px;
  9. }
  10. .draggable {
  11. app-region: drag;
  12. /* Pre-fix app-region during standardization process */
  13. -webkit-app-region: drag;
  14. }
  15. .nonDraggable {
  16. app-region: no-drag;
  17. /* Pre-fix app-region during standardization process */
  18. -webkit-app-region: no-drag;
  19. }
  20. #titleBarContainer {
  21. position: absolute;
  22. top: env(titlebar-area-y, 0);
  23. height: env(titlebar-area-height, var(--fallback-title-bar-height));
  24. width: 100%;
  25. }
  26. #titleBar {
  27. position: absolute;
  28. top: 0;
  29. display: flex;
  30. user-select: none;
  31. height: 100%;
  32. left: env(titlebar-area-x, 0);
  33. width: env(titlebar-area-width, 100%);
  34. }
  35. #mainContent {
  36. position: absolute;
  37. left: 0;
  38. right: 0;
  39. bottom: 0;
  40. top: env(titlebar-area-height, var(--fallback-title-bar-height));
  41. overflow-y: scroll;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <script>
  47. const {ipcRenderer} = require('electron');
  48. navigator.windowControlsOverlay.ongeometrychange = function() {
  49. const {x, y, width, height} = navigator.windowControlsOverlay.getTitlebarAreaRect();
  50. ipcRenderer.send('geometrychange', {x, y, width, height});
  51. };
  52. </script>
  53. <div id="titleBarContainer">
  54. <div id="titleBar" class=" draggable">
  55. <span class="draggable">Title goes here</span>
  56. <input class="nonDraggable" type="text" placeholder="Search"></input>
  57. </div>
  58. </div>
  59. <div id="mainContent"><!-- The rest of the webpage --></div>
  60. <script>
  61. function getCssOverlayProperties() {
  62. const cssOverlayProps = {};
  63. const titleBarContainer = document.getElementById('titleBarContainer');
  64. const titleBar = document.getElementById('titleBar');
  65. cssOverlayProps.y = titleBarContainer.computedStyleMap().get('top').value;
  66. cssOverlayProps.height = titleBarContainer.computedStyleMap().get('height').value;
  67. cssOverlayProps.x = titleBar.computedStyleMap().get('left').value;
  68. cssOverlayProps.width = titleBar.computedStyleMap().get('width').value;
  69. return cssOverlayProps;
  70. }
  71. function getJSOverlayProperties() {
  72. const {x, y, width, height} = navigator.windowControlsOverlay.getTitlebarAreaRect();
  73. return {x, y, width, height};
  74. }
  75. </script>
  76. </body>
  77. </html>