Git Product home page Git Product logo

Comments (7)

selastingeorge avatar selastingeorge commented on May 20, 2024

Bro, I have noticed the issue about DXGI warning earlier, i think it is from the D3D11, any way I will look into it. and I will also add the dpi awareness. Did you make it work on QT, will you be able to draw anything on top of the acrylic

from win32-acrylic-effect.

selastingeorge avatar selastingeorge commented on May 20, 2024

Bro I have updated the code, Added DPI Awareness and Fixed the memory leak.

from win32-acrylic-effect.

wangwenx190 avatar wangwenx190 commented on May 20, 2024

Thanks for your great work!

from win32-acrylic-effect.

wangwenx190 avatar wangwenx190 commented on May 20, 2024

Did you make it work on QT, will you be able to draw anything on top of the acrylic

I'm porting this repo to Qt and is making some progress indeed. I'm not able to draw on top of the acrylic either. My solution is creating two windows, one is the real window but have a transparent background, the other is the acrylic window, then place the acrylic window under the real window. I hooked the real window's WndProc function to make the acrylic window sync it's position with the real window. Once it's done, I'll let you know.

from win32-acrylic-effect.

selastingeorge avatar selastingeorge commented on May 20, 2024

Did you make it work on QT, will you be able to draw anything on top of the acrylic

I'm porting this repo to Qt and is making some progress indeed. I'm not able to draw on top of the acrylic either. My solution is creating two windows, one is the real window but have a transparent background, the other is the acrylic window, then place the acrylic window under the real window. I hooked the real window's WndProc function to make the acrylic window sync it's position with the real window. Once it's done, I'll let you know.

Ya i tried this method with WPF, I was actually able to draw contents on top, but syncing the position is too slow. There is one other way also to overcome this problem. there is an easy way to draw on top of acrylic, there is a method in Direct composition to copy the contents of one window to another (i mean the visual like DWM thumbnail). then all you need to do is forward all events from one window to another.

I will explain you with a demo.

IDCompositionDevice::CreateSurfaceFromHwnd() : with this function you can copy all the contents in a window to another same as DWMThumbnail. but in the case of dwm thumbnail you will not be able to alter the visual rendered to window, but it is possible in this method.

CreateSurfaceFromHwnd() takes two parameter hwnd and IUnknown.

HRESULT hr = S_OK;
IDCompositionVisual *pVisual = nullptr;
IUnknown *pSurface = nullptr;

// Create a visual. g_pDevice is the IDCompositionDevice pointer of a 
// device object created earlier.
hr = g_pDevice->CreateVisual(&pVisual);

if (SUCCEEDED(hr))
{
    // Create a surface that contains the image of the layered child 
    // window identified by the g_hwndChild window handle (HWND). 
    hr = g_pDevice->CreateSurfaceFromHwnd(g_hwndChild, &pSurface);
}

if (SUCCEEDED(hr))
{
    // Set the content of the Control child visual.
    hr = pVisual->SetContent(pSurface);
}

with this code you can get the content of a window into IDCompositionVisual, in this repo the acrylic is actually rendered to a visual.so it is possible to overlap the window visual on top of acrylic visual. See this part of my code.

case AcrylicCompositor::BACKDROP_SOURCE_HOSTBACKDROP:
rootVisual->AddVisual(desktopWindowVisual.Get(), false, NULL);
rootVisual->AddVisual(topLevelWindowVisual.Get(), true, desktopWindowVisual.Get());
rootVisual->AddVisual(fallbackVisual.Get(), true, topLevelWindowVisual.Get());
break;

Here the AddVisual() adds another visuals into the root visual, the first parameter is the visual to be added, the second parameter is a Boolean which specifies whether to place top of another visual or not. the third parameter is the previous visual.(which means the new visual will overlap the previous visual).

This will help you to create the visual of one window and place on top of other, but the both windows should be of the same program (thread)

The you must forward all events from one window to another (i mean all click,drag etc..)

from win32-acrylic-effect.

wangwenx190 avatar wangwenx190 commented on May 20, 2024

Thanks for your detailed reply, I really learned a lot! But it seems your solution also needs two windows, or am I misunderstand something?
Anyway, if my solution goes to an dead end, I'll try your solution.

from win32-acrylic-effect.

selastingeorge avatar selastingeorge commented on May 20, 2024

Thanks for your detailed reply, I really learned a lot! But it seems your solution also needs two windows, or am I misunderstand something?
Anyway, if my solution goes to an dead end, I'll try your solution.

you need two windows but it will remove the sync delay, it is really fast like DWM Thumbnail, and to reduce the memory usage you can use DWMA_CLOAK attribute for the original window. works really better than overlapping window. Haven't you tried winrt acrylic, its easier than this, i will upload a sample later

join here : Discord Channel, we can have a lot of discussions there

from win32-acrylic-effect.

Related Issues (7)

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.