MCPcopy Create free account
hub / github.com/NyarchLinux/DesktopPuppet / on_activate

Function on_activate

src/main.py:29–72  ·  view source on GitHub ↗
(app)

Source from the content-addressed store, hash-verified

27 print("overlay")
28
29def on_activate(app):
30 # Configure the complete surface before mapping it. Presenting the window
31 # earlier lets GTK draw its default opaque background for the first frame
32 # and means the initial 1x1 default size may be kept by the compositor.
33 window = Gtk.Window(application=app, title="nyarchpet")
34 LayerShell.init_for_window(window)
35 LayerShell.set_layer(window, LayerShell.Layer.OVERLAY)
36 window.set_decorated(False)
37
38 # A user GTK stylesheet can contain a global `window` background at
39 # GTK_STYLE_PROVIDER_PRIORITY_USER. Transparency is functional here, not
40 # cosmetic, so install this narrowly-scoped rule just above that priority.
41 css = Gtk.CssProvider()
42 css.load_from_string(
43 """
44 window.main-window {
45 background: transparent;
46 background-color: transparent;
47 }
48 """
49 )
50 Gtk.StyleContext.add_provider_for_display(
51 window.get_display(),
52 css,
53 Gtk.STYLE_PROVIDER_PRIORITY_USER + 1
54 )
55 window.add_css_class("main-window")
56
57 # Create puppet
58 model_manager = ModelManager(Live2DDesktopPuppet(), get_wm_interface())
59 server = InteractionServer(model_manager, window)
60 server.set_change_func(changefunc, window)
61 widget = model_manager.get_gtk_widget()
62 # Get monitor resolution
63 dim = model_manager.get_monitor_dimensions()
64 w = dim[0]
65 h = dim[1]
66 window.set_default_size(w, h)
67 window.set_child(widget)
68 window.present()
69
70 # Remove input area until the model reports its visible bounds.
71 surface = window.get_surface()
72 if surface is None:
73 return
74 Gdk.Surface.set_input_region(surface, Region(RectangleInt(0, 0, 0, 0)))
75

Callers

nothing calls this directly

Calls 8

set_change_funcMethod · 0.95
get_gtk_widgetMethod · 0.95
ModelManagerClass · 0.90
Live2DDesktopPuppetClass · 0.90
get_wm_interfaceFunction · 0.90
InteractionServerClass · 0.90

Tested by

no test coverage detected