Git Product home page Git Product logo

Comments (17)

Ciantic avatar Ciantic commented on May 13, 2024 10

Was there a regression of sorts? I think the pull request was for old version of this library that used the msedge HTML, and needs to be fixed for webview2 Edge implementation too.

I'm testing the webview_rust in Windows 10, the windows are blurry.


For webview_rust one can fix it like this:

Cargo.toml

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["shellscalingapi"] }

main.rs

fn main() {
    #[cfg(target_os = "windows")]
    unsafe {
        winapi::um::shellscalingapi::SetProcessDpiAwareness(2);
    }

    // Rest of the application ...

from webview.

raphtlw avatar raphtlw commented on May 13, 2024 5

This library also doesn't support display scaling from KDE, when the display is scaled, the GTK+ webkit doesn't scale properly and elements are too small.

from webview.

zserge avatar zserge commented on May 13, 2024 3

from webview.

lewisthoma5 avatar lewisthoma5 commented on May 13, 2024 3

I have a fix for windows that extends the minimal-go example.

package main

import (
	"syscall"
	"github.com/zserge/webview"
)

func scale() {
	modshcore := syscall.NewLazyDLL("Shcore.dll")
	shc := modshcore.NewProc("SetProcessDpiAwareness")
	shc.Call(uintptr(1))
}

func main() {
	// Open wikipedia in a 800x600 resizable window
	scale()
	webview.Open("Minimal webview example",
		"https://en.m.wikipedia.org/wiki/Main_Page", 800, 600, true)
}

No idea about mac so sorry about that but I hope this helps.

from webview.

Boscop avatar Boscop commented on May 13, 2024 1

I'm also interested in this...

from webview.

jiangyibin avatar jiangyibin commented on May 13, 2024 1

Right click the exe file -> properties -> compatibility, there's an option "Override high DPI scaling behavior". Check it.
This is equal to write register "/Software/Microsoft/Windows NT/CurrentVersion/AppCompatFlags/Layers" KEY:path/to/exe VALUE:"~HIGHDPIAWARE"

from webview.

zenakuten avatar zenakuten commented on May 13, 2024 1

Woah that was a quick reply. :) I took a drink of coffee, looked back over and here it is. Nice thank you for the great project

from webview.

jakenvac avatar jakenvac commented on May 13, 2024 1

Did this PR ever get merged?

from webview.

quadrupleslap avatar quadrupleslap commented on May 13, 2024

Relevant page? https://msdn.microsoft.com/en-us/library/dn265030(v=vs.85).aspx

from webview.

Boscop avatar Boscop commented on May 13, 2024

Hm, I don't think that's the solution. In my normal IE11 on Win8.1, the same site looks HDPI but if I open it with webview, it looks low-res.. It must be some setting for the MSHTML engine.

from webview.

ajusa avatar ajusa commented on May 13, 2024

Yeah, I noticed that too

from webview.

DanielSek avatar DanielSek commented on May 13, 2024

Probably related to application DPI awareness:

EDIT:
Verified with Visual Studio 2013 Community
Project->Properties->Configuration Properties->Manifest Tool->Input and Output->DPI Awareness
change from None to High DPI Aware.
Per Monitor High DPI Aware needs handling of additional messages, so initially it would be harder, but it would react faster on DPI setting change.
Unfortunately High DPI Aware on Windows 10 needs log off and log in after change to work correctly.

Or edit manifest manually:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="*"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
    </dependency>
    <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    	<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
            <dpiAware>true</dpiAware>
    	</asmv3:windowsSettings>
    </asmv3:application>
</assembly>

Or early in WinMain call

SetProcessDpiAwareness( PROCESS_SYSTEM_DPI_AWARE );

Or

SetProcessDpiAwareness( PROCESS_PER_MONITOR_DPI_AWARE );

from webview.

jiangyibin avatar jiangyibin commented on May 13, 2024

Use the following code to adjust width and height automatically

  HDC hDC = GetDC(NULL);
  w->width = GetDeviceCaps(hDC, 88)*w->width/96.0;
  w->height = GetDeviceCaps(hDC, 90)*w->height/96.0;
  ReleaseDC(NULL, hDC);

and this works fine for most examples.

from webview.

zenakuten avatar zenakuten commented on May 13, 2024

I have a pull request which fixes this.

from webview.

mantou132 avatar mantou132 commented on May 13, 2024

When I execute binary files directly, the application is not blurred. But when the application is packaged and run, the window becomes blurred. I use macOS.

https://github.com/mantou132/evernote-webview
screen shot 2019-02-19 at 2 24 01 am
// fixed: NSHighResolutionCapable

from webview.

raphtlw avatar raphtlw commented on May 13, 2024

So recently, I started using this library again and I've found a workaround for Linux. ✨

Use winit to get the scale factor and set the scale factor as the zoom level on the webview instead.

First, get the scale factor

    let scale_factor = {
        use winit::{event_loop::EventLoop, window::WindowBuilder};

        let event_loop = EventLoop::new();
        let window = WindowBuilder::new()
            .with_maximized(false)
            .with_visible(false)
            .build(&event_loop)?;

        let scale_factor = window.scale_factor();
        println!("Scale factor: {}", scale_factor);

        drop(window);

        scale_factor
    };

Then, instantiate the webview and call set_zoom_level on the webview.

webview.set_zoom_level(scale_factor);

from webview.

SteffenL avatar SteffenL commented on May 13, 2024

Closing as stale. The current situation on Windows is that the library enables DPI awareness.

from webview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.