cengal.user_interface.gui.nt.blur_behind.versions.v_0.blur_behind
1#!/usr/bin/env python 2# coding=utf-8 3 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space> 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18 19__all__ = ['prepare_for_composition'] 20 21 22import ctypes 23from ctypes import wintypes 24from cengal.system import OS_TYPE 25 26 27""" 28Module Docstring 29Docstrings: http://www.python.org/dev/peps/pep-0257/ 30""" 31 32__author__ = "ButenkoMS <gtalk@butenkoms.space>" 33__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>" 34__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ] 35__license__ = "Apache License, Version 2.0" 36__version__ = "4.4.1" 37__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>" 38__email__ = "gtalk@butenkoms.space" 39# __status__ = "Prototype" 40__status__ = "Development" 41# __status__ = "Production" 42 43 44def prepare_for_composition(hwnd): 45 if 'Windows' != OS_TYPE: 46 return 47 48 dwm = ctypes.windll.dwmapi 49 50 # needs pointertomarginsstruct 51 class MARGINS(ctypes.Structure): 52 _fields_ = [("cxLeftWidth", ctypes.c_int), 53 ("cxRightWidth", ctypes.c_int), 54 ("cyTopHeight", ctypes.c_int), 55 ("cyBottomHeight", ctypes.c_int) 56 ] 57 58 thisWin = hwnd 59 60 # if self.is_composition_enabled: 61 # # lt() 62 # margins = MARGINS(-1, 0, 0, 0) 63 # result = dwm.DwmExtendFrameIntoClientArea(thisWin, ctypes.byref(margins)) 64 # else: 65 # # lt() 66 # margins = MARGINS(0, 0, 0, 0) 67 # result = dwm.DwmExtendFrameIntoClientArea(thisWin, ctypes.byref(margins)) 68 69 # if 0 == result: 70 # self.is_aero_glass_turned_on = True 71 # else: 72 # self.is_aero_glass_turned_on = False 73 74 # -------------------- 75 76 user32 = ctypes.windll.user32 77 78 WCA_ACCENT_POLICY = 19 79 ACCENT_ENABLE_BLURBEHIND = 3 80 81 class AccentPolicy(ctypes.Structure): 82 _fields_ = [ 83 ('AccentState', wintypes.ULONG), 84 ('AccentFlags', wintypes.ULONG), 85 ('GradientColor', wintypes.ULONG), 86 ('AnimationId', wintypes.ULONG), 87 ] 88 89 class WINCOMPATTRDATA(ctypes.Structure): 90 _fields_ = [ 91 ('attribute', wintypes.DWORD), 92 ('pData', ctypes.POINTER(AccentPolicy)), 93 ('dataSize', wintypes.ULONG), 94 ] 95 96 accent_policy = AccentPolicy(ACCENT_ENABLE_BLURBEHIND, 0, 0, 0) 97 wincompattrdata = WINCOMPATTRDATA(WCA_ACCENT_POLICY, ctypes.pointer(accent_policy), ctypes.sizeof(accent_policy)) 98 99 result = user32.SetWindowCompositionAttribute(thisWin, ctypes.pointer(wincompattrdata)) 100 101 if 0 != result: 102 return None 103 else: 104 return ctypes.windll.Kernel32.GetLastError()
def
prepare_for_composition(hwnd):
45def prepare_for_composition(hwnd): 46 if 'Windows' != OS_TYPE: 47 return 48 49 dwm = ctypes.windll.dwmapi 50 51 # needs pointertomarginsstruct 52 class MARGINS(ctypes.Structure): 53 _fields_ = [("cxLeftWidth", ctypes.c_int), 54 ("cxRightWidth", ctypes.c_int), 55 ("cyTopHeight", ctypes.c_int), 56 ("cyBottomHeight", ctypes.c_int) 57 ] 58 59 thisWin = hwnd 60 61 # if self.is_composition_enabled: 62 # # lt() 63 # margins = MARGINS(-1, 0, 0, 0) 64 # result = dwm.DwmExtendFrameIntoClientArea(thisWin, ctypes.byref(margins)) 65 # else: 66 # # lt() 67 # margins = MARGINS(0, 0, 0, 0) 68 # result = dwm.DwmExtendFrameIntoClientArea(thisWin, ctypes.byref(margins)) 69 70 # if 0 == result: 71 # self.is_aero_glass_turned_on = True 72 # else: 73 # self.is_aero_glass_turned_on = False 74 75 # -------------------- 76 77 user32 = ctypes.windll.user32 78 79 WCA_ACCENT_POLICY = 19 80 ACCENT_ENABLE_BLURBEHIND = 3 81 82 class AccentPolicy(ctypes.Structure): 83 _fields_ = [ 84 ('AccentState', wintypes.ULONG), 85 ('AccentFlags', wintypes.ULONG), 86 ('GradientColor', wintypes.ULONG), 87 ('AnimationId', wintypes.ULONG), 88 ] 89 90 class WINCOMPATTRDATA(ctypes.Structure): 91 _fields_ = [ 92 ('attribute', wintypes.DWORD), 93 ('pData', ctypes.POINTER(AccentPolicy)), 94 ('dataSize', wintypes.ULONG), 95 ] 96 97 accent_policy = AccentPolicy(ACCENT_ENABLE_BLURBEHIND, 0, 0, 0) 98 wincompattrdata = WINCOMPATTRDATA(WCA_ACCENT_POLICY, ctypes.pointer(accent_policy), ctypes.sizeof(accent_policy)) 99 100 result = user32.SetWindowCompositionAttribute(thisWin, ctypes.pointer(wincompattrdata)) 101 102 if 0 != result: 103 return None 104 else: 105 return ctypes.windll.Kernel32.GetLastError()