Skip to content

Commit

Permalink
update tinywl
Browse files Browse the repository at this point in the history
  • Loading branch information
m-col committed Dec 1, 2023
1 parent 5774ae8 commit 3af0da7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
37 changes: 26 additions & 11 deletions tiny/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
Keyboard,
Output,
OutputLayout,
OutputState,
Scene,
SceneBuffer,
SceneNodeType,
SceneOutput,
SceneSurface,
SceneTree,
Seat,
Expand All @@ -51,6 +53,7 @@
if TYPE_CHECKING:
from wlroots.wlr_types import InputDevice
from wlroots.wlr_types.keyboard import KeyboardKeyEvent, KeyboardModifiers
from wlroots.wlr_types.output import OutputEventRequestState

_weakkeydict: WeakKeyDictionary = WeakKeyDictionary()

Expand Down Expand Up @@ -213,7 +216,7 @@ def process_cursor_motion(self, time) -> None:
logging.debug("Processing cursor motion: %s, %s", sx, sy)

if view is None:
self._cursor_manager.set_cursor_image("left_ptr", self._cursor)
self._cursor.set_xcursor(self._cursor_manager, "default")

if surface is None:
# Clear pointer focus so future button events and such are not sent
Expand Down Expand Up @@ -289,8 +292,8 @@ def focus_view(self, view: View, surface: Surface | None = None) -> None:
if previous_surface is not None:
# Deactivate the previously focused surface
logging.info("Un-focusing previous")
previous_xdg_surface = XdgSurface.from_surface(previous_surface)
previous_xdg_surface.set_activated(False)
if previous_xdg_surface := XdgSurface.try_from_surface(previous_surface):
previous_xdg_surface.set_activated(False)

view.scene_node.raise_to_top()
# roll the given surface to the front of the list, copy and modify the
Expand Down Expand Up @@ -322,10 +325,10 @@ def server_new_xdg_surface(self, listener, xdg_surface: XdgSurface) -> None:
# we must provide the proper parent scene node of the xdg popup. To
# enable this, we always set the user data field of xdg_surfaces to
# the corresponding scene node.
parent_xdg_surface = XdgSurface.from_surface(xdg_surface.popup.parent)
parent_scene_tree = cast(SceneTree, parent_xdg_surface.data)
scene_tree = Scene.xdg_surface_create(parent_scene_tree, xdg_surface)
xdg_surface.data = scene_tree
if parent_xdg_surface := XdgSurface.try_from_surface(xdg_surface.popup.parent):
parent_scene_tree = cast(SceneTree, parent_xdg_surface.data)
scene_tree = Scene.xdg_surface_create(parent_scene_tree, xdg_surface)
xdg_surface.data = scene_tree
return

assert xdg_surface.role == XdgSurfaceRole.TOPLEVEL
Expand All @@ -344,16 +347,24 @@ def server_new_xdg_surface(self, listener, xdg_surface: XdgSurface) -> None:
# output and frame handling callbacks

def server_new_output(self, listener, output: Output) -> None:
SceneOutput.create(self._scene, output)
output.init_render(self._allocator, self._renderer)

output.set_mode(output.preferred_mode())
output.enable()
output.commit()
state = OutputState()
state.set_enabled()
if mode := output.preferred_mode():
state.set_mode(mode)

output.commit_state(state)
state.finish()

self.outputs.append(output)
self._output_layout.add_auto(output)
if not self._output_layout.add_auto(output):
logging.warning("Failed to add output to layout.")
return

output.frame_event.add(Listener(self.output_frame))
output.request_state_event.add(Listener(self.output_request_state))

def output_frame(self, listener, data) -> None:
output = self.outputs[0]
Expand All @@ -363,6 +374,10 @@ def output_frame(self, listener, data) -> None:
now = Timespec.get_monotonic_time()
scene_output.send_frame_done(now)

def output_request_state(self, listener, request: OutputEventRequestState) -> None:
output = self.outputs[0]
output.commit_state(request.state)

# #############################################################
# input handling callbacks

Expand Down
4 changes: 2 additions & 2 deletions tiny/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(
self.x = 0.0
self.y = 0.0

xdg_surface.map_event.add(Listener(self.xdg_toplevel_map))
xdg_surface.unmap_event.add(Listener(self.xdg_toplevel_unmap))
xdg_surface.surface.map_event.add(Listener(self.xdg_toplevel_map))
xdg_surface.surface.unmap_event.add(Listener(self.xdg_toplevel_unmap))
xdg_surface.destroy_event.add(Listener(self.xdg_toplevel_destroy))

toplevel = xdg_surface.toplevel
Expand Down

0 comments on commit 3af0da7

Please sign in to comment.