Skip to content

Commit

Permalink
Merge pull request #413 from RedBearAK/dev_beta
Browse files Browse the repository at this point in the history
Fix broken COSMIC window context method
  • Loading branch information
RedBearAK authored Oct 4, 2024
2 parents b103c5d + 150d4d5 commit 43eb372
Show file tree
Hide file tree
Showing 42 changed files with 1,478 additions and 286 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Copyright © 2018 Ilia Bozhinov
# Copyright © 2020 Isaac Freund
# Copytight © 2022 Victoria Brekenfeld
# Copyright © 2024 Victoria Brekenfeld
#
# Permission to use, copy, modify, distribute, and sell this
# software and its documentation for any purpose is hereby granted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Copyright © 2018 Ilia Bozhinov
# Copyright © 2020 Isaac Freund
# Copytight © 2022 Victoria Brekenfeld
# Copyright © 2024 Victoria Brekenfeld
#
# Permission to use, copy, modify, distribute, and sell this
# software and its documentation for any purpose is hereby granted
Expand Down Expand Up @@ -46,20 +46,21 @@ class ZcosmicToplevelHandleV1(Interface):
"""An open toplevel
A :class:`ZcosmicToplevelHandleV1` object represents an open toplevel
window. A single app may have multiple open toplevels.
window. A single app may have multiple open toplevels.
Each toplevel has a list of outputs it is visible on, exposed to the client
via the output_enter and output_leave events.
"""

name = "zcosmic_toplevel_handle_v1"
version = 1
version = 2

class state(enum.IntEnum):
maximized = 0
minimized = 1
activated = 2
fullscreen = 3
sticky = 4


class ZcosmicToplevelHandleV1Proxy(Proxy[ZcosmicToplevelHandleV1]):
Expand All @@ -70,8 +71,7 @@ def destroy(self) -> None:
"""Destroy the :class:`ZcosmicToplevelHandleV1` object
This request should be called either when the client will no longer use
the :class:`ZcosmicToplevelHandleV1` or after the closed event has been
received to allow destruction of the object.
the :class:`ZcosmicToplevelHandleV1`.
"""
self._marshal(0)
self._destroy()
Expand All @@ -89,6 +89,11 @@ def closed(self) -> None:
received aside from the destroy request will be ignored. Upon receiving
this event, the client should make the destroy request to allow freeing
of resources.
Note: This event will not be emitted for clients binding version 2 of
this protocol, as `:func:`ExtForeignToplevelHandleV1.closed()
<pywayland.protocol.ext_foreign_toplevel_list_v1.ExtForeignToplevelHandleV1.closed>``
is equivalent.
"""
self._post_event(0)

Expand All @@ -103,6 +108,11 @@ def done(self) -> None:
to be seen as atomic, even if they happen via multiple events.
Note: this is is not sent after the closed event.
Note: This event will not be emitted for clients binding version 2 of
this protocol, as `:func:`ExtForeignToplevelHandleV1.done()
<pywayland.protocol.ext_foreign_toplevel_list_v1.ExtForeignToplevelHandleV1.done>``
is equivalent.
"""
self._post_event(1)

Expand All @@ -114,6 +124,11 @@ def title(self, title: str) -> None:
This event is emitted whenever the title of the toplevel changes.
Note: This event will not be emitted for clients binding version 2 of
this protocol, as `:func:`ExtForeignToplevelHandleV1.title()
<pywayland.protocol.ext_foreign_toplevel_list_v1.ExtForeignToplevelHandleV1.title>``
is equivalent.
:param title:
:type title:
`ArgumentType.String`
Expand All @@ -128,6 +143,11 @@ def app_id(self, app_id: str) -> None:
This event is emitted whenever the app_id of the toplevel changes.
Note: This event will not be emitted for clients binding version 2 of
this protocol, as `:func:`ExtForeignToplevelHandleV1.app_id()
<pywayland.protocol.ext_foreign_toplevel_list_v1.ExtForeignToplevelHandleV1.app_id>``
is equivalent.
:param app_id:
:type app_id:
`ArgumentType.String`
Expand Down Expand Up @@ -212,6 +232,46 @@ def state(self, state: list) -> None:
"""
self._post_event(8, state)

@ZcosmicToplevelHandleV1.event(
Argument(ArgumentType.Object, interface=WlOutput),
Argument(ArgumentType.Int),
Argument(ArgumentType.Int),
Argument(ArgumentType.Int),
Argument(ArgumentType.Int),
version=2,
)
def geometry(self, output: WlOutput, x: int, y: int, width: int, height: int) -> None:
"""The toplevel's position and/or size has changed
Emitted when the geometry of a toplevel (it's position and/or size)
relative to the provided output has changed.
This event is emitted once on creation of the
:class:`ZcosmicToplevelHandleV1` for every entered output and again
whenever the geometry of the toplevel changes relative to any output.
:param output:
:type output:
:class:`~pywayland.protocol.wayland.WlOutput`
:param x:
x coordinate of the upper-left corner
:type x:
`ArgumentType.Int`
:param y:
y coordinate of the upper-left corner
:type y:
`ArgumentType.Int`
:param width:
width of the toplevel
:type width:
`ArgumentType.Int`
:param height:
height of the toplevel
:type height:
`ArgumentType.Int`
"""
self._post_event(9, output, x, y, width, height)


class ZcosmicToplevelHandleV1Global(Global):
interface = ZcosmicToplevelHandleV1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Copyright © 2018 Ilia Bozhinov
# Copyright © 2020 Isaac Freund
# Copytight © 2022 Victoria Brekenfeld
# Copyright © 2024 Victoria Brekenfeld
#
# Permission to use, copy, modify, distribute, and sell this
# software and its documentation for any purpose is hereby granted
Expand Down Expand Up @@ -36,6 +36,7 @@
Resource,
)

from ..ext_foreign_toplevel_list_v1 import ExtForeignToplevelHandleV1
from .zcosmic_toplevel_handle_v1 import ZcosmicToplevelHandleV1


Expand All @@ -45,16 +46,12 @@ class ZcosmicToplevelInfoV1(Interface):
The purpose of this protocol is to enable clients such as taskbars or docks
to access a list of opened applications and basic properties thereof.
The secondary purpose of this protocol is to provide protocol object
handles for toplevels which may be used to address said toplevels in other
protocols (e.g. to target a toplevel for screencopy).
After a client binds the :class:`ZcosmicToplevelInfoV1`, each opened
toplevel window will be sent via the toplevel event
It thus extends ext_foreign_toplevel_v1 to provide more information and
actions on foreign toplevels.
"""

name = "zcosmic_toplevel_info_v1"
version = 1
version = 2


class ZcosmicToplevelInfoV1Proxy(Proxy[ZcosmicToplevelInfoV1]):
Expand All @@ -69,9 +66,38 @@ def stop(self) -> None:
toplevel_created events until the finished event is emitted.
The client must not send any more requests after this one.
Note: This request isn't necessary for clients binding version 2 of
this protocol and will be ignored.
"""
self._marshal(0)

@ZcosmicToplevelInfoV1.request(
Argument(ArgumentType.NewId, interface=ZcosmicToplevelHandleV1),
Argument(ArgumentType.Object, interface=ExtForeignToplevelHandleV1),
version=2,
)
def get_cosmic_toplevel(self, foreign_toplevel: ExtForeignToplevelHandleV1) -> Proxy[ZcosmicToplevelHandleV1]:
"""Get cosmic toplevel extension object
Request a
:class:`~pywayland.protocol.cosmic_toplevel_info_unstable_v1.ZcosmicToplevelHandleV1`
extension object for an existing
:class:`~pywayland.protocol.ext_foreign_toplevel_list_v1.ExtForeignToplevelHandleV1`.
All initial properties of the toplevel (states, etc.) will be sent
immediately after this event via the corresponding events in
:class:`~pywayland.protocol.cosmic_toplevel_info_unstable_v1.ZcosmicToplevelHandleV1`.
:param foreign_toplevel:
:type foreign_toplevel:
:class:`~pywayland.protocol.ext_foreign_toplevel_list_v1.ExtForeignToplevelHandleV1`
:returns:
:class:`~pywayland.protocol.cosmic_toplevel_info_unstable_v1.ZcosmicToplevelHandleV1`
"""
cosmic_toplevel = self._marshal_constructor(1, ZcosmicToplevelHandleV1, foreign_toplevel)
return cosmic_toplevel


class ZcosmicToplevelInfoV1Resource(Resource):
interface = ZcosmicToplevelInfoV1
Expand All @@ -82,8 +108,12 @@ class ZcosmicToplevelInfoV1Resource(Resource):
def toplevel(self, toplevel: ZcosmicToplevelHandleV1) -> None:
"""A toplevel has been created
This event is emitted whenever a new toplevel window is created. It is
emitted for all toplevels, regardless of the app that has created them.
This event is never emitted for clients binding version 2 of this
protocol, they should use `get_cosmic_toplevel` instead.
This event is emitted for clients binding version 1 whenever a new
toplevel window is created. It is emitted for all toplevels, regardless
of the app that has created them.
All initial properties of the toplevel (title, app_id, states, etc.)
will be sent immediately after this event via the corresponding events
Expand All @@ -104,9 +134,27 @@ def finished(self) -> None:
:class:`ZcosmicToplevelInfoV1`. The server will destroy the object
immediately after sending this request, so it will become invalid and
the client should free any resources associated with it.
Note: This event is emitted immediately after calling `stop` for
clients binding version 2 of this protocol for backwards compatibility.
"""
self._post_event(1)

@ZcosmicToplevelInfoV1.event(version=2)
def done(self) -> None:
"""All information about active toplevels have been sent
This event is sent after all changes for currently active
:class:`~pywayland.protocol.cosmic_toplevel_info_unstable_v1.ZcosmicToplevelHandleV1`
have been sent.
This allows changes to multiple
:class:`~pywayland.protocol.cosmic_toplevel_info_unstable_v1.ZcosmicToplevelHandleV1`
handles and their properties to be seen as atomic, even if they happen
via multiple events.
"""
self._post_event(2)


class ZcosmicToplevelInfoV1Global(Global):
interface = ZcosmicToplevelInfoV1
Expand Down
8 changes: 5 additions & 3 deletions cosmic-dbus-service/protocols/wayland/wl_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ class WlBuffer(Interface):
a client provides and updates the contents is defined by the buffer factory
interface.
If the buffer uses a format that has an alpha channel, the alpha channel is
assumed to be premultiplied in the color channels unless otherwise
specified.
Color channels are assumed to be electrical rather than optical (in other
words, encoded with a transfer function) unless otherwise specified. If the
buffer uses a format that has an alpha channel, the alpha channel is
assumed to be premultiplied into the electrical color channel values (after
transfer function encoding) unless otherwise specified.
Note, because :class:`WlBuffer` objects are created from multiple
independent factory interfaces, the :class:`WlBuffer` interface is frozen
Expand Down
13 changes: 11 additions & 2 deletions cosmic-dbus-service/protocols/wayland/wl_data_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class WlDataDevice(Interface):

class error(enum.IntEnum):
role = 0
used_source = 1


class WlDataDeviceProxy(Proxy[WlDataDevice]):
Expand Down Expand Up @@ -87,8 +88,8 @@ def start_drag(self, source: WlDataSource | None, origin: WlSurface, icon: WlSur
The icon surface is an optional (can be NULL) surface that provides an
icon to be moved around with the cursor. Initially, the top-left
corner of the icon surface is placed at the cursor hotspot, but
subsequent :func:`WlSurface.attach()
<pywayland.protocol.wayland.WlSurface.attach>` request can move the
subsequent :func:`WlSurface.offset()
<pywayland.protocol.wayland.WlSurface.offset>` requests can move the
relative position. Attach requests must be confirmed with
:func:`WlSurface.commit()
<pywayland.protocol.wayland.WlSurface.commit>` as usual. The icon
Expand All @@ -98,6 +99,10 @@ def start_drag(self, source: WlDataSource | None, origin: WlSurface, icon: WlSur
The input region is ignored for wl_surfaces with the role of a drag-
and-drop icon.
The given source may not be used in any further set_selection or
start_drag requests. Attempting to reuse a previously-used source may
send a used_source error.
:param source:
data source for the eventual transfer
:type source:
Expand Down Expand Up @@ -129,6 +134,10 @@ def set_selection(self, source: WlDataSource | None, serial: int) -> None:
To unset the selection, set the source to NULL.
The given source may not be used in any further set_selection or
start_drag requests. Attempting to reuse a previously-used source may
send a used_source error.
:param source:
data source for the selection
:type source:
Expand Down
3 changes: 2 additions & 1 deletion cosmic-dbus-service/protocols/wayland/wl_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def sync(self) -> Proxy[WlCallback]:
after the callback is fired and as such the client must not attempt to
use it after that point.
The callback_data passed in the callback is the event serial.
The callback_data passed in the callback is undefined and should be
ignored.
:returns:
:class:`~pywayland.protocol.wayland.WlCallback` -- callback object
Expand Down
Loading

0 comments on commit 43eb372

Please sign in to comment.