Skip to content
New issue

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

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

Already on GitHub? # to your account

Cef scaling issue with different windows scaling optoins #2554

Open
michalcourson opened this issue Dec 29, 2024 · 0 comments
Open

Cef scaling issue with different windows scaling optoins #2554

michalcourson opened this issue Dec 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@michalcourson
Copy link

michalcourson commented Dec 29, 2024

Describe the bug
A cef web wallpaper can fail to scale properly if the worker window is in on a display that has different windows scaling options. It is unclear to me if this is a windows error, or a cef error. Upon calling NativeMethods.SetWindowPos when placing the window on the correct display, the browser size and scaling factor is incorrect. I have a workaround in the lively core service that is working for me.

To Reproduce

  1. Setup displays such that the worker window puts itself on a display with a different scaling factor
  2. Load a web wallpaper using Cef
  3. Scaling will be incorrect

Expected behavior
Scaling factor/resolution is correctly grabbed from the target display.

Screenshots/Video
Video with both failure condition and workaround

Desktop (please complete the following information):

  • OS: windows 11

  • Test wallpaper:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Browser Info</title>
    <style>
    body {
    font-family: Arial, sans-serif;
    margin: 20px;
    }
    .info {
    margin: 10px 0;
    }
    .label {
    font-weight: bold;
    }
    </style>
    </head>
    <body>
    <h1>Browser Information</h1>
    <div class="info">
    <span class="label">Scale Factor:</span>
    <span id="scaleFactor"></span>
    </div>
    <div class="info">
    <span class="label">Screen Resolution:</span>
    <span id="screenResolution"></span>
    </div>
    <div class="info">
    <span class="label">Browser Window Size:</span>
    <span id="windowSize"></span>
    </div>
    <div class="info">
    <span class="label">User Agent:</span>
    <span id="userAgent"></span>
    </div>
    <div class="info">
    <span class="label">Browser Version:</span>
    <span id="browserVersion"></span>
    </div>

    <script>
    function updateValues(){
    function getScaleFactor() {
    return window.devicePixelRatio;
    }

      function getScreenResolution() {
          return `${window.screen.width} x ${window.screen.height}`;
      }
    
      function getWindowSize() {
          return `${window.innerWidth} x ${window.innerHeight}`;
      }
    
      function getUserAgent() {
          return navigator.userAgent;
      }
    
      function getBrowserVersion() {
          let userAgent = navigator.userAgent;
          let match = userAgent.match(/(Chrome|Firefox|Safari|Edge)\/(\d+)/);
          if (match) {
              return `${match[1]} ${match[2]}`;
          }
          return 'Unknown';
      }
    
      document.getElementById('scaleFactor').textContent = getScaleFactor();
      document.getElementById('screenResolution').textContent = getScreenResolution();
      document.getElementById('windowSize').textContent = getWindowSize();
      document.getElementById('userAgent').textContent = getUserAgent();
      document.getElementById('browserVersion').textContent = getBrowserVersion();
    }
    updateValues();
    window.addEventListener('resize', function(event){
      updateValues();
    });
    

    </script>
    </body>
    </html>

Additional context
Add any other context about the problem here.

Log file (Important)
20241229_110618.txt

@michalcourson michalcourson added the bug Something isn't working label Dec 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant