pywebview icon indicating copy to clipboard operation
pywebview copied to clipboard

When the window is maximized or minimized, the bottom view will be covered

Open MaxBill opened this issue 2 years ago • 10 comments

Specification

  • pywebview version: 3.5
  • operating system: windows 10 and windows 10
  • web renderer: cef and mshtml

Description

After the window instantiation is started, maximize or minimize the window or resize, and then restore the window. At this time, compared with the original, some views at the bottom are blocked. This is the case with CEF and mshtml. After browsing the documents and issues, this problem has not been solved. Please ask how to troubleshoot this problem. Thank you very much.

Here are two screenshots of the original and problem comparison: image image

Practicalities

  • YES/NO I am willing to work on this issue myself.

  • YES/NO I am prepared to support this issue financially.

MaxBill avatar Nov 20 '21 16:11 MaxBill

Please share the code to reproduce this problem

r0x0r avatar Nov 20 '21 21:11 r0x0r

I found a problem in the process of putting forward simple error examples from complex projects. This scenario occurs when the GUI is CEF, and mshtml has no problem. The following simple error examples I provide, thank you again for your help

import webview

html = '''
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <title>hello pywebview</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color: #3e8f3e;
        }

        iframe {
            border: 0;
        }

        #header {
            width: 100%;
            height: 90px;
            background-color: red;
        }

        #center {
            width: 100%;
            height: 100%;
            background-color: white;
        }

        #footer {
            bottom: 0;
            width: 100%;
            height: 30px;
            position: fixed;
            background-color: blue;
        }
    </style>
</head>
<body>
<div id="header">
   top
</div>
<div id="center">
    center
</div>
<div id="footer">
   bottom
</div>
</body>
</html>
'''


def run():
    window = webview.create_window(
        '', html=html,
        width=600, height=400
    )
    webview.start(gui='cef')


if __name__ == '__main__':
    run()

MaxBill avatar Nov 21 '21 04:11 MaxBill

Can you repeat this question over there. Can the CEF version be upgraded? I wonder if this problem can be solved by upgrading CEF

MaxBill avatar Nov 25 '21 08:11 MaxBill

Sorry haven't had a chance to investigate the problem yet. I think the problem is caused that CEF component fails to update its size on window restore event. CEF browser object provides NotifyMoveOrResizeStarted method. My guess is it should be invoked on maximize/restore events.

As for CEF upgrade. I haven't done it, but from my investigations back then I got an impression it was possible. CEF builds can be downloaded at https://cef-builds.spotifycdn.com/index.html and CEF Python documentation here https://github.com/cztomczak/cefpython

r0x0r avatar Nov 30 '21 15:11 r0x0r

Thank you for paying attention to this problem. According to the solution ideas you provided, I will try to solve this problem. If there is a solution, I will share it here. I will close this problem first and thank you again for your help

MaxBill avatar Dec 01 '21 03:12 MaxBill

Hello, through the debug code, I found that this problem is caused by a fixed value. When the window size changes, the incoming height parameter will be fixed minus 38. Please tell me what the value of 38 is. I try to change it to 44. On my computer, this problem is solved. I guess whether this 38 is the height of the taskbar, If so, there may be some compatibility problems with different versions of the system

image

MaxBill avatar Dec 01 '21 07:12 MaxBill

It is the height of titlebar. It has been changed before to fix a similar problem, but apparently hard coding this value does not solve anything.

r0x0r avatar Dec 01 '21 22:12 r0x0r

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 01 '22 02:01 github-actions[bot]

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.

github-actions[bot] avatar Jan 06 '22 02:01 github-actions[bot]

I pushed a potential fix to cef-resize-fix branch. It still has hard-coded values, but offset is calculated dynamically now. @MaxBill can you test if it solves the problem for you?

r0x0r avatar Feb 17 '22 20:02 r0x0r

I merged the fix with 4.0 branch and will close this issue now.

r0x0r avatar Nov 15 '22 06:11 r0x0r