Added New Backend Dual Kawase Blur + Rounded Corners - merged with Ibhagwan

This commit is contained in:
jon
2020-07-14 18:04:45 +02:00
parent d6bc68146b
commit 0375dad5d1
54 changed files with 4696 additions and 1620 deletions

View File

@ -1,35 +1,18 @@
import xcffib.xproto as xproto
import xcffib.randr as randr
import xcffib
import time
import random
import string
def to_atom(conn, string):
return conn.core.InternAtom(False, len(string), string).reply().atom
def set_window_name(conn, wid, name):
prop_name = to_atom(conn, "_NET_WM_NAME")
str_type = to_atom(conn, "UTF8_STRING")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, prop_name, str_type, 8, len(name), name).check()
prop_name = to_atom(conn, "WM_NAME")
str_type = to_atom(conn, "STRING")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, prop_name, str_type, 8, len(name), name).check()
def set_window_state(conn, wid, state):
prop_name = to_atom(conn, "WM_STATE")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, prop_name, prop_name, 32, 2, [state, 0]).check()
def set_window_class(conn, wid, name):
if not isinstance(name, bytearray):
name = name.encode()
name = name+b"\0"+name+b"\0"
prop_name = to_atom(conn, "WM_CLASS")
str_type = to_atom(conn, "STRING")
prop_name = "_NET_WM_NAME"
prop_name = conn.core.InternAtom(True, len(prop_name), prop_name).reply().atom
str_type = "STRING"
str_type = conn.core.InternAtom(True, len(str_type), str_type).reply().atom
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid, prop_name, str_type, 8, len(name), name).check()
def find_picom_window(conn):
prop_name = to_atom(conn, "WM_NAME")
prop_name = "WM_NAME"
prop_name = conn.core.InternAtom(True, len(prop_name), prop_name).reply().atom
setup = conn.get_setup()
root = setup.roots[0].root
windows = conn.core.QueryTree(root).reply()
@ -58,19 +41,3 @@ def trigger_root_configure(conn):
rr.AddOutputModeChecked(output, mode).check()
rr.SetCrtcConfig(reply.crtcs[0], reply.timestamp, reply.config_timestamp, 0, 0, mode, randr.Rotation.Rotate_0, 1, [output]).reply()
def find_32bit_visual(conn):
setup = conn.get_setup()
render = conn(xcffib.render.key)
r = render.QueryPictFormats().reply()
pictfmt_ids = set()
for pictform in r.formats:
if (pictform.depth == 32 and
pictform.type == xcffib.render.PictType.Direct and
pictform.direct.alpha_mask != 0):
pictfmt_ids.add(pictform.id)
print(pictfmt_ids)
for screen in r.screens:
for depth in screen.depths:
for pv in depth.visuals:
if pv.format in pictfmt_ids:
return pv.visual

View File

@ -1,112 +0,0 @@
#!/usr/bin/env python3
import xcffib.xproto as xproto
import xcffib
import time
import os
import subprocess
import asyncio
from dbus_next.aio import MessageBus
from dbus_next.message import Message, MessageType
from common import *
display = os.environ["DISPLAY"].replace(":", "_")
conn = xcffib.connect()
setup = conn.get_setup()
root = setup.roots[0].root
visual = setup.roots[0].root_visual
depth = setup.roots[0].root_depth
x = xproto.xprotoExtension(conn)
visual32 = find_32bit_visual(conn)
async def get_client_win_async(wid):
message = await bus.call(Message(destination='com.github.chjj.compton.'+display,
path='/',
interface='com.github.chjj.compton',
member='win_get',
signature='us',
body=[wid, 'client_win']))
return message.body[0]
def get_client_win(wid):
return loop.run_until_complete(get_client_win_async(wid))
def wait():
time.sleep(0.5)
def create_client_window(name):
client_win = conn.generate_id()
print("Window : ", hex(client_win))
conn.core.CreateWindowChecked(depth, client_win, root, 0, 0, 100, 100, 0,
xproto.WindowClass.InputOutput, visual, 0, []).check()
set_window_name(conn, client_win, "Test window "+name)
set_window_class(conn, client_win, "Test windows")
set_window_state(conn, client_win, 1)
conn.core.MapWindowChecked(client_win).check()
return client_win
loop = asyncio.get_event_loop()
bus = loop.run_until_complete(MessageBus().connect())
cmid = conn.generate_id()
colormap = conn.core.CreateColormapChecked(xproto.ColormapAlloc._None, cmid, root, visual32).check()
# Create window
client_wins = []
for i in range(0,2):
client_wins.append(create_client_window(str(i)))
# Create frame window
frame_win = conn.generate_id()
print("Window : ", hex(frame_win))
conn.core.CreateWindowChecked(depth, frame_win, root, 0, 0, 200, 200, 0,
xproto.WindowClass.InputOutput, visual, 0, []).check()
set_window_name(conn, frame_win, "Frame")
conn.core.MapWindowChecked(frame_win).check()
# Scenario 1.1
# 1. reparent placeholder to frame
conn.core.ReparentWindowChecked(client_wins[0], frame_win, 0, 0).check()
wait()
# 2. reparent real client to frame
conn.core.ReparentWindowChecked(client_wins[1], frame_win, 0, 0).check()
wait()
# 3. detach the placeholder
conn.core.ReparentWindowChecked(client_wins[0], root, 0, 0).check()
wait()
assert get_client_win(frame_win) == client_wins[1]
# Scenario 1.2
# 1. reparent placeholder to frame
conn.core.ReparentWindowChecked(client_wins[0], frame_win, 0, 0).check()
wait()
# 2. reparent real client to frame
conn.core.ReparentWindowChecked(client_wins[1], frame_win, 0, 0).check()
wait()
# 3. destroy the placeholder
conn.core.DestroyWindowChecked(client_wins[0]).check()
wait()
assert get_client_win(frame_win) == client_wins[1]
client_wins[0] = create_client_window("0")
# Scenario 2
# 1. frame is unmapped
conn.core.UnmapWindowChecked(frame_win).check()
wait()
# 2. reparent placeholder to frame
conn.core.ReparentWindowChecked(client_wins[0], frame_win, 0, 0).check()
wait()
# 3. destroy placeholder, map frame and reparent real client to frame
conn.core.DestroyWindowChecked(client_wins[0]).check()
conn.core.MapWindowChecked(frame_win).check()
conn.core.ReparentWindowChecked(client_wins[1], frame_win, 0, 0).check()
wait()
assert get_client_win(frame_win) == client_wins[1]
client_wins[0] = create_client_window("0")
# Destroy the windows
for wid in client_wins:
conn.core.DestroyWindowChecked(wid).check()
conn.core.DestroyWindowChecked(frame_win).check()

View File

@ -1,44 +0,0 @@
#!/usr/bin/env python
import xcffib.xproto as xproto
import xcffib
import time
from common import set_window_name, trigger_root_configure
conn = xcffib.connect()
setup = conn.get_setup()
root = setup.roots[0].root
visual = setup.roots[0].root_visual
depth = setup.roots[0].root_depth
x = xproto.xprotoExtension(conn)
# issue 314 is caused by changing a windows target opacity during its fade-in/-out transition
wid1 = conn.generate_id()
print("Window 1: ", hex(wid1))
wid2 = conn.generate_id()
print("Window 2: ", hex(wid2))
# Create windows
conn.core.CreateWindowChecked(depth, wid1, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
conn.core.CreateWindowChecked(depth, wid2, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
# Set Window names
set_window_name(conn, wid1, "Test window 1")
set_window_name(conn, wid2, "Test window 2")
# Check updating opacity while UNMAPPING/DESTROYING windows
print("Mapping 1")
conn.core.MapWindowChecked(wid1).check()
print("Mapping 2")
conn.core.MapWindowChecked(wid2).check()
time.sleep(0.5)
x.SetInputFocusChecked(0, wid1, xproto.Time.CurrentTime).check()
time.sleep(0.5)
# Destroy the windows
print("Destroy 1 while fading out")
conn.core.DestroyWindowChecked(wid1).check()
x.SetInputFocusChecked(0, wid2, xproto.Time.CurrentTime).check()
time.sleep(1)
conn.core.DestroyWindowChecked(wid2).check()

View File

@ -1,46 +0,0 @@
#!/usr/bin/env python
import xcffib.xproto as xproto
import xcffib
import time
from common import set_window_name, trigger_root_configure
conn = xcffib.connect()
setup = conn.get_setup()
root = setup.roots[0].root
visual = setup.roots[0].root_visual
depth = setup.roots[0].root_depth
x = xproto.xprotoExtension(conn)
opacity_80 = [int(0xffffffff * 0.8), ]
opacity_single = [int(0xffffffff * 0.002), ]
# issue 314 is caused by changing a windows target opacity during its fade-in/-out transition
wid1 = conn.generate_id()
print("Window 1: ", hex(wid1))
atom = "_NET_WM_WINDOW_OPACITY"
opacity_atom = conn.core.InternAtom(False, len(atom), atom).reply().atom
# Create windows
conn.core.CreateWindowChecked(depth, wid1, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
# Set Window names
set_window_name(conn, wid1, "Test window 1")
# Check updating opacity while MAPPING windows
print("Mapping window")
conn.core.MapWindowChecked(wid1).check()
time.sleep(0.5)
print("Update opacity while fading in")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_80).check()
time.sleep(0.2)
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_single).check()
time.sleep(1)
conn.core.DeletePropertyChecked(wid1, opacity_atom).check()
time.sleep(0.5)
# Destroy the windows
conn.core.DestroyWindowChecked(wid1).check()

View File

@ -1,63 +0,0 @@
#!/usr/bin/env python
import xcffib.xproto as xproto
import xcffib
import time
from common import set_window_name, trigger_root_configure
conn = xcffib.connect()
setup = conn.get_setup()
root = setup.roots[0].root
visual = setup.roots[0].root_visual
depth = setup.roots[0].root_depth
x = xproto.xprotoExtension(conn)
opacity_100 = [0xffffffff, ]
opacity_80 = [int(0xffffffff * 0.8), ]
opacity_single = [int(0xffffffff * 0.002), ]
opacity_0 = [0, ]
# issue 314 is caused by changing a windows target opacity during its fade-in/-out transition
wid1 = conn.generate_id()
print("Window 1: ", hex(wid1))
atom = "_NET_WM_WINDOW_OPACITY"
opacity_atom = conn.core.InternAtom(False, len(atom), atom).reply().atom
# Create windows
conn.core.CreateWindowChecked(depth, wid1, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
# Set Window names
set_window_name(conn, wid1, "Test window 1")
# Check updating opacity while FADING windows
print("Mapping window")
conn.core.MapWindowChecked(wid1).check()
time.sleep(1.2)
print("Update opacity while fading out")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_single).check()
time.sleep(0.2)
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_0).check()
time.sleep(1)
print("Change from fading in to fading out")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_80).check()
time.sleep(0.5)
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_0).check()
time.sleep(1)
print("Update opacity while fading in")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_80).check()
time.sleep(0.2)
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_100).check()
time.sleep(1)
print("Change from fading out to fading in")
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_0).check()
time.sleep(0.5)
conn.core.ChangePropertyChecked(xproto.PropMode.Replace, wid1, opacity_atom, xproto.Atom.CARDINAL, 32, 1, opacity_80).check()
time.sleep(1)
# Destroy the windows
conn.core.DestroyWindowChecked(wid1).check()

View File

@ -1,33 +0,0 @@
#!/usr/bin/env python
import xcffib.xproto as xproto
import xcffib
import time
from common import set_window_name, trigger_root_configure
conn = xcffib.connect()
setup = conn.get_setup()
root = setup.roots[0].root
visual = setup.roots[0].root_visual
depth = setup.roots[0].root_depth
# issue 357 is triggered when a window is destroyed right after configure_root
wid = conn.generate_id()
print("Window 1: ", hex(wid))
# Create a window
conn.core.CreateWindowChecked(depth, wid, root, 0, 0, 100, 100, 0, xproto.WindowClass.InputOutput, visual, 0, []).check()
# Set Window name
set_window_name(conn, wid, "Test window 1")
print("mapping 1")
conn.core.MapWindowChecked(wid).check()
time.sleep(0.5)
trigger_root_configure(conn)
# Destroy the windows
conn.core.DestroyWindowChecked(wid).check()
time.sleep(1)