diff options
64 files changed, 2112 insertions, 1548 deletions
diff --git a/src/3rdparty/protocol/README b/src/3rdparty/protocol/README new file mode 100644 index 000000000..d37bad09f --- /dev/null +++ b/src/3rdparty/protocol/README @@ -0,0 +1 @@ +wayland.xml from wayland version defined in qtwayland/README diff --git a/src/3rdparty/protocol/wayland.xml b/src/3rdparty/protocol/wayland.xml new file mode 100644 index 000000000..cc8fb063f --- /dev/null +++ b/src/3rdparty/protocol/wayland.xml @@ -0,0 +1,1332 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="wayland"> + + <copyright> + Copyright © 2008-2011 Kristian Høgsberg + Copyright © 2010-2011 Intel Corporation + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + + <interface name="wl_display" version="1"> + <description summary="core global object"> + The core global object. This is a special singleton object. It + is used for internal Wayland protocol features. + </description> + + <request name="sync"> + <description summary="asynchronous roundtrip"> + The sync request asks the server to emit the 'done' event + on the provided wl_callback object. Since requests are + handled in-order, this can be used as a barrier to ensure all + previous requests have been handled. + </description> + <arg name="callback" type="new_id" interface="wl_callback"/> + </request> + + <request name="get_registry"> + <description summary="get global registry object"> + This request creates a registry object that allows the client + to list and bind the global objects available from the + compositor. + </description> + <arg name="callback" type="new_id" interface="wl_registry"/> + </request> + + <event name="error"> + <description summary="fatal error event"> + The error event is sent out when a fatal (non-recoverable) + error has occurred. The @object_id argument is the object + where the error occurred, most often in response to a request + to that object. The @code identifies the error and is defined + by the object interface. As such, each interface defines its + own set of error codes. The @message is an brief description + of the error, for (debugging) convenience. + </description> + <arg name="object_id" type="object"/> + <arg name="code" type="uint"/> + <arg name="message" type="string"/> + </event> + + <enum name="error"> + <description summary="global error values"> + These errors are global and can be emitted in response to any + server request. + </description> + <entry name="invalid_object" value="0" + summary="server couldn't find object"/> + <entry name="invalid_method" value="1" + summary="method doesn't exist on the specified interface"/> + <entry name="no_memory" value="2" + summary="server is out of memory"/> + </enum> + + <event name="delete_id"> + <description summary="acknowledge object id deletion"> + This event is used internally by the object ID management + logic. When a client deletes an object, the server will send + this event to acknowledge that it has seen the delete request. + When the client receive this event, it will know that it can + safely reuse the object ID + </description> + <arg name="id" type="uint" /> + </event> + </interface> + + <interface name="wl_registry" version="1"> + <description summary="global registry object"> + The global registry object. The server has a number of global + objects that are available to all clients. These objects + typically represent an actual object in the server (for example, + an input device) or they are singleton objects that provides + extension functionality. + + When a client creates a registry object, the registry object + will emit a global event for each global currently in the + registry. Globals come and go as a result of device hotplugs, + reconfiguration or other events, and the registry will send out + @global and @global_remove events to keep the client up to date + with the changes. To mark the end of the initial burst of + events, the client can use the wl_display.sync request + immediately after calling wl_display.get_registry. + + A client can 'bind' to a global object by using the bind + request. This creates a client side handle that lets the object + emit events to the client and lets the client invoke requests on + the object. + </description> + + <request name="bind"> + <description summary="bind an object to the display"> + Binds a new, client-created object to the server using @name as + the identifier. + </description> + <arg name="name" type="uint" summary="unique number id for object"/> + <arg name="id" type="new_id"/> + </request> + + <event name="global"> + <description summary="announce global object"> + Notify the client of global objects. + </description> + <arg name="name" type="uint"/> + <arg name="interface" type="string"/> + <arg name="version" type="uint"/> + </event> + + <event name="global_remove"> + <description summary="announce removal of global object"> + Notify the client of removed global objects. This event + notifies the client that the global identifies by @name is no + longer available. If the client bound to the global using the + 'bind' request, the client should now destroy that object. + The object remains valid and requests to the object will be + ignored until the client destroys it, to avoid races between + the global going away and a client sending a request to it. + </description> + <arg name="name" type="uint"/> + </event> + </interface> + + <interface name="wl_callback" version="1"> + <event name="done"> + <arg name="serial" type="uint"/> + </event> + </interface> + + <interface name="wl_compositor" version="1"> + <description summary="the compositor singleton"> + A compositor. This object is a singleton global. The + compositor is in charge of combining the contents of multiple + surfaces into one displayable output. + </description> + + <request name="create_surface"> + <description summary="create new surface"> + Ask the compositor to create a new surface. + </description> + <arg name="id" type="new_id" interface="wl_surface"/> + </request> + + <request name="create_region"> + <description summary="create new region"> + Ask the compositor to create a new region. + </description> + <arg name="id" type="new_id" interface="wl_region"/> + </request> + </interface> + + <interface name="wl_shm_pool" version="1"> + <description summary="a shared memory pool"> + The wl_shm_pool object encapsulates a piece of memory shared + between the compositor and client. Through the wl_shm_pool + object, the client can allocate shared memory wl_buffer objects. + The objects will share the same underlying mapped memory. + Reusing the mapped memory avoids the setup/teardown overhead and + is useful when interactively resizing a surface or for many + small buffers. + </description> + + <request name="create_buffer"> + <description summary="create wl_buffer from pool"> + Create a wl_buffer from the pool. The buffer is created a + offset bytes into the pool and has width and height as + specified. The stride arguments specifies the number of bytes + from beginning of one row to the beginning of the next. The + format is the pixel format of the buffer and must be one of + those advertised through the wl_shm.format event. + + A buffer will keep a reference to the pool it was created from + so it is valid to destroy the pool immediately after creating + a buffer from it. + </description> + + <arg name="id" type="new_id" interface="wl_buffer"/> + <arg name="offset" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + <arg name="stride" type="int"/> + <arg name="format" type="uint"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the pool"> + Destroy the pool. + </description> + </request> + + <request name="resize"> + <description summary="change the size of the pool mapping"> + This request will cause the server to remap the backing memory + for the pool from the fd passed when the pool was creating but + using the new size. + </description> + + <arg name="size" type="int"/> + </request> + </interface> + + <interface name="wl_shm" version="1"> + <description summary="shared memory support"> + Support for shared memory buffers. + </description> + + <enum name="error"> + <entry name="invalid_format" value="0"/> + <entry name="invalid_stride" value="1"/> + <entry name="invalid_fd" value="2"/> + </enum> + + <enum name="format"> + <entry name="argb8888" value="0"/> + <entry name="xrgb8888" value="1"/> + </enum> + + <request name="create_pool"> + <description summary="create a shm pool"> + This creates wl_shm_pool object, which can be used to create + shared memory based wl_buffer objects. The server will mmap + size bytes of the passed fd, to use as backing memory for then + pool. + </description> + + <arg name="id" type="new_id" interface="wl_shm_pool"/> + <arg name="fd" type="fd"/> + <arg name="size" type="int"/> + </request> + + <event name="format"> + <arg name="format" type="uint"/> + </event> + </interface> + + <interface name="wl_buffer" version="1"> + <description summary="content for a wl_surface"> + A buffer provides the content for a wl_surface. Buffers are + created through factory interfaces such as wl_drm, wl_shm or + similar. It has a width and a height and can be attached to a + wl_surface, but the mechanism by which a client provides and + updates the contents is defined by the buffer factory interface. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy a buffer"> + Destroy a buffer. If and how you need to release the backing + storage is defined by the buffer factory interface. + + For possible side-effects to a surface, see wl_surface.attach. + </description> + </request> + + <event name="release"> + <description summary="compositor releases buffer"> + Sent when this wl_buffer is no longer used by the compositor. + The client is now free to re-use or destroy this buffer and its + backing storage. + + If a client receives a release event before the frame callback + requested in the same wl_surface.commit that attaches this + wl_buffer to a surface, then the client is immediately free to + re-use the buffer and its backing storage, and does not need a + second buffer for the next surface content update. Typically + this is possible, when the compositor maintains a copy of the + wl_surface contents, e.g. as a GL texture. This is an important + optimization for GL(ES) compositors with wl_shm clients. + </description> + </event> + </interface> + + + <interface name="wl_data_offer" version="1"> + <description summary="offer to transfer data"> + A wl_data_offer represents a piece of data offered for transfer + by another client (the source client). It is used by the + copy-and-paste and drag-and-drop mechanisms. The offer + describes the different mime types that the data can be + converted to and provides the mechanism for transferring the + data directly from the source client. + </description> + + <request name="accept"> + <description summary="accept one of the offered mime-types"> + Indicate that the client can accept the given mime-type, or + NULL for not accepted. Use for feedback during drag and drop. + </description> + + <arg name="serial" type="uint"/> + <arg name="type" type="string" allow-null="true"/> + </request> + + <request name="receive"> + <description summary="request that the data is transferred"> + To transfer the offered data, the client issues this request + and indicates the mime-type it wants to receive. The transfer + happens through the passed fd (typically a pipe(7) file + descriptor). The source client writes the data in the + mime-type representation requested and then closes the fd. + The receiving client reads from the read end of the pipe until + EOF and the closes its end, at which point the transfer is + complete. + </description> + <arg name="mime_type" type="string"/> + <arg name="fd" type="fd"/> + </request> + + <request name="destroy" type="destructor"/> + + <event name="offer"> + <description summary="advertise offered mime-type"> + Sent immediately after creating the wl_data_offer object. One + event per offered mime type. + </description> + + <arg name="type" type="string"/> + </event> + </interface> + + <interface name="wl_data_source" version="1"> + <description summary="offer to transfer data"> + The wl_data_source object is the source side of a wl_data_offer. + It is created by the source client in a data transfer and + provides a way to describe the offered data and a way to respond + to requests to transfer the data. + </description> + + <request name="offer"> + <description summary="add an offered mime type"> + This request adds a mime-type to the set of mime-types + advertised to targets. Can be called several times to offer + multiple types. + </description> + <arg name="type" type="string"/> + </request> + + <request name="destroy" type="destructor"> + <description summary="destroy the data source"> + Destroy the data source. + </description> + </request> + + <event name="target"> + <description summary="a target accepts an offered mime-type"> + Sent when a target accepts pointer_focus or motion events. If + a target does not accept any of the offered types, type is NULL. + </description> + + <arg name="mime_type" type="string" allow-null="true"/> + </event> + + <event name="send"> + <description summary="send the data"> + Request for data from another client. Send the data as the + specified mime-type over the passed fd, then close the fd. + </description> + + <arg name="mime_type" type="string"/> + <arg name="fd" type="fd"/> + </event> + + <event name="cancelled"> + <description summary="selection was cancelled"> + This data source has been replaced by another data source. + The client should clean up and destroy this data source. + </description> + </event> + + </interface> + + <interface name="wl_data_device" version="1"> + <request name="start_drag"> + <description summary="start drag and drop operation"> + This request asks the compositor to start a drag and drop + operation on behalf of the client. + + The source argument is the data source that provides the data + for the eventual data transfer. If source is NULL, enter, leave + and motion events are sent only to the client that initiated the + drag and the client is expected to handle the data passing + internally. + + The origin surface is the surface where the drag originates and + the client must have an active implicit grab that matches the + serial. + + The icon surface is an optional (can be nil) 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 wl_surface.attach request can move the + relative position. Attach requests must be confirmed with + wl_surface.commit as usual. + + The current and pending input regions of the icon wl_surface are + cleared, and wl_surface.set_input_region is ignored until the + wl_surface is no longer used as the icon surface. When the use + as an icon ends, the the current and pending input regions + become undefined, and the wl_surface is unmapped. + </description> + <arg name="source" type="object" interface="wl_data_source" allow-null="true"/> + <arg name="origin" type="object" interface="wl_surface"/> + <arg name="icon" type="object" interface="wl_surface" allow-null="true"/> + <arg name="serial" type="uint"/> + </request> + + <request name="set_selection"> + <arg name="source" type="object" interface="wl_data_source" allow-null="true"/> + <arg name="serial" type="uint"/> + </request> + + <event name="data_offer"> + <description summary="introduce a new wl_data_offer"> + The data_offer event introduces a new wl_data_offer object, + which will subsequently be used in either the + data_device.enter event (for drag and drop) or the + data_device.selection event (for selections). Immediately + following the data_device_data_offer event, the new data_offer + object will send out data_offer.offer events to describe the + mime-types it offers. + </description> + + <arg name="id" type="new_id" interface="wl_data_offer"/> + </event> + + <event name="enter"> + <description summary="initiate drag and drop session"> + This event is sent when an active drag-and-drop pointer enters + a surface owned by the client. The position of the pointer at + enter time is provided by the @x an @y arguments, in surface + local coordinates. + </description> + + <arg name="serial" type="uint"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="x" type="fixed"/> + <arg name="y" type="fixed"/> + <arg name="id" type="object" interface="wl_data_offer" allow-null="true"/> + </event> + + <event name="leave"> + <description summary="end drag and drop session"> + This event is sent when the drag-and-drop pointer leaves the + surface and the session ends. The client must destroy the + wl_data_offer introduced at enter time at this point. + </description> + </event> + + <event name="motion"> + <description summary="drag and drop session motion"> + This event is sent when the drag-and-drop pointer moves within + the currently focused surface. The new position of the pointer + is provided by the @x an @y arguments, in surface local + coordinates. + </description> + <arg name="time" type="uint"/> + <arg name="x" type="fixed"/> + <arg name="y" type="fixed"/> + </event> + + <event name="drop"/> + + <event name="selection"> + <description summary="advertise new selection"> + The selection event is sent out to notify the client of a new + wl_data_offer for the selection for this device. The + data_device.data_offer and the data_offer.offer events are + sent out immediately before this event to introduce the data + offer object. The selection event is sent to a client + immediately before receiving keyboard focus and when a new + selection is set while the client has keyboard focus. The + data_offer is valid until a new data_offer or NULL is received + or until the client loses keyboard focus. + </description> + <arg name="id" type="object" interface="wl_data_offer" allow-null="true"/> + </event> + </interface> + + <interface name="wl_data_device_manager" version="1"> + <description summary="data transfer interface"> + The wl_data_device_manager is a a singleton global object that + provides access to inter-client data transfer mechanisms such as + copy and paste and drag and drop. These mechanisms are tied to + a wl_seat and this interface lets a client get a wl_data_device + corresponding to a wl_seat. + </description> + + <request name="create_data_source"> + <arg name="id" type="new_id" interface="wl_data_source"/> + </request> + + <request name="get_data_device"> + <arg name="id" type="new_id" interface="wl_data_device"/> + <arg name="seat" type="object" interface="wl_seat"/> + </request> + </interface> + + <interface name="wl_shell" version="1"> + <request name="get_shell_surface"> + <arg name="id" type="new_id" interface="wl_shell_surface"/> + <arg name="surface" type="object" interface="wl_surface"/> + </request> + </interface> + + <interface name="wl_shell_surface" version="1"> + + <description summary="desktop style meta data interface"> + An interface implemented by a wl_surface. On server side the + object is automatically destroyed when the related wl_surface is + destroyed. On client side, wl_shell_surface_destroy() must be + called before destroying the wl_surface object. + </description> + + <request name="pong"> + <description summary="respond to a ping event"> + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. + </description> + <arg name="serial" type="uint"/> + </request> + + <request name="move"> + <arg name="seat" type="object" interface="wl_seat"/> + <arg name="serial" type="uint"/> + </request> + + <enum name="resize"> + <entry name="none" value="0"/> + <entry name="top" value="1"/> + <entry name="bottom" value="2"/> + <entry name="left" value="4"/> + <entry name="top_left" value="5"/> + <entry name="bottom_left" value="6"/> + <entry name="right" value="8"/> + <entry name="top_right" value="9"/> + <entry name="bottom_right" value="10"/> + </enum> + + <request name="resize"> + <arg name="seat" type="object" interface="wl_seat"/> + <arg name="serial" type="uint"/> + <arg name="edges" type="uint"/> + </request> + + <request name="set_toplevel"> + <description summary="make the surface a top level surface"> + Make the surface a toplevel window. + </description> + </request> + + <enum name="transient"> + <entry name="inactive" value="0x1" summary="do not set keyboard focus"/> + </enum> + + <request name="set_transient"> + <description summary="make the surface a transient surface"> + Map the surface relative to an existing surface. The x and y + arguments specify the locations of the upper left corner of + the surface relative to the upper left corner of the parent + surface. The flags argument controls overflow/clipping + behaviour when the surface would intersect a screen edge, + panel or such. And possibly whether the offset only + determines the initial position or if the surface is locked to + that relative position during moves. + </description> + + <arg name="parent" type="object" interface="wl_surface"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="flags" type="uint"/> + </request> + + <request name="set_fullscreen"> + <description summary="make the surface a fullscreen surface"> + Map the surface as a fullscreen surface. If an output parameter is + given then the surface will be made fullscreen on that output. If the + client does not specify the output then the compositor will apply its + policy - usually choosing the output on which the surface has the + biggest surface area. + + The client may specify a method to resolve a size conflict between the + output size and the surface size - this is provided through the + fullscreen_method parameter. + + The framerate parameter is used only when the fullscreen_method is set + to "driver", to indicate the preferred framerate. framerate=0 indicates + that the app does not care about framerate. The framerate is + specified in mHz, that is framerate of 60000 is 60Hz. + + The compositor must reply to this request with a configure event with + the dimensions for the output on which the surface will be made fullscreen. + </description> + <arg name="method" type="uint"/> + <arg name="framerate" type="uint"/> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + </request> + + <enum name="fullscreen_method"> + <description summary="different method to set the surface fullscreen"> + Hints to indicate compositor how to deal with a conflict between the + dimensions for the surface and the dimensions of the output. As a hint + the compositor is free to ignore this parameter. + + "default" The client has no preference on fullscreen behavior, + policies are determined by compositor. + + "scale" The client prefers scaling by the compositor. Scaling would + always preserve surface's aspect ratio with surface centered on the + output + + "driver" The client wants to switch video mode to the smallest mode + that can fit the client buffer. If the sizes do not match the + compositor must add black borders. + + "fill" The surface is centered on the output on the screen with no + scaling. If the surface is of insufficient size the compositor must + add black borders. + </description> + <entry name="default" value="0"/> + <entry name="scale" value="1"/> + <entry name="driver" value="2"/> + <entry name="fill" value="3"/> + </enum> + + <request name="set_popup"> + <description summary="make the surface a popup surface"> + Popup surfaces. Will switch an implicit grab into + owner-events mode, and grab will continue after the implicit + grab ends (button released). Once the implicit grab is over, + the popup grab continues until the window is destroyed or a + mouse button is pressed in any other clients window. A click + in any of the clients surfaces is reported as normal, however, + clicks in other clients surfaces will be discarded and trigger + the callback. + + TODO: Grab keyboard too, maybe just terminate on any click + inside or outside the surface? + </description> + + <arg name="seat" type="object" interface="wl_seat"/> + <arg name="serial" type="uint"/> + <arg name="parent" type="object" interface="wl_surface"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="flags" type="uint"/> + </request> + + <request name="set_maximized"> + <description summary="make the surface a maximized surface"> + A request from the client to notify the compositor the maximized + operation. The compositor will reply with a configure event telling + the expected new surface size. The operation is completed on the + next buffer attach to this surface. + A maximized client will fill the fullscreen of the output it is bound + to, except the panel area. This is the main difference between + a maximized shell surface and a fullscreen shell surface. + </description> + <arg name="output" type="object" interface="wl_output" allow-null="true"/> + </request> + + <request name="set_title"> + <description summary="set surface title"> + </description> + <arg name="title" type="string"/> + </request> + + <request name="set_class"> + <description summary="set surface class"> + The surface class identifies the general class of applications + to which the surface belongs. The class is the file name of + the applications .desktop file (absolute path if non-standard + location). + </description> + <arg name="class_" type="string"/> + </request> + + <event name="ping"> + <description summary="ping client"> + Ping a client to check if it is receiving events and sending + requests. A client is expected to reply with a pong request. + </description> + <arg name="serial" type="uint"/> + </event> + + <event name="configure"> + <description summary="suggest resize"> + The configure event asks the client to resize its surface. + The size is a hint, in the sense that the client is free to + ignore it if it doesn't resize, pick a smaller size (to + satisfy aspect ratio or resize in steps of NxM pixels). The + client is free to dismiss all but the last configure event it + received. + </description> + + <arg name="edges" type="uint"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </event> + + <event name="popup_done"> + <description summary="popup interaction is done"> + The popup_done event is sent out when a popup grab is broken, + that is, when the users clicks a surface that doesn't belong + to the client owning the popup surface. + </description> + </event> + </interface> + + <interface name="wl_surface" version="1"> + <description summary="an onscreen surface"> + A surface. This is an image that is displayed on the screen. + It has a location, size and pixel contents. + </description> + + <request name="destroy" type="destructor"> + <description summary="delete surface"> + Deletes the surface and invalidates its object id. + </description> + </request> + + <request name="attach"> + <description summary="set the surface contents"> + Set the contents of a buffer into this surface. The x and y + arguments specify the location of the new pending buffer's upper + left corner, relative to the current buffer's upper left corner. In + other words, the x and y, and the width and height of the wl_buffer + together define in which directions the surface's size changes. + + Surface contents are double-buffered state, see wl_surface.commit. + + The initial surface contents are void; there is no content. + wl_surface.attach assigns the given wl_buffer as the pending wl_buffer. + wl_surface.commit applies the pending wl_buffer as the new + surface contents, and the size of the surface becomes the size of + the wl_buffer. The wl_buffer is also kept as pending, until + changed by wl_surface.attach or the wl_buffer is destroyed. + + Committing a pending wl_buffer allows the compositor to read the + pixels in the wl_buffer. The compositor may access the pixels at any + time after the wl_surface.commit request. When the compositor will + not access the pixels anymore, it will send the wl_buffer.release + event. Only after receiving wl_buffer.release, the client may re-use + the wl_buffer. A wl_buffer, that has been attached and then replaced + by another attach instead of committed, will not receive a release + event, and is not used by the compositor. + + Destroying the wl_buffer after wl_buffer.release does not change the + surface contents, even if the wl_buffer is still pending for the + next commit. In such case, the next commit does not change the + surface contents. However, if the client destroys the wl_buffer + before receiving wl_buffer.release, the surface contents become + undefined immediately. + + Only if wl_surface.attach is sent with a nil wl_buffer, the + following wl_surface.commit will remove the surface content. + </description> + + <arg name="buffer" type="object" interface="wl_buffer" allow-null="true"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + </request> + + <request name="damage"> + <description summary="mark part of the surface damaged"> + This request is used to describe the regions where the pending + buffer (or if pending buffer is none, the current buffer as updated + in-place) on the next wl_surface.commit will be different from the + current buffer, and needs to be repainted. The pending buffer can be + set by wl_surface.attach. The compositor ignores the parts of the + damage that fall outside of the surface. + + Damage is double-buffered state, see wl_surface.commit. + + The initial value for pending damage is empty: no damage. + wl_surface.damage adds pending damage: the new pending damage is the + union of old pending damage and the given rectangle. + wl_surface.commit assigns pending damage as the current damage, and + clears pending damage. The server will clear the current damage as + it repaints the surface. + </description> + + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="frame"> + <description summary="request repaint feedback"> + Request notification when the next frame is displayed. Useful + for throttling redrawing operations, and driving animations. + The frame request will take effect on the next wl_surface.commit. + The notification will only be posted for one frame unless + requested again. + + A server should avoid signalling the frame callbacks if the + surface is not visible in any way, e.g. the surface is off-screen, + or completely obscured by other opaque surfaces. + + A client can request a frame callback even without an attach, + damage, or any other state changes. wl_surface.commit triggers a + display update, so the callback event will arrive after the next + output refresh where the surface is visible. + </description> + + <arg name="callback" type="new_id" interface="wl_callback"/> + </request> + + <request name="set_opaque_region"> + <description summary="set opaque region"> + This request sets the region of the surface that contains + opaque content. The opaque region is an optimization hint for + the compositor that lets it optimize out redrawing of content + behind opaque regions. Setting an opaque region is not + required for correct behaviour, but marking transparent + content as opaque will result in repaint artifacts. + The compositor ignores the parts of the opaque region that fall + outside of the surface. + + Opaque region is double-buffered state, see wl_surface.commit. + + wl_surface.set_opaque_region changes the pending opaque region. + wl_surface.commit copies the pending region to the current region. + Otherwise the pending and current regions are never changed. + + The initial value for opaque region is empty. Setting the pending + opaque region has copy semantics, and the wl_region object can be + destroyed immediately. A nil wl_region causes the pending opaque + region to be set to empty. + </description> + + <arg name="region" type="object" interface="wl_region" allow-null="true"/> + </request> + + <request name="set_input_region"> + <description summary="set input region"> + This request sets the region of the surface that can receive + pointer and touch events. Input events happening outside of + this region will try the next surface in the server surface + stack. The compositor ignores the parts of the input region that + fall outside of the surface. + + Input region is double-buffered state, see wl_surface.commit. + + wl_surface.set_input_region changes the pending input region. + wl_surface.commit copies the pending region to the current region. + Otherwise the pending and current regions are never changed, + except cursor and icon surfaces are special cases, see + wl_pointer.set_cursor and wl_data_device.start_drag. + + The initial value for input region is infinite. That means the whole + surface will accept input. Setting the pending input region has copy + semantics, and the wl_region object can be destroyed immediately. A + nil wl_region causes the input region to be set to infinite. + </description> + + <arg name="region" type="object" interface="wl_region" allow-null="true"/> + </request> + + <request name="commit"> + <description summary="commit pending surface state"> + Surface state (input, opaque, and damage regions, attached buffers, + etc.) is double-buffered. Protocol requests modify the pending + state, as opposed to current state in use by the compositor. Commit + request atomically applies all pending state, replacing the current + state. After commit, the new pending state is as documented for each + related request. + + On commit, a pending wl_buffer is applied first, all other state + second. This means that all coordinates in double-buffered state are + relative to the new wl_buffer coming into use, except for + wl_surface.attach itself. If the pending wl_buffer is none, the + coordinates are relative to the current surface contents. + + All requests that need a commit to become effective are documented + to affect double-buffered state. + + Other interfaces may add further double-buffered surface state. + </description> + </request> + + <event name="enter"> + <description summary="surface enters an output"> + This is emitted whenever a surface's creation, movement, or resizing + results in some part of it being within the scanout region of an + output. + </description> + <arg name="output" type="object" interface="wl_output"/> + </event> + + <event name="leave"> + <description summary="surface leaves an output"> + This is emitted whenever a surface's creation, movement, or resizing + results in it no longer having any part of it within the scanout region + of an output. + </description> + <arg name="output" type="object" interface="wl_output"/> + </event> + </interface> + + <interface name="wl_seat" version="1"> + <description summary="seat"> + A group of keyboards, pointer (mice, for example) and touch + devices . This object is published as a global during start up, + or when such a device is hot plugged. A seat typically has a + pointer and maintains a keyboard_focus and a pointer_focus. + </description> + + <enum name="capability"> + <description summary="seat capability bitmask"> + This is a bitmask of capabilities this seat has; if a member is + set, then it is present on the seat. + </description> + <entry name="pointer" value="1" summary="wl_pointer"/> + <entry name="keyboard" value="2" summary="wl_keyboard"/> + <entry name="touch" value="4" summary="wl_touch"/> + </enum> + + + <event name="capabilities"> + <description summary="seat capabilities changed"> + This is emitted whenever a seat gains or loses the pointer, + keyboard or touch capabilities. The argument is a wl_seat_caps_mask + enum containing the complete set of capabilities this seat has. + </description> + <arg name="capabilities" type="uint"/> + </event> + + <request name="get_pointer"> + <description summary="return pointer object"> + The ID provided will be initialized to the wl_pointer interface + for this seat. + </description> + <arg name="id" type="new_id" interface="wl_pointer"/> + </request> + + <request name="get_keyboard"> + <description summary="return pointer object"> + The ID provided will be initialized to the wl_keyboard interface + for this seat. + </description> + <arg name="id" type="new_id" interface="wl_keyboard"/> + </request> + + <request name="get_touch"> + <description summary="return pointer object"> + The ID provided will be initialized to the wl_touch interface + for this seat. + </description> + <arg name="id" type="new_id" interface="wl_touch"/> + </request> + </interface> + + <interface name="wl_pointer" version="1"> + <request name="set_cursor"> + <description summary="set the pointer surface"> + Set the pointer surface, i.e., the surface that contains the + pointer image (cursor). This request only takes effect if the pointer + focus for this device is one of the requesting client's surfaces + or the surface parameter is the current pointer surface. If + there was a previous surface set with this request it is + replaced. If surface is NULL, the pointer image is hidden. + + The parameters hotspot_x and hotspot_y define the position of + the pointer surface relative to the pointer location. Its + top-left corner is always at (x, y) - (hotspot_x, hotspot_y), + where (x, y) are the coordinates of the pointer location. + + On surface.attach requests to the pointer surface, hotspot_x + and hotspot_y are decremented by the x and y parameters + passed to the request. Attach must be confirmed by + wl_surface.commit as usual. + + The hotspot can also be updated by passing the currently set + pointer surface to this request with new values for hotspot_x + and hotspot_y. + + The current and pending input regions of the wl_surface are + cleared, and wl_surface.set_input_region is ignored until the + wl_surface is no longer used as the cursor. When the use as a + cursor ends, the current and pending input regions become + undefined, and the wl_surface is unmapped. + </description> + + <arg name="serial" type="uint"/> + <arg name="surface" type="object" interface="wl_surface" allow-null="true"/> + <arg name="hotspot_x" type="int"/> + <arg name="hotspot_y" type="int"/> + </request> + + <event name="enter"> + <description summary="enter event"> + Notification that this seat's pointer is focused on a certain + surface. When an seat's focus enters a surface, the pointer image + is undefined and a client should respond to this event by setting + an appropriate pointer image. + </description> + + <arg name="serial" type="uint"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="surface_x" type="fixed"/> + <arg name="surface_y" type="fixed"/> + </event> + + <event name="leave"> + <description summary="leave event"> + </description> + <arg name="serial" type="uint"/> + <arg name="surface" type="object" interface="wl_surface"/> + </event> + + <event name="motion"> + <description summary="pointer motion event"> + Notification of pointer location change. The arguments surface_[xy] + are the location relative to the focused surface. + </description> + + <arg name="time" type="uint"/> + <arg name="surface_x" type="fixed"/> + <arg name="surface_y" type="fixed"/> + </event> + + <enum name="button_state"> + <description summary="physical button state"> + Describes the physical state of a button which provoked the button + event. + </description> + <entry name="released" value="0" summary="button is not pressed"/> + <entry name="pressed" value="1" summary="button is pressed"/> + </enum> + + <event name="button"> + <description summary="pointer button event"> + Mouse button click and release notifications. The location + of the click is given by the last motion or pointer_focus event. + </description> + + <arg name="serial" type="uint"/> + <arg name="time" type="uint"/> + <arg name="button" type="uint"/> + <arg name="state" type="uint"/> + </event> + + <enum name="axis"> + <description summary="axis types"/> + <entry name="vertical_scroll" value="0"/> + <entry name="horizontal_scroll" value="1"/> + </enum> + + <event name="axis"> + <description summary="axis event"> + Scroll and other axis notifications. + + For scroll events (vertical and horizontal scroll axes), the + value parameter is the length of a vector along the specified + axis in a coordinate space identical to those of motion events, + representing a relative movement along the specified axis. + + For devices that support movements non-parallel to axes multiple + axis events will be emitted. + + When applicable, for example for touch pads, the server can + choose to emit scroll events where the motion vector is + equivalent to a motion event vector. + + When applicable, clients can transform its view relative to the + scroll distance. + </description> + + <arg name="time" type="uint"/> + <arg name="axis" type="uint"/> + <arg name="value" type="fixed"/> + </event> + </interface> + + <interface name="wl_keyboard" version="1"> + <description summary="keyboard input device"> + </description> + + <enum name="keymap_format"> + <description summary="keyboard mapping format"> + This enum specifies the format of the keymap provided to the client + with the wl_keyboard::keymap event. + </description> + <entry name="xkb_v1" value="1" description="libxkbcommon compatible"/> + </enum> + + <event name="keymap"> + <description summary="keyboard mapping"> + This event provides a file descriptor to the client which can be + memory-mapped to provide a keyboard mapping description. + </description> + <arg name="format" type="uint"/> + <arg name="fd" type="fd"/> + <arg name="size" type="uint"/> + </event> + + <event name="enter"> + <arg name="serial" type="uint"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="keys" type="array"/> + </event> + + <event name="leave"> + <arg name="serial" type="uint"/> + <arg name="surface" type="object" interface="wl_surface"/> + </event> + + <enum name="key_state"> + <description summary="physical key state"> + Describes the physical state of a key which provoked the key event. + </description> + <entry name="released" value="0" summary="key is not pressed"/> + <entry name="pressed" value="1" summary="key is pressed"/> + </enum> + + <event name="key"> + <description summary="key event"> + A key was pressed or released. + </description> + + <arg name="serial" type="uint"/> + <arg name="time" type="uint"/> + <arg name="key" type="uint"/> + <arg name="state" type="uint"/> + </event> + + <event name="modifiers"> + <description summary="modifier and group state"> + Notifies clients that the modifier and/or group state has + changed, and it should update its local state. + </description> + + <arg name="serial" type="uint"/> + <arg name="mods_depressed" type="uint"/> + <arg name="mods_latched" type="uint"/> + <arg name="mods_locked" type="uint"/> + <arg name="group" type="uint"/> + </event> + </interface> + + <interface name="wl_touch" version="1"> + <description summary="touch screen input device"> + </description> + + <event name="down"> + <arg name="serial" type="uint"/> + <arg name="time" type="uint"/> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="id" type="int" /> + <arg name="x" type="fixed" /> + <arg name="y" type="fixed" /> + </event> + + <event name="up"> + <arg name="serial" type="uint"/> + <arg name="time" type="uint"/> + <arg name="id" type="int" /> + </event> + + <event name="motion"> + <arg name="time" type="uint"/> + <arg name="id" type="int" /> + <arg name="x" type="fixed" /> + <arg name="y" type="fixed" /> + </event> + + <event name="frame"> + <description summary="end of touch frame event"> + Indicates the end of a contact point list. + </description> + </event> + + <event name="cancel"> + <description summary="touch session cancelled"> + Sent if the compositor decides the touch stream is a global + gesture. No further events are sent to the clients from that + particular gesture. + </description> + </event> + </interface> + + + <interface name="wl_output" version="1"> + <description summary="compositor output region"> + An output describes part of the compositor geometry. The + compositor work in the 'compositor coordinate system' and an + output corresponds to rectangular area in that space that is + actually visible. This typically corresponds to a monitor that + displays part of the compositor space. This object is published + as global during start up, or when a screen is hot plugged. + </description> + + <enum name="subpixel"> + <entry name="unknown" value="0"/> + <entry name="none" value="1"/> + <entry name="horizontal_rgb" value="2"/> + <entry name="horizontal_bgr" value="3"/> + <entry name="vertical_rgb" value="4"/> + <entry name="vertical_bgr" value="5"/> + </enum> + + <enum name="transform"> + <description summary="transform from framebuffer to output"> + This describes the transform that a compositor will apply to a + surface to compensate for the rotation or mirroring of an + output device. + + The flipped values correspond to an initial flip around a + vertical axis followed by rotation. + + The purpose is mainly to allow clients render accordingly and + tell the compositor, so that for fullscreen surfaces, the + compositor will still be able to scan out directly from client + surfaces. + </description> + + <entry name="normal" value="0"/> + <entry name="90" value="1"/> + <entry name="180" value="2"/> + <entry name="270" value="3"/> + <entry name="flipped" value="4"/> + <entry name="flipped_90" value="5"/> + <entry name="flipped_180" value="6"/> + <entry name="flipped_270" value="7"/> + </enum> + + <event name="geometry"> + <description summary="properties of the output"/> + <arg name="x" type="int" + summary="x position within the global compositor space"/> + <arg name="y" type="int" + summary="y position within the global compositor space"/> + <arg name="physical_width" type="int" + summary="width in millimeters of the output"/> + <arg name="physical_height" type="int" + summary="height in millimeters of the output"/> + <arg name="subpixel" type="int" + summary="subpixel orientation of the output"/> + <arg name="make" type="string" + summary="textual description of the manufacturer"/> + <arg name="model" type="string" + summary="textual description of the model"/> + <arg name="transform" type="int" + summary="transform that maps framebuffer to output"/> + </event> + + <enum name="mode"> + <description summary="values for the flags bitfield in the mode event"/> + <entry name="current" value="0x1" + summary="indicates this is the current mode"/> + <entry name="preferred" value="0x2" + summary="indicates this is the preferred mode"/> + </enum> + + <event name="mode"> + <description summary="advertise available modes for the output"> + The mode event describes an available mode for the output. + The event is sent when binding to the output object and there + will always be one mode, the current mode. The event is sent + again if an output changes mode, for the mode that is now + current. In other words, the current mode is always the last + mode that was received with the current flag set. + </description> + <arg name="flags" type="uint" summary="mask of wl_output_mode flags"/> + <arg name="width" type="int" summary="width of the mode in pixels"/> + <arg name="height" type="int" summary="height of the mode in pixels"/> + <arg name="refresh" type="int" summary="vertical refresh rate in mHz"/> + </event> + </interface> + + <interface name="wl_region" version="1"> + <description summary="region interface"> + Region. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy region"> + Destroy the region. This will invalidate the object id. + </description> + </request> + + <request name="add"> + <description summary="add rectangle to region"> + Add the specified rectangle to the region + </description> + + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + <request name="subtract"> + <description summary="subtract rectangle from region"> + Subtract the specified rectangle from the region + </description> + + <arg name="x" type="int"/> + <arg name="y" type="int"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + </request> + + </interface> + +</protocol> diff --git a/src/compositor/global/qwaylandresourcecollection.cpp b/src/compositor/global/qwaylandresourcecollection.cpp index 6433474a3..cc20e628f 100644 --- a/src/compositor/global/qwaylandresourcecollection.cpp +++ b/src/compositor/global/qwaylandresourcecollection.cpp @@ -46,6 +46,17 @@ QT_BEGIN_NAMESPACE namespace QtWayland { +struct wl_resource *resourceForClient(const struct wl_list *list, struct wl_client *client) +{ + struct wl_resource *resource; + wl_list_for_each(resource, list, link) { + if (resource->client == client) { + return resource; + } + } + return 0; +} + ResourceCollection::ResourceCollection() { wl_list_init(&client_resources); @@ -66,14 +77,7 @@ void ResourceCollection::registerResource(struct wl_resource *resource) struct wl_resource *ResourceCollection::resourceForClient(wl_client *client) const { - struct wl_resource *resource; - wl_list_for_each(resource,&client_resources, link) { - if (resource->client == client) { - return resource; - } - } - return 0; - + return QtWayland::resourceForClient(&client_resources, client); } bool ResourceCollection::resourceListIsEmpty() const diff --git a/src/compositor/global/qwaylandresourcecollection.h b/src/compositor/global/qwaylandresourcecollection.h index cfc1c32cb..61df0f1d7 100644 --- a/src/compositor/global/qwaylandresourcecollection.h +++ b/src/compositor/global/qwaylandresourcecollection.h @@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE namespace QtWayland { +struct wl_resource *resourceForClient(const struct wl_list *list, struct wl_client *client); + class ResourceCollection { public: diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp index 26defc0ba..ee7fe796b 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor.cpp +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -176,8 +176,7 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor) wl_display_init_shm(m_display->handle()); - m_output_global = new OutputGlobal(); - wl_display_add_global(m_display->handle(),&wl_output_interface, m_output_global, OutputGlobal::output_bind_func); + m_output_global = new OutputGlobal(m_display->handle()); m_shell = new Shell(); wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func); @@ -426,8 +425,8 @@ Qt::ScreenOrientations Compositor::orientationUpdateMaskForClient(wl_client *cli { Output *output = m_output_global->outputForClient(client); Q_ASSERT(output); - if (output->extendedOutput()) - return output->extendedOutput()->orientationUpdateMask(); + if (output->extendedOutput) + return output->extendedOutput->orientationUpdateMask; return 0; } @@ -440,9 +439,8 @@ void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation) struct wl_client *client = clientList.at(i); Output *output = m_output_global->outputForClient(client); Q_ASSERT(output); - if (output->extendedOutput()){ - output->extendedOutput()->sendOutputOrientation(orientation); - } + if (output->extendedOutput) + output->extendedOutput->sendOutputOrientation(orientation); } } diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp index f89dbc314..03baa16bd 100644 --- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp @@ -208,7 +208,7 @@ void DataDeviceManager::get_data_device(struct wl_client *client, struct wl_resource *input_device_resource) { DataDeviceManager *data_device_manager = static_cast<DataDeviceManager *>(data_device_manager_resource->data); - InputDevice *input_device = resolve<InputDevice>(input_device_resource); + InputDevice *input_device = InputDevice::fromSeatResource(input_device_resource); input_device->clientRequestedDataDevice(data_device_manager,client,id); } diff --git a/src/compositor/wayland_wrapper/qwlextendedoutput.cpp b/src/compositor/wayland_wrapper/qwlextendedoutput.cpp index 8249f2721..6c53afe0d 100644 --- a/src/compositor/wayland_wrapper/qwlextendedoutput.cpp +++ b/src/compositor/wayland_wrapper/qwlextendedoutput.cpp @@ -49,58 +49,29 @@ QT_BEGIN_NAMESPACE namespace QtWayland { OutputExtensionGlobal::OutputExtensionGlobal(Compositor *compositor) - : m_compositor(compositor) -{ - wl_display_add_global(compositor->wl_display(), - &wl_output_extension_interface, - this, - OutputExtensionGlobal::bind_func); -} - -void OutputExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) + : QtWaylandServer::wl_output_extension(compositor->wl_display()) + , m_compositor(compositor) { - Q_UNUSED(version); - wl_client_add_object(client,&wl_output_extension_interface,&output_extension_interface,id,data); } -void OutputExtensionGlobal::get_extended_output(wl_client *client, wl_resource *output_extension_resource, uint32_t id, wl_resource *output_resource) +void OutputExtensionGlobal::output_extension_get_extended_output(wl_output_extension::Resource *resource, uint32_t id, wl_resource *output_resource) { - OutputExtensionGlobal *output_extension = static_cast<OutputExtensionGlobal *>(output_extension_resource->data); - Output *output = static_cast<Output *>(output_resource->data); - new ExtendedOutput(client,id,output,output_extension->m_compositor); -} + Output *output = static_cast<Output *>(OutputGlobal::Resource::fromResource(output_resource)); + Q_ASSERT(output->extendedOutput == 0); -const struct wl_output_extension_interface OutputExtensionGlobal::output_extension_interface = { - OutputExtensionGlobal::get_extended_output -}; + ExtendedOutput *extendedOutput = static_cast<ExtendedOutput *>(wl_extended_output::add(resource->client(), id)); -ExtendedOutput::ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor) - : m_output(output) - , m_compositor(compositor) -{ - static const struct wl_extended_output_interface extended_output_interface = { - set_orientation_update_mask - }; - Q_ASSERT(m_output->extendedOutput() == 0); - m_output->setExtendedOutput(this); - m_extended_output_resource = wl_client_add_object(client,&wl_extended_output_interface,&extended_output_interface,id,this); - m_extended_output_resource->destroy = ExtendedOutput::destroy_resource; - - sendOutputOrientation(m_compositor->screenOrientation()); -} + Q_ASSERT(!output->extendedOutput); + output->extendedOutput = extendedOutput; + extendedOutput->output = output; -void ExtendedOutput::destroy_resource(wl_resource *resource) -{ - ExtendedOutput *output = static_cast<ExtendedOutput *>(resource->data); - delete output; - free(resource); + extendedOutput->sendOutputOrientation(m_compositor->screenOrientation()); } -void ExtendedOutput::set_orientation_update_mask(struct wl_client *client, - struct wl_resource *resource, - int32_t orientation_update_mask) +void OutputExtensionGlobal::extended_output_set_orientation_update_mask(wl_extended_output::Resource *resource, + int32_t orientation_update_mask) { - ExtendedOutput *output = static_cast<ExtendedOutput *>(resource->data); + ExtendedOutput *output = static_cast<ExtendedOutput *>(resource); Qt::ScreenOrientations mask = 0; if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION) @@ -112,11 +83,11 @@ void ExtendedOutput::set_orientation_update_mask(struct wl_client *client, if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION) mask |= Qt::InvertedLandscapeOrientation; - Qt::ScreenOrientations oldMask = output->m_orientationUpdateMask; - output->m_orientationUpdateMask = mask; + Qt::ScreenOrientations oldMask = output->orientationUpdateMask; + output->orientationUpdateMask = mask; if (mask != oldMask) { - QList<Surface*> surfaces = output->m_compositor->surfacesForClient(client); + QList<Surface*> surfaces = m_compositor->surfacesForClient(resource->client()); foreach (Surface *surface, surfaces) { if (surface->waylandSurface()) emit surface->waylandSurface()->orientationUpdateMaskChanged(); @@ -126,24 +97,25 @@ void ExtendedOutput::set_orientation_update_mask(struct wl_client *client, void ExtendedOutput::sendOutputOrientation(Qt::ScreenOrientation orientation) { - int sendOpperation; + int sendOperation; switch (orientation) { case Qt::PortraitOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; + sendOperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; break; case Qt::LandscapeOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION; + sendOperation = WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION; break; case Qt::InvertedPortraitOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION; + sendOperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION; break; case Qt::InvertedLandscapeOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION; + sendOperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION; break; default: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; + sendOperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; } - wl_extended_output_send_set_screen_rotation(m_extended_output_resource, sendOpperation); + + extended_output->send_set_screen_rotation(handle, sendOperation); } } diff --git a/src/compositor/wayland_wrapper/qwlextendedoutput_p.h b/src/compositor/wayland_wrapper/qwlextendedoutput_p.h index 46c56beb8..3bc418e90 100644 --- a/src/compositor/wayland_wrapper/qwlextendedoutput_p.h +++ b/src/compositor/wayland_wrapper/qwlextendedoutput_p.h @@ -42,12 +42,13 @@ #define WLEXTENDEDOUTPUT_H #include "wayland-server.h" -#include "wayland-output-extension-server-protocol.h" #include <QtCompositor/qwaylandexport.h> #include <QtCore/qnamespace.h> +#include <qwayland-server-output-extension.h> + QT_BEGIN_NAMESPACE namespace QtWayland { @@ -55,46 +56,36 @@ namespace QtWayland { class Compositor; class Output; -class OutputExtensionGlobal +class ExtendedOutput : public QtWaylandServer::wl_extended_output::Resource { public: - OutputExtensionGlobal(Compositor *compositor); + ExtendedOutput() : output(0) {} -private: - Compositor *m_compositor; - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void get_extended_output(struct wl_client *client, - struct wl_resource *output_extension_resource, - uint32_t id, - struct wl_resource *output_resource); - static const struct wl_output_extension_interface output_extension_interface; + void sendOutputOrientation(Qt::ScreenOrientation orientation); + Output *output; + Qt::ScreenOrientations orientationUpdateMask; }; -class ExtendedOutput +class OutputExtensionGlobal : public QtWaylandServer::wl_output_extension, public QtWaylandServer::wl_extended_output { public: - ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor); - - Qt::ScreenOrientations orientationUpdateMask() { return m_orientationUpdateMask; } + OutputExtensionGlobal(Compositor *compositor); - void sendOutputOrientation(Qt::ScreenOrientation orientation); +private: + Compositor *m_compositor; - static void destroy_resource(wl_resource *resource); + wl_extended_output::Resource *extended_output_allocate() Q_DECL_OVERRIDE { return new ExtendedOutput; } - static void set_orientation_update_mask(struct wl_client *client, - struct wl_resource *resource, - int32_t orientation_update_mask); + void extended_output_set_orientation_update_mask(wl_extended_output::Resource *resource, + int32_t orientation_update_mask) Q_DECL_OVERRIDE; -private: - struct wl_resource *m_extended_output_resource; - Output *m_output; - Compositor *m_compositor; - Qt::ScreenOrientations m_orientationUpdateMask; + void output_extension_get_extended_output(wl_output_extension::Resource *resource, + uint32_t id, + struct wl_resource *output_resource) Q_DECL_OVERRIDE; }; + } QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlinputdevice.cpp b/src/compositor/wayland_wrapper/qwlinputdevice.cpp index 8591de254..eba2caf5b 100644 --- a/src/compositor/wayland_wrapper/qwlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/qwlinputdevice.cpp @@ -65,15 +65,12 @@ QT_BEGIN_NAMESPACE namespace QtWayland { InputDevice::InputDevice(QWaylandInputDevice *handle, Compositor *compositor) - : m_handle(handle) + : QtWaylandServer::wl_seat(compositor->wl_display()) + , m_handle(handle) , m_compositor(compositor) { - wl_seat_init(base()); + wl_seat_init(&m_seat); initDevices(); - wl_display_add_global(compositor->wl_display(), - &wl_seat_interface, - this, - InputDevice::bind_func); #ifndef QT_NO_WAYLAND_XKB xkb_rule_names xkb_names; @@ -150,13 +147,13 @@ InputDevice::~InputDevice() void InputDevice::initDevices() { wl_pointer_init(&m_device_interfaces.pointer); - wl_seat_set_pointer(base(), &m_device_interfaces.pointer); + wl_seat_set_pointer(&m_seat, &m_device_interfaces.pointer); wl_keyboard_init(&m_device_interfaces.keyboard); - wl_seat_set_keyboard(base(), &m_device_interfaces.keyboard); + wl_seat_set_keyboard(&m_seat, &m_device_interfaces.keyboard); wl_touch_init(&m_device_interfaces.touch); - wl_seat_set_touch(base(), &m_device_interfaces.touch); + wl_seat_set_touch(&m_seat, &m_device_interfaces.touch); } void InputDevice::releaseDevices() @@ -196,129 +193,71 @@ const wl_touch *InputDevice::touchDevice() const return &m_device_interfaces.touch; } -void InputDevice::destroy_resource(wl_resource *resource) +void InputDevice::seat_destroy_resource(wl_seat::Resource *resource) { - InputDevice *input_device = static_cast<InputDevice *>(resource->data); - if (input_device->keyboardDevice()->focus_resource == resource) { - input_device->keyboardDevice()->focus_resource = 0; - } - if (input_device->pointerDevice()->focus_resource == resource) { - input_device->pointerDevice()->focus_resource = 0; - } + if (keyboardDevice()->focus_resource == resource->handle) + keyboardDevice()->focus_resource = 0; - input_device->cleanupDataDeviceForClient(resource->client, true); + if (pointerDevice()->focus_resource == resource->handle) + pointerDevice()->focus_resource = 0; - wl_list_remove(&resource->link); - - free(resource); + cleanupDataDeviceForClient(resource->client(), true); } -void InputDevice::bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) +void InputDevice::seat_bind_resource(wl_seat::Resource *resource) { - Q_UNUSED(version); - struct wl_resource *resource = wl_client_add_object(client, - &wl_seat_interface, - &seat_interface, - id, - data); - - struct wl_seat *seat = static_cast<struct wl_seat *>(data); - resource->destroy = destroy_resource; - wl_list_insert(&seat->base_resource_list, &resource->link); + wl_list_insert(&m_seat.base_resource_list, &resource->handle->link); uint32_t caps = WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD; if (!QTouchDevice::devices().isEmpty()) caps |= WL_SEAT_CAPABILITY_TOUCH; - wl_seat_send_capabilities(resource, caps); + wl_seat::send_capabilities(resource->handle, caps); } -const struct wl_pointer_interface InputDevice::pointer_interface = { - InputDevice::set_cursor -}; - -void InputDevice::set_cursor(wl_client *client, wl_resource *resource, - uint32_t serial, wl_resource *surface_resource, - int32_t hotspot_x, int32_t hotspot_y) +void InputDevice::pointer_set_cursor(wl_pointer::Resource *resource, + uint32_t serial, wl_resource *surface_resource, + int32_t hotspot_x, int32_t hotspot_y) { - Q_UNUSED(client); + Q_UNUSED(resource); Q_UNUSED(serial); - wl_pointer *pointer = reinterpret_cast<wl_pointer *>(resource->data); - InputDevice *inputDevice = wayland_cast<InputDevice>(pointer->seat); QtWayland::Surface *surface = reinterpret_cast<QtWayland::Surface *>(surface_resource->data); surface->setCursorSurface(true); - inputDevice->m_compositor->waylandCompositor()->setCursorSurface(surface->waylandSurface(), hotspot_x, hotspot_y); + m_compositor->waylandCompositor()->setCursorSurface(surface->waylandSurface(), hotspot_x, hotspot_y); } -const struct wl_seat_interface InputDevice::seat_interface = { - get_pointer, - get_keyboard, - get_touch -}; - -void InputDevice::destroy_device_resource(wl_resource *resource) +void InputDevice::seat_get_pointer(wl_seat::Resource *resource, uint32_t id) { - wl_list_remove(&resource->link); - free(resource); + ::wl_pointer *pointer = pointerDevice(); + wl_pointer::add(&pointer->resource_list, resource->client(), id); } -void InputDevice::get_pointer(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) +void InputDevice::seat_get_keyboard(wl_seat::Resource *resource, uint32_t id) { - InputDevice *inputDevice = static_cast<InputDevice *>(resource->data); - wl_pointer *pointer = inputDevice->pointerDevice(); - wl_resource *clientResource = wl_client_add_object(client, - &wl_pointer_interface, - &pointer_interface, - id, - pointer); - wl_list_insert(&pointer->resource_list, &clientResource->link); - clientResource->destroy = InputDevice::destroy_device_resource; + ::wl_keyboard *keyboard = keyboardDevice(); + wl_keyboard::add(&keyboard->resource_list, resource->client(), id); } -void InputDevice::get_keyboard(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) +void InputDevice::keyboard_bind_resource(wl_keyboard::Resource *resource) { - InputDevice *inputDevice = static_cast<InputDevice *>(resource->data); - wl_keyboard *keyboard = inputDevice->keyboardDevice(); - wl_resource *clientResource = wl_client_add_object(client, - &wl_keyboard_interface, - 0, - id, - keyboard); - wl_list_insert(&keyboard->resource_list, &clientResource->link); - clientResource->destroy = InputDevice::destroy_device_resource; - #ifndef QT_NO_WAYLAND_XKB - wl_keyboard_send_keymap(clientResource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - inputDevice->m_keymap_fd, inputDevice->m_keymap_size); + wl_keyboard::send_keymap(resource->handle, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + m_keymap_fd, m_keymap_size); #endif } -void InputDevice::get_touch(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) +void InputDevice::seat_get_touch(wl_seat::Resource *resource, uint32_t id) { - InputDevice *inputDevice = static_cast<InputDevice *>(resource->data); - wl_touch *touch = inputDevice->touchDevice(); - wl_resource *clientResource = wl_client_add_object(client, - &wl_touch_interface, - 0, - id, - touch); - wl_list_insert(&touch->resource_list, &clientResource->link); - clientResource->destroy = InputDevice::destroy_device_resource; + ::wl_touch *touch = touchDevice(); + wl_touch::add(&touch->resource_list, resource->client(), id); } void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) { sendMouseMoveEvent(localPos,globalPos); - wl_pointer *pointer = pointerDevice(); + ::wl_pointer *pointer = pointerDevice(); pointer->button_count++; uint32_t time = m_compositor->currentTimeMsecs(); const struct wl_pointer_grab_interface *interface = pointer->grab->interface; @@ -328,7 +267,7 @@ void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &loc void InputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) { sendMouseMoveEvent(localPos,globalPos); - wl_pointer *pointer = pointerDevice(); + ::wl_pointer *pointer = pointerDevice(); pointer->button_count--; uint32_t time = m_compositor->currentTimeMsecs(); const struct wl_pointer_grab_interface *interface = pointer->grab->interface; @@ -339,7 +278,7 @@ void InputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &glo { Q_UNUSED(globalPos); uint32_t time = m_compositor->currentTimeMsecs(); - wl_pointer *pointer = pointerDevice(); + ::wl_pointer *pointer = pointerDevice(); const struct wl_pointer_grab_interface *interface = pointer->grab->interface; pointer->x = wl_fixed_from_double(globalPos.x()); pointer->y = wl_fixed_from_double(globalPos.y()); @@ -356,7 +295,7 @@ void InputDevice::sendMouseMoveEvent(Surface *surface, const QPointF &localPos, void InputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta) { - wl_pointer *pointer = pointerDevice(); + ::wl_pointer *pointer = pointerDevice(); struct wl_resource *resource = pointer->focus_resource; if (!resource) return; @@ -376,7 +315,7 @@ void InputDevice::updateModifierState(uint code, int state) uint32_t mods_locked = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); uint32_t group = xkb_state_serialize_group(m_state, (xkb_state_component)XKB_STATE_EFFECTIVE); - wl_keyboard *keyboard = keyboardDevice(); + ::wl_keyboard *keyboard = keyboardDevice(); if (mods_depressed == keyboard->modifiers.mods_depressed && mods_latched == keyboard->modifiers.mods_latched @@ -401,7 +340,7 @@ void InputDevice::updateModifierState(uint code, int state) void InputDevice::sendKeyModifiers(wl_resource *resource) { - wl_keyboard *keyboard = keyboardDevice(); + ::wl_keyboard *keyboard = keyboardDevice(); uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); wl_keyboard_send_modifiers(resource, serial, keyboard->modifiers.mods_depressed, keyboard->modifiers.mods_latched, keyboard->modifiers.mods_locked, keyboard->modifiers.group); @@ -409,7 +348,7 @@ void InputDevice::sendKeyModifiers(wl_resource *resource) void InputDevice::sendKeyPressEvent(uint code) { - wl_keyboard *keyboard = keyboardDevice(); + ::wl_keyboard *keyboard = keyboardDevice(); if (keyboard->focus_resource) { uint32_t time = m_compositor->currentTimeMsecs(); uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); @@ -421,7 +360,7 @@ void InputDevice::sendKeyPressEvent(uint code) void InputDevice::sendKeyReleaseEvent(uint code) { - wl_keyboard *keyboard = keyboardDevice(); + ::wl_keyboard *keyboard = keyboardDevice(); if (keyboard->focus_resource) { uint32_t time = m_compositor->currentTimeMsecs(); uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); @@ -435,7 +374,7 @@ void InputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPoint { uint32_t time = m_compositor->currentTimeMsecs(); uint32_t serial = 0; - wl_touch *touch = touchDevice(); + ::wl_touch *touch = touchDevice(); wl_resource *resource = touch->focus_resource; if (!resource) return; @@ -461,7 +400,7 @@ void InputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPoint void InputDevice::sendTouchFrameEvent() { - wl_touch *touch = touchDevice(); + ::wl_touch *touch = touchDevice(); wl_resource *resource = touch->focus_resource; if (resource) wl_touch_send_frame(resource); @@ -469,7 +408,7 @@ void InputDevice::sendTouchFrameEvent() void InputDevice::sendTouchCancelEvent() { - wl_touch *touch = touchDevice(); + ::wl_touch *touch = touchDevice(); wl_resource *resource = touch->focus_resource; if (resource) wl_touch_send_cancel(resource); @@ -548,7 +487,7 @@ Surface *InputDevice::mouseFocus() const void InputDevice::setMouseFocus(Surface *surface, const QPointF &localPos, const QPointF &globalPos) { - wl_pointer *pointer = pointerDevice(); + ::wl_pointer *pointer = pointerDevice(); pointer->x = wl_fixed_from_double(globalPos.x()); pointer->y = wl_fixed_from_double(globalPos.y()); pointer->current = surface ? surface->base() : 0; @@ -560,7 +499,7 @@ void InputDevice::setMouseFocus(Surface *surface, const QPointF &localPos, const // We have no separate touch focus management so make it match the pointer focus always. // No wl_touch_set_focus() is available so set it manually. - wl_touch *touch = touchDevice(); + ::wl_touch *touch = touchDevice(); touch->focus = surface ? surface->base() : 0; touch->focus_resource = Compositor::resourceForSurface(&touch->resource_list, surface); } diff --git a/src/compositor/wayland_wrapper/qwlinputdevice_p.h b/src/compositor/wayland_wrapper/qwlinputdevice_p.h index 9365fa9de..fd1b0fb4e 100644 --- a/src/compositor/wayland_wrapper/qwlinputdevice_p.h +++ b/src/compositor/wayland_wrapper/qwlinputdevice_p.h @@ -41,8 +41,6 @@ #ifndef WLINPUTDEVICE_H #define WLINPUTDEVICE_H -#include <QtCompositor/qwaylandobject.h> - #include <stdint.h> #include <QtCore/QList> @@ -52,6 +50,8 @@ #include <xkbcommon/xkbcommon.h> #endif +#include <qwayland-server-wayland.h> + QT_BEGIN_NAMESPACE class QKeyEvent; @@ -65,7 +65,7 @@ class DataDevice; class Surface; class DataDeviceManager; -class InputDevice : public Object<struct wl_seat> +class InputDevice : public QtWaylandServer::wl_seat, public QtWaylandServer::wl_pointer, public QtWaylandServer::wl_keyboard, public QtWaylandServer::wl_touch { public: InputDevice(QWaylandInputDevice *handle, Compositor *compositor); @@ -100,12 +100,18 @@ public: Compositor *compositor() const; QWaylandInputDevice *handle() const; - wl_pointer *pointerDevice(); - wl_keyboard *keyboardDevice(); - wl_touch *touchDevice(); - const wl_pointer *pointerDevice() const; - const wl_keyboard *keyboardDevice() const; - const wl_touch *touchDevice() const; + ::wl_pointer *pointerDevice(); + ::wl_keyboard *keyboardDevice(); + ::wl_touch *touchDevice(); + + const ::wl_pointer *pointerDevice() const; + const ::wl_keyboard *keyboardDevice() const; + const ::wl_touch *touchDevice() const; + + static InputDevice *fromSeatResource(struct ::wl_resource *resource) + { + return static_cast<InputDevice *>(wl_seat::Resource::fromResource(resource)->seat); + } private: void initDevices(); @@ -117,12 +123,15 @@ private: QWaylandInputDevice *m_handle; Compositor *m_compositor; QList<DataDevice *> m_data_devices; + struct { - wl_pointer pointer; - wl_keyboard keyboard; - wl_touch touch; + ::wl_pointer pointer; + ::wl_keyboard keyboard; + ::wl_touch touch; } m_device_interfaces; + ::wl_seat m_seat; + #ifndef QT_NO_WAYLAND_XKB struct xkb_keymap *m_keymap; struct xkb_state *m_state; @@ -133,30 +142,24 @@ private: uint32_t toWaylandButton(Qt::MouseButton button); - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - - static void set_cursor(struct wl_client *client, - struct wl_resource *device_base, - uint32_t serial, - struct wl_resource *surface, - int32_t hotspot_x, - int32_t hotspot_y); - const static struct wl_pointer_interface pointer_interface; - - static void get_pointer(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void get_keyboard(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void get_touch(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - const static struct wl_seat_interface seat_interface; - - static void destroy_resource(wl_resource *resource); - static void destroy_device_resource(wl_resource *resource); + void seat_bind_resource(wl_seat::Resource *resource) Q_DECL_OVERRIDE; + + void pointer_set_cursor(wl_pointer::Resource *resource, + uint32_t serial, + struct wl_resource *surface, + int32_t hotspot_x, + int32_t hotspot_y) Q_DECL_OVERRIDE; + + void keyboard_bind_resource(wl_keyboard::Resource *resource) Q_DECL_OVERRIDE; + + void seat_get_pointer(wl_seat::Resource *resource, + uint32_t id) Q_DECL_OVERRIDE; + void seat_get_keyboard(wl_seat::Resource *resource, + uint32_t id) Q_DECL_OVERRIDE; + void seat_get_touch(wl_seat::Resource *resource, + uint32_t id) Q_DECL_OVERRIDE; + + void seat_destroy_resource(wl_seat::Resource *resource) Q_DECL_OVERRIDE; }; } diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp index f248dccdb..bb516f8c4 100644 --- a/src/compositor/wayland_wrapper/qwloutput.cpp +++ b/src/compositor/wayland_wrapper/qwloutput.cpp @@ -44,12 +44,15 @@ #include <QtGui/QScreen> #include <QRect> +#include "qwaylandresourcecollection.h" + QT_BEGIN_NAMESPACE namespace QtWayland { -OutputGlobal::OutputGlobal() - : m_displayId(-1) +OutputGlobal::OutputGlobal(struct ::wl_display *display) + : QtWaylandServer::wl_output(display) + , m_displayId(-1) , m_numQueued(0) { QScreen *screen = QGuiApplication::primaryScreen(); @@ -59,7 +62,15 @@ OutputGlobal::OutputGlobal() OutputGlobal::~OutputGlobal() { - qDeleteAll(m_outputs); +} + +void OutputGlobal::output_bind_resource(Resource *resource) +{ + wl_output_send_geometry(resource->handle, 0, 0, + size().width(), size().height(), 0, "", "", 0); + + wl_output_send_mode(resource->handle, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED, + size().width(), size().height(), refreshRate()); } void OutputGlobal::setGeometry(const QRect &geometry) @@ -74,53 +85,7 @@ void OutputGlobal::setRefreshRate(int rate) Output *OutputGlobal::outputForClient(wl_client *client) const { - return static_cast<Output *>(resourceForClient(client)->data); -} - -void OutputGlobal::output_bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - OutputGlobal *output_global = static_cast<OutputGlobal *>(data); - - Output *output = new Output(output_global,client,version,id); - output_global->registerResource(output->handle()); - output_global->m_outputs.append(output); -} - - - -Output::Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id) - : m_output_global(outputGlobal) - , m_extended_output(0) -{ - Q_UNUSED(version); - m_output_resource = wl_client_add_object(client,&wl_output_interface,0,id,this); - wl_output_send_geometry(m_output_resource, 0, 0, - m_output_global->size().width(), m_output_global->size().height(),0,"","",0); - - wl_output_send_mode(m_output_resource, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED, - m_output_global->size().width(), m_output_global->size().height(), m_output_global->refreshRate()); - -} - -Output::~Output() -{ -} - -ExtendedOutput *Output::extendedOutput() const -{ - return m_extended_output; -} - -void Output::setExtendedOutput(ExtendedOutput *extendedOutput) -{ - m_extended_output = extendedOutput; -} - -wl_resource *Output::handle() const -{ - return m_output_resource; + return static_cast<Output *>(resourceForClient(resourceList(), client)->data); } } // namespace Wayland diff --git a/src/compositor/wayland_wrapper/qwloutput_p.h b/src/compositor/wayland_wrapper/qwloutput_p.h index 11341737d..514d3e9f5 100644 --- a/src/compositor/wayland_wrapper/qwloutput_p.h +++ b/src/compositor/wayland_wrapper/qwloutput_p.h @@ -41,22 +41,27 @@ #ifndef WL_OUTPUT_H #define WL_OUTPUT_H -#include <QtCompositor/qwaylandresourcecollection.h> - #include <QtCore/QRect> #include <QtCore/QList> +#include <qwayland-server-wayland.h> + QT_BEGIN_NAMESPACE namespace QtWayland { -class Output; class ExtendedOutput; -class OutputGlobal : public ResourceCollection +struct Output : public QtWaylandServer::wl_output::Resource +{ + Output() : extendedOutput(0) {} + ExtendedOutput *extendedOutput; +}; + +class OutputGlobal : public QtWaylandServer::wl_output { public: - OutputGlobal(); + OutputGlobal(struct ::wl_display *display); ~OutputGlobal(); void setGeometry(const QRect &geometry); @@ -71,21 +76,21 @@ public: Output *outputForClient(struct wl_client *client) const; - static void output_bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); + void output_bind_resource(Resource *resource) Q_DECL_OVERRIDE; + Resource *output_allocate() Q_DECL_OVERRIDE { return new Output; } + private: QRect m_geometry; int m_refreshRate; int m_displayId; int m_numQueued; - QList<Output *> m_outputs; }; - +#if 0 class Output { public: - Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id); + Output(OutputGlobal *outputGlobal, struct ::wl_resource *resource); ~Output(); OutputGlobal *outputGlobal() const; @@ -98,8 +103,8 @@ private: struct wl_resource *m_output_resource; OutputGlobal *m_output_global; ExtendedOutput *m_extended_output; - }; +#endif } diff --git a/src/compositor/wayland_wrapper/qwlqtkey.cpp b/src/compositor/wayland_wrapper/qwlqtkey.cpp index a6fea9f2a..0c9c136ea 100644 --- a/src/compositor/wayland_wrapper/qwlqtkey.cpp +++ b/src/compositor/wayland_wrapper/qwlqtkey.cpp @@ -43,68 +43,35 @@ #include <QKeyEvent> #include <QWindow> +#include "qwaylandresourcecollection.h" + QT_BEGIN_NAMESPACE namespace QtWayland { -static void dummy(wl_client *, wl_resource *) -{ -} - -const struct wl_qtkey_extension_interface QtKeyExtensionGlobal::qtkey_interface = { - dummy -}; - QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) - : m_compositor(compositor) + : QtWaylandServer::wl_qtkey_extension(compositor->wl_display()) + , m_compositor(compositor) { - wl_display_add_global(compositor->wl_display(), - &wl_qtkey_extension_interface, - this, - QtKeyExtensionGlobal::bind_func); -} - -QtKeyExtensionGlobal::~QtKeyExtensionGlobal() -{ -} - -void QtKeyExtensionGlobal::destroy_resource(wl_resource *resource) -{ - QtKeyExtensionGlobal *self = static_cast<QtKeyExtensionGlobal *>(resource->data); - self->m_resources.removeOne(resource); - free(resource); -} - -void QtKeyExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_resource *resource = wl_client_add_object(client, &wl_qtkey_extension_interface, &qtkey_interface, id, data); - resource->destroy = destroy_resource; - QtKeyExtensionGlobal *self = static_cast<QtKeyExtensionGlobal *>(resource->data); - self->m_resources.append(resource); } bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) { wl_client *surfaceClient = surface->base()->resource.client; - uint32_t time = m_compositor->currentTimeMsecs(); - const int rescount = m_resources.count(); - for (int res = 0; res < rescount; ++res) { - wl_resource *target = m_resources.at(res); - if (target->client != surfaceClient) - continue; - - QByteArray textUtf8 = event->text().toUtf8(); + uint32_t time = m_compositor->currentTimeMsecs(); - wl_qtkey_extension_send_qtkey(target, - time, event->type(), event->key(), event->modifiers(), - event->nativeScanCode(), - event->nativeVirtualKey(), - event->nativeModifiers(), - textUtf8.constData(), - event->isAutoRepeat(), - event->count()); + struct wl_resource *target = resourceForClient(resourceList(), surfaceClient); + + if (target) { + send_qtkey(target, + time, event->type(), event->key(), event->modifiers(), + event->nativeScanCode(), + event->nativeVirtualKey(), + event->nativeModifiers(), + event->text(), + event->isAutoRepeat(), + event->count()); return true; } diff --git a/src/compositor/wayland_wrapper/qwlqtkey_p.h b/src/compositor/wayland_wrapper/qwlqtkey_p.h index bb98f9b88..c9226c0ff 100644 --- a/src/compositor/wayland_wrapper/qwlqtkey_p.h +++ b/src/compositor/wayland_wrapper/qwlqtkey_p.h @@ -42,9 +42,11 @@ #define WLQTKEY_H #include <private/qwlcompositor_p.h> -#include "wayland-qtkey-extension-server-protocol.h" + #include "wayland-util.h" +#include "qwayland-server-qtkey-extension.h" + QT_BEGIN_NAMESPACE class Compositor; @@ -53,24 +55,15 @@ class QKeyEvent; namespace QtWayland { -class QtKeyExtensionGlobal +class QtKeyExtensionGlobal : public QtWaylandServer::wl_qtkey_extension { public: QtKeyExtensionGlobal(Compositor *compositor); - ~QtKeyExtensionGlobal(); bool postQtKeyEvent(QKeyEvent *event, Surface *surface); private: - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - - static void destroy_resource(wl_resource *resource); - - static const struct wl_qtkey_extension_interface qtkey_interface; - Compositor *m_compositor; - QList<wl_resource *> m_resources; }; } diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp index f8d6e0c5c..061faccdc 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlshellsurface.cpp @@ -78,20 +78,20 @@ const struct wl_shell_interface Shell::shell_interface = { }; ShellSurface::ShellSurface(wl_client *client, uint32_t id, Surface *surface) - : m_surface(surface) + : wl_shell_surface(client, id) + , m_surface(surface) , m_resizeGrabber(0) , m_moveGrabber(0) , m_transientParent(0) , m_xOffset(0) , m_yOffset(0) { - m_shellSurface = wl_client_add_object(client,&wl_shell_surface_interface,&shell_surface_interface,id,this); surface->setShellSurface(this); } void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height) { - wl_shell_surface_send_configure(m_shellSurface,edges,width,height); + send_configure(edges, width, height); } Surface *ShellSurface::surface() const @@ -148,103 +148,102 @@ void ShellSurface::setOffset(const QPointF &offset) m_yOffset = offset.y(); } -void ShellSurface::move(struct wl_client *client, - struct wl_resource *shell_surface_resource, +void ShellSurface::shell_surface_destroy_resource(Resource *) +{ + delete this; +} + +void ShellSurface::shell_surface_move(Resource *resource, struct wl_resource *input_device_super, uint32_t time) { - Q_UNUSED(client); + Q_UNUSED(resource); Q_UNUSED(time); - ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data); - InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data); - if (self->m_resizeGrabber || self->m_moveGrabber) { + + if (m_resizeGrabber || m_moveGrabber) { qDebug() << "invalid state"; return; } - self->m_moveGrabber = new ShellSurfaceMoveGrabber(self); - wl_pointer *pointer = input_device->pointerDevice(); - self->m_moveGrabber->base()->x = pointer->x; - self->m_moveGrabber->base()->y = pointer->y; - self->m_moveGrabber->offset_x = wl_fixed_to_int(pointer->x) - self->surface()->pos().x(); - self->m_moveGrabber->offset_y = wl_fixed_to_int(pointer->y) - self->surface()->pos().y(); + InputDevice *input_device = InputDevice::fromSeatResource(input_device_super); + ::wl_pointer *pointer = input_device->pointerDevice(); - wl_pointer_start_grab(pointer, self->m_moveGrabber->base()); + m_moveGrabber = new ShellSurfaceMoveGrabber(this); + m_moveGrabber->base()->x = pointer->x; + m_moveGrabber->base()->y = pointer->y; + m_moveGrabber->offset_x = wl_fixed_to_int(pointer->x) - surface()->pos().x(); + m_moveGrabber->offset_y = wl_fixed_to_int(pointer->y) - surface()->pos().y(); + + wl_pointer_start_grab(pointer, m_moveGrabber->base()); } -void ShellSurface::resize(struct wl_client *client, - struct wl_resource *shell_surface_resource, +void ShellSurface::shell_surface_resize(Resource *resource, struct wl_resource *input_device_super, uint32_t time, uint32_t edges) { - Q_UNUSED(shell_surface_resource); - Q_UNUSED(client); + Q_UNUSED(resource); Q_UNUSED(time); Q_UNUSED(edges); - ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data); - InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data); - if (self->m_moveGrabber || self->m_resizeGrabber) { + + if (m_moveGrabber || m_resizeGrabber) { qDebug() << "invalid state2"; return; } - self->m_resizeGrabber = new ShellSurfaceResizeGrabber(self); - wl_pointer *pointer = input_device->pointerDevice(); - self->m_resizeGrabber->base()->x = pointer->x; - self->m_resizeGrabber->base()->y = pointer->y; - self->m_resizeGrabber->resize_edges = wl_shell_surface_resize(edges); - self->m_resizeGrabber->width = self->surface()->size().width(); - self->m_resizeGrabber->height = self->surface()->size().height(); - wl_pointer_start_grab(pointer, self->m_resizeGrabber->base()); + m_resizeGrabber = new ShellSurfaceResizeGrabber(this); + + InputDevice *input_device = InputDevice::fromSeatResource(input_device_super); + ::wl_pointer *pointer = input_device->pointerDevice(); + + m_resizeGrabber->base()->x = pointer->x; + m_resizeGrabber->base()->y = pointer->y; + m_resizeGrabber->resize_edges = wl_shell_surface_resize(edges); + m_resizeGrabber->width = surface()->size().width(); + m_resizeGrabber->height = surface()->size().height(); + + wl_pointer_start_grab(pointer, m_resizeGrabber->base()); } -void ShellSurface::set_toplevel(struct wl_client *client, - struct wl_resource *shell_surface_resource) +void ShellSurface::shell_surface_set_toplevel(Resource *resource) { - Q_UNUSED(client); - ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data); - self->m_transientParent = 0; - self->m_xOffset = 0; - self->m_yOffset = 0; + Q_UNUSED(resource); + m_transientParent = 0; + m_xOffset = 0; + m_yOffset = 0; } -void ShellSurface::set_transient(struct wl_client *client, - struct wl_resource *shell_surface_resource, +void ShellSurface::shell_surface_set_transient(Resource *resource, struct wl_resource *parent_surface_resource, int x, int y, uint32_t flags) { - Q_UNUSED(client); + Q_UNUSED(resource); Q_UNUSED(flags); - ShellSurface *shell_surface = static_cast<ShellSurface *>(shell_surface_resource->data); Surface *parent_surface = static_cast<Surface *>(parent_surface_resource->data); - shell_surface->m_transientParent = parent_surface->shellSurface(); - shell_surface->m_xOffset = x; - shell_surface->m_yOffset = y; + m_transientParent = parent_surface->shellSurface(); + m_xOffset = x; + m_yOffset = y; if (flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE) - shell_surface->surface()->setTransientInactive(true); + surface()->setTransientInactive(true); } -void ShellSurface::set_fullscreen(struct wl_client *client, - struct wl_resource *shell_surface_resource, +void ShellSurface::shell_surface_set_fullscreen(Resource *resource, uint32_t method, uint32_t framerate, struct wl_resource *output) { - Q_UNUSED(client); - Q_UNUSED(shell_surface_resource); + Q_UNUSED(resource); Q_UNUSED(method); Q_UNUSED(framerate); Q_UNUSED(output); } -void ShellSurface::set_popup(wl_client *client, wl_resource *resource, wl_resource *input_device, uint32_t time, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) +void ShellSurface::shell_surface_set_popup(Resource *resource, wl_resource *input_device, uint32_t time, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) { - Q_UNUSED(client); Q_UNUSED(resource); Q_UNUSED(input_device); Q_UNUSED(time); @@ -254,55 +253,34 @@ void ShellSurface::set_popup(wl_client *client, wl_resource *resource, wl_resour Q_UNUSED(flags); } -void ShellSurface::set_maximized(struct wl_client *client, - struct wl_resource *shell_surface_resource, +void ShellSurface::shell_surface_set_maximized(Resource *resource, struct wl_resource *output) { - Q_UNUSED(client); - Q_UNUSED(shell_surface_resource); + Q_UNUSED(resource); Q_UNUSED(output); } -void ShellSurface::pong(struct wl_client *client, - struct wl_resource *resource, +void ShellSurface::shell_surface_pong(Resource *resource, uint32_t serial) { - Q_UNUSED(client); Q_UNUSED(resource); Q_UNUSED(serial); } -void ShellSurface::set_title(struct wl_client *client, - struct wl_resource *resource, - const char *title) +void ShellSurface::shell_surface_set_title(Resource *resource, + const QString &title) { - Q_UNUSED(client); - ShellSurface *self = static_cast<ShellSurface *>(resource->data); - self->surface()->setTitle(QString::fromUtf8(title)); + Q_UNUSED(resource); + surface()->setTitle(title); } -void ShellSurface::set_class(struct wl_client *client, - struct wl_resource *resource, - const char *class_) +void ShellSurface::shell_surface_set_class(Resource *resource, + const QString &className) { - Q_UNUSED(client); - ShellSurface *self = static_cast<ShellSurface *>(resource->data); - self->surface()->setClassName(QString::fromUtf8(class_)); + Q_UNUSED(resource); + surface()->setClassName(className); } -const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = { - ShellSurface::pong, - ShellSurface::move, - ShellSurface::resize, - ShellSurface::set_toplevel, - ShellSurface::set_transient, - ShellSurface::set_fullscreen, - ShellSurface::set_popup, - ShellSurface::set_maximized, - ShellSurface::set_title, - ShellSurface::set_class -}; - Qt::MouseButton toQtButton(uint32_t button) { #ifndef BTN_LEFT diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h index 1bb0c4e42..92820adb6 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlshellsurface_p.h @@ -46,6 +46,8 @@ #include <wayland-server.h> #include <QPoint> +#include <qwayland-server-wayland.h> + QT_BEGIN_NAMESPACE namespace QtWayland { @@ -72,7 +74,7 @@ private: }; -class ShellSurface +class ShellSurface : public QtWaylandServer::wl_shell_surface { public: ShellSurface(struct wl_client *client, uint32_t id, Surface *surface); @@ -89,7 +91,6 @@ public: void setOffset(const QPointF &offset); private: - struct wl_resource *m_shellSurface; Surface *m_surface; ShellSurfaceResizeGrabber *m_resizeGrabber; @@ -100,50 +101,40 @@ private: int32_t m_xOffset; int32_t m_yOffset; - static void move(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *input_device_super, - uint32_t time); - static void resize(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *input_device, - uint32_t time, - uint32_t edges); - static void set_toplevel(struct wl_client *client, - struct wl_resource *shell_surface_resource); - static void set_transient(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *parent_surface_resource, - int x, - int y, - uint32_t flags); - static void set_fullscreen(struct wl_client *client, - struct wl_resource *shell_surface_resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output); - static void set_popup(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *input_device, - uint32_t time, - struct wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags); - static void set_maximized(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *output); - static void pong(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void set_title(struct wl_client *client, - struct wl_resource *resource, - const char *title); - static void set_class(struct wl_client *client, - struct wl_resource *resource, - const char *class_); - - static const struct wl_shell_surface_interface shell_surface_interface; + void shell_surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; + + void shell_surface_move(Resource *resource, + struct wl_resource *input_device_super, + uint32_t time) Q_DECL_OVERRIDE; + void shell_surface_resize(Resource *resource, + struct wl_resource *input_device, + uint32_t time, + uint32_t edges) Q_DECL_OVERRIDE; + void shell_surface_set_toplevel(Resource *resource) Q_DECL_OVERRIDE; + void shell_surface_set_transient(Resource *resource, + struct wl_resource *parent_surface_resource, + int x, + int y, + uint32_t flags) Q_DECL_OVERRIDE; + void shell_surface_set_fullscreen(Resource *resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output) Q_DECL_OVERRIDE; + void shell_surface_set_popup(Resource *resource, + struct wl_resource *input_device, + uint32_t time, + struct wl_resource *parent, + int32_t x, + int32_t y, + uint32_t flags) Q_DECL_OVERRIDE; + void shell_surface_set_maximized(Resource *resource, + struct wl_resource *output) Q_DECL_OVERRIDE; + void shell_surface_pong(Resource *resource, + uint32_t serial) Q_DECL_OVERRIDE; + void shell_surface_set_title(Resource *resource, + const QString &title) Q_DECL_OVERRIDE; + void shell_surface_set_class(Resource *resource, + const QString &class_) Q_DECL_OVERRIDE; }; class ShellSurfaceGrabber : public Object<wl_pointer_grab> diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index 34fee627f..8ef0befdb 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -103,7 +103,6 @@ Surface::~Surface() delete m_waylandSurface; delete m_extendedSurface; delete m_subSurface; - delete m_shellSurface; for (int i = 0; i < buffer_pool_size; i++) { if (!m_bufferPool[i]->pageFlipperHasBuffer()) diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index 9bfe957e2..c425e2e5b 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -1,10 +1,11 @@ -WAYLANDSOURCES += \ +WAYLANDSERVERSOURCES += \ ../extensions/surface-extension.xml \ ../extensions/sub-surface-extension.xml \ ../extensions/output-extension.xml \ ../extensions/touch-extension.xml \ ../extensions/qtkey-extension.xml \ - ../extensions/windowmanager.xml + ../extensions/windowmanager.xml \ + ../3rdparty/protocol/wayland.xml HEADERS += \ wayland_wrapper/qwlcompositor_p.h \ diff --git a/src/extensions/qtkey-extension.xml b/src/extensions/qtkey-extension.xml index fc4d14dac..e90c33190 100644 --- a/src/extensions/qtkey-extension.xml +++ b/src/extensions/qtkey-extension.xml @@ -1,4 +1,4 @@ -<protocol name="key_extension"> +<protocol name="qtkey_extension"> <copyright> Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). diff --git a/src/extensions/windowmanager.xml b/src/extensions/windowmanager.xml index 71fb27239..4d789e51a 100644 --- a/src/extensions/windowmanager.xml +++ b/src/extensions/windowmanager.xml @@ -1,4 +1,4 @@ -<protocol name="wayland_windowmanager"> +<protocol name="windowmanager"> <copyright> Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro b/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro index bdd948ac8..2e5a66e96 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro +++ b/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro @@ -17,4 +17,4 @@ HEADERS += qwaylandbrcmeglintegration.h \ qwaylandbrcmglcontext.h \ qwaylandbrcmeglwindow.h -WAYLANDSOURCES += ../../../extensions/brcm.xml +WAYLANDCLIENTSOURCES += ../../../extensions/brcm.xml diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp index 2bd5732d3..c5712d65b 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp @@ -59,10 +59,10 @@ QWaylandBrcmEglIntegration::QWaylandBrcmEglIntegration(QWaylandDisplay *waylandD waylandDisplay->addRegistryListener(wlDisplayHandleGlobal, this); } -void QWaylandBrcmEglIntegration::wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) +void QWaylandBrcmEglIntegration::wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) { Q_UNUSED(version); - if (strcmp(interface, "wl_brcm") == 0) { + if (interface == "wl_brcm") { QWaylandBrcmEglIntegration *integration = static_cast<QWaylandBrcmEglIntegration *>(data); integration->m_waylandBrcm = static_cast<struct wl_brcm *>(wl_registry_bind(registry, id, &wl_brcm_interface, 1)); } diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h index c7cb41b6d..fd971ffb9 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h @@ -81,7 +81,7 @@ public: PFNEGLDESTROYGLOBALIMAGEBRCMPROC eglDestroyGlobalImageBRCM; private: - static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version); + static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version); struct wl_display *m_waylandDisplay; struct wl_brcm *m_waylandBrcm; diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp index ba480c004..a6fe462e4 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp @@ -104,7 +104,7 @@ void QWaylandEglWindow::setGeometry(const QRect &rect) m_resize = true; } } else { - m_waylandEglWindow = wl_egl_window_create(mSurface, sizeWithMargins.width(), sizeWithMargins.height()); + m_waylandEglWindow = wl_egl_window_create(wl_surface(), sizeWithMargins.width(), sizeWithMargins.height()); } QWaylandWindow::setGeometry(rect); @@ -125,10 +125,11 @@ QSurfaceFormat QWaylandEglWindow::format() const EGLSurface QWaylandEglWindow::eglSurface() const { if (!m_waylandEglWindow) { - const_cast<QWaylandEglWindow *>(this)->createDecoration(); + QWaylandEglWindow *self = const_cast<QWaylandEglWindow *>(this); + self->createDecoration(); QMargins margins = frameMargins(); QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); - m_waylandEglWindow = wl_egl_window_create(mSurface, sizeWithMargins.width(), sizeWithMargins.height()); + m_waylandEglWindow = wl_egl_window_create(self->wl_surface(), sizeWithMargins.width(), sizeWithMargins.height()); } if (!m_eglSurface) { diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro b/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro index b691ec9dc..e41cf59b4 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro @@ -6,6 +6,10 @@ include (../xcomposite_share/xcomposite_share.pri) OTHER_FILES += qwayland-xcomposite-egl.json +contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) { + WAYLANDCLIENTSOURCES += ../../../extensions/windowmanager.xml +} + !contains(QT_CONFIG, no-pkg-config) { CONFIG += link_pkgconfig PKGCONFIG += xcomposite egl x11 diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp index 992c2dcff..7827fdb97 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp @@ -114,10 +114,10 @@ const struct wl_xcomposite_listener QWaylandXCompositeEGLIntegration::xcomposite QWaylandXCompositeEGLIntegration::rootInformation }; -void QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const char *interface, uint32_t version) +void QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) { Q_UNUSED(version); - if (strcmp(interface, "wl_xcomposite") == 0) { + if (interface == "wl_xcomposite") { QWaylandXCompositeEGLIntegration *integration = static_cast<QWaylandXCompositeEGLIntegration *>(data); integration->mWaylandComposite = static_cast<struct wl_xcomposite *>(wl_registry_bind(registry,id,&wl_xcomposite_interface,1)); wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h index d3015ab57..034d00d58 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h @@ -92,7 +92,7 @@ private: Window mRootWindow; static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version); + const QString &interface, uint32_t version); static const struct wl_xcomposite_listener xcomposite_listener; static void rootInformation(void *data, diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp index d47439412..c7053b51a 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp @@ -49,7 +49,10 @@ #include <X11/extensions/Xcomposite.h> #include "qwaylandxcompositeeglintegration.h" + +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" +#endif #include <QtCore/QDebug> diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp index 56554236b..e3316d96f 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp @@ -112,10 +112,10 @@ const struct wl_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite QWaylandXCompositeGLXIntegration::rootInformation }; -void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const char *interface, uint32_t version) +void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) { Q_UNUSED(version); - if (strcmp(interface, "wl_xcomposite") == 0) { + if (interface == "wl_xcomposite") { qDebug("XComposite-GLX: got wl_xcomposite global"); QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data); integration->mWaylandComposite = static_cast<struct wl_xcomposite *>(wl_registry_bind(registry, id, &wl_xcomposite_interface, 1)); diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h index 8bbbab89b..55bf815ea 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h @@ -85,7 +85,7 @@ private: Window mRootWindow; static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version); + const QString &interface, uint32_t version); static const struct wl_xcomposite_listener xcomposite_listener; static void rootInformation(void *data, diff --git a/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp b/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp index d4ba61790..901069c5c 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp @@ -86,7 +86,7 @@ void QWaylandDataDeviceManager::enter(void *data, return; data_device_manager->m_drag_last_event_time = time; - data_device_manager->m_drag_current_event_window = static_cast<QWaylandWindow *>(wl_surface_get_user_data(surface)); + data_device_manager->m_drag_current_event_window = QWaylandWindow::fromWlSurface(surface); if (!surface) return; QWaylandDataOffer *offer = static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id)); @@ -261,7 +261,7 @@ void QWaylandDataDeviceManager::createAndSetDrag(QDrag *drag) p.drawPixmap(0,0,pixmap); } - m_drag_icon_surface = wl_compositor_create_surface(m_display->wl_compositor()); + m_drag_icon_surface = m_display->compositor()->create_surface(); wl_surface_attach(m_drag_icon_surface, m_drag_icon_buffer->buffer(), -drag->hotSpot().x(), -drag->hotSpot().y()); wl_data_device_start_drag(transfer_device, m_drag_data_source->handle(), m_drag_surface, m_drag_icon_surface, QWaylandDisplay::currentTimeMillisec()); diff --git a/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp b/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp index dbe214119..39ca811bf 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp @@ -48,7 +48,6 @@ #include "qwaylandinputdevice.h" #include "qwaylandclipboard.h" #include "qwaylanddatadevicemanager.h" -#include "qwaylandshell.h" #ifdef QT_WAYLAND_GL_SUPPORT #include "qwaylandglintegration.h" @@ -73,7 +72,7 @@ QT_USE_NAMESPACE struct wl_surface *QWaylandDisplay::createSurface(void *handle) { - struct wl_surface * surface = wl_compositor_create_surface(mCompositor); + struct wl_surface *surface = mCompositor.create_surface(); wl_surface_set_user_data(surface, handle); return surface; } @@ -104,11 +103,7 @@ void QWaylandDisplay::setLastKeyboardFocusInputDevice(QWaylandInputDevice *devic static QWaylandDisplay *display = 0; -const struct wl_registry_listener QWaylandDisplay::registryListener = { - QWaylandDisplay::displayHandleGlobal -}; - -QWaylandDisplay::QWaylandDisplay(void) +QWaylandDisplay::QWaylandDisplay() : mLastKeyboardFocusInputDevice(0) , mDndSelectionHandler(0) , mWindowExtension(0) @@ -131,9 +126,10 @@ QWaylandDisplay::QWaylandDisplay(void) //Create a new even queue for the QtGui thread mEventQueue = wl_display_create_queue(mDisplay); - mRegistry = wl_display_get_registry(mDisplay); - wl_proxy_set_queue((struct wl_proxy *)mRegistry, mEventQueue); - wl_registry_add_listener(mRegistry, ®istryListener, this); + struct ::wl_registry *registry = wl_display_get_registry(mDisplay); + wl_proxy_set_queue((struct wl_proxy *)registry, mEventQueue); + + init(registry); QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); @@ -144,7 +140,7 @@ QWaylandDisplay::QWaylandDisplay(void) #endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT - mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); + mWindowManagerIntegration = new QWaylandWindowManagerIntegration(this); #endif blockingReadEvents(); @@ -170,12 +166,6 @@ QWaylandDisplay::~QWaylandDisplay(void) delete mEventThreadObject; } -void QWaylandDisplay::createNewScreen(struct wl_output *output) -{ - QWaylandScreen *waylandScreen = new QWaylandScreen(this,output); - mScreens.append(waylandScreen); -} - void QWaylandDisplay::flushRequests() { wl_display_dispatch_queue_pending(mDisplay, mEventQueue); @@ -197,51 +187,12 @@ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const return 0; } -void QWaylandDisplay::outputHandleGeometry(void *data, - struct wl_output *output, - int32_t x, int32_t y, - int32_t physicalWidth, - int32_t physicalHeight, - int subpixel, - const char *make, const char *model, - int32_t transform) -{ - Q_UNUSED(subpixel); - Q_UNUSED(make); - Q_UNUSED(model); - Q_UNUSED(transform); - QWaylandDisplay *waylandDisplay = static_cast<QWaylandDisplay *>(data); - QRect outputRect = QRect(x, y, physicalWidth, physicalHeight); - waylandDisplay->screenForOutput(output)->setGeometry(outputRect); -} - -void QWaylandDisplay::mode(void *data, - struct wl_output *output, - uint32_t flags, - int width, - int height, - int refresh) -{ - QWaylandDisplay *waylandDisplay = static_cast<QWaylandDisplay *>(data); - - if (flags & WL_OUTPUT_MODE_CURRENT) { - QWaylandScreen *screen = waylandDisplay->screenForOutput(output); - if (screen) - screen->handleMode(QSize(width, height), refresh); - } -} - void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data) { Listener l = { listener, data }; mRegistryListeners.append(l); } -const struct wl_output_listener QWaylandDisplay::outputListener = { - QWaylandDisplay::outputHandleGeometry, - QWaylandDisplay::mode -}; - void QWaylandDisplay::waitForScreens() { flushRequests(); @@ -249,53 +200,41 @@ void QWaylandDisplay::waitForScreens() blockingReadEvents(); } -void QWaylandDisplay::displayHandleGlobal(void *data, - struct wl_registry *registry, - uint32_t id, - const char *interface, - uint32_t version) -{ - Q_UNUSED(registry); - QWaylandDisplay *that = static_cast<QWaylandDisplay *>(data); - that->displayHandleGlobal(id, QByteArray(interface), version); -} - -void QWaylandDisplay::displayHandleGlobal(uint32_t id, - const QByteArray &interface, - uint32_t version) +void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uint32_t version) { Q_UNUSED(version); + struct ::wl_registry *registry = object(); + if (interface == "wl_output") { - struct wl_output *output = static_cast<struct wl_output *>(wl_registry_bind(mRegistry,id,&wl_output_interface,1)); - createNewScreen(output); - wl_output_add_listener(output, &outputListener, this); + mScreens.append(new QWaylandScreen(this, id)); } else if (interface == "wl_compositor") { - mCompositor = static_cast<struct wl_compositor *>(wl_registry_bind(mRegistry, id,&wl_compositor_interface,1)); + mCompositor.init(registry, id); } else if (interface == "wl_shm") { - mShm = static_cast<struct wl_shm *>(wl_registry_bind(mRegistry, id, &wl_shm_interface,1)); + mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1)); } else if (interface == "wl_shell"){ - mShell = new QWaylandShell(this,id,version); + mShell = new QtWayland::wl_shell(registry, id); } else if (interface == "wl_seat") { QWaylandInputDevice *inputDevice = new QWaylandInputDevice(this, id); mInputDevices.append(inputDevice); } else if (interface == "wl_data_device_manager") { mDndSelectionHandler = new QWaylandDataDeviceManager(this, id); } else if (interface == "wl_output_extension") { - mOutputExtension = new QWaylandOutputExtension(this,id); + mOutputExtension = new QtWayland::wl_output_extension(registry, id); + foreach (QPlatformScreen *screen, screens()) + static_cast<QWaylandScreen *>(screen)->createExtendedOutput(); } else if (interface == "wl_surface_extension") { - mWindowExtension = new QWaylandSurfaceExtension(this,id); + mWindowExtension = new QtWayland::wl_surface_extension(registry, id); } else if (interface == "wl_sub_surface_extension") { - mSubSurfaceExtension = new QWaylandSubSurfaceExtension(this,id); + mSubSurfaceExtension = new QtWayland::wl_sub_surface_extension(registry, id); } else if (interface == "wl_touch_extension") { mTouchExtension = new QWaylandTouchExtension(this, id); } else if (interface == "wl_qtkey_extension") { mQtKeyExtension = new QWaylandQtKeyExtension(this, id); } - foreach (Listener l, mRegistryListeners) { - (*l.listener)(l.data, mRegistry, id, interface, version); - } + foreach (Listener l, mRegistryListeners) + (*l.listener)(l.data, registry, id, interface, version); } uint32_t QWaylandDisplay::currentTimeMillisec() diff --git a/src/plugins/platforms/wayland_common/qwaylanddisplay.h b/src/plugins/platforms/wayland_common/qwaylanddisplay.h index 40da74f1a..e0a6be159 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland_common/qwaylanddisplay.h @@ -48,6 +48,7 @@ #include <QtCore/QWaitCondition> #include <wayland-client.h> +#include <qwayland-wayland.h> QT_BEGIN_NAMESPACE @@ -60,22 +61,25 @@ class QWaylandScreen; class QWaylandGLIntegration; class QWaylandWindowManagerIntegration; class QWaylandDataDeviceManager; -class QWaylandShell; -class QWaylandSurfaceExtension; -class QWaylandSubSurfaceExtension; -class QWaylandOutputExtension; class QWaylandTouchExtension; class QWaylandQtKeyExtension; class QWaylandWindow; class QWaylandEventThread; +namespace QtWayland { + class wl_output_extension; + class wl_shell; + class wl_sub_surface_extension; + class wl_surface_extension; +} + typedef void (*RegistryListener)(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, + const QString &interface, uint32_t version); -class QWaylandDisplay : public QObject { +class QWaylandDisplay : public QObject, public QtWayland::wl_registry { Q_OBJECT public: @@ -100,10 +104,12 @@ public: struct wl_display *wl_display() const { return mDisplay; } struct wl_event_queue *wl_event_queue() const { return mEventQueue; } - struct wl_registry *wl_registry() const { return mRegistry; } - struct wl_compositor *wl_compositor() const { return mCompositor; } + struct ::wl_registry *wl_registry() { return object(); } + + const struct wl_compositor *wl_compositor() const { return mCompositor.object(); } + QtWayland::wl_compositor *compositor() { return &mCompositor; } - QWaylandShell *shell() const { return mShell; } + QtWayland::wl_shell *shell() { return mShell; } QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; } @@ -112,9 +118,9 @@ public: QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler; } - QWaylandSurfaceExtension *windowExtension() const { return mWindowExtension; } - QWaylandSubSurfaceExtension *subSurfaceExtension() const { return mSubSurfaceExtension; } - QWaylandOutputExtension *outputExtension() const { return mOutputExtension; } + QtWayland::wl_surface_extension *windowExtension() const { return mWindowExtension; } + QtWayland::wl_sub_surface_extension *subSurfaceExtension() const { return mSubSurfaceExtension; } + QtWayland::wl_output_extension *outputExtension() const { return mOutputExtension; } QWaylandTouchExtension *touchExtension() const { return mTouchExtension; } /* wl_registry_add_listener does not add but rather sets a listener, so this function is used @@ -130,15 +136,11 @@ public: void scheduleRedraw(QWaylandWindow *window); public slots: - void createNewScreen(struct wl_output *output); void blockingReadEvents(); void flushRequests(); private: void waitForScreens(); - void displayHandleGlobal(uint32_t id, - const QByteArray &interface, - uint32_t version); struct Listener { RegistryListener listener; @@ -147,20 +149,19 @@ private: struct wl_display *mDisplay; struct wl_event_queue *mEventQueue; - struct wl_registry *mRegistry; - struct wl_compositor *mCompositor; + QtWayland::wl_compositor mCompositor; struct wl_shm *mShm; QThread *mEventThread; QWaylandEventThread *mEventThreadObject; - QWaylandShell *mShell; + QtWayland::wl_shell *mShell; QList<QPlatformScreen *> mScreens; QList<QWaylandInputDevice *> mInputDevices; QList<Listener> mRegistryListeners; QWaylandInputDevice *mLastKeyboardFocusInputDevice; QWaylandDataDeviceManager *mDndSelectionHandler; - QWaylandSurfaceExtension *mWindowExtension; - QWaylandSubSurfaceExtension *mSubSurfaceExtension; - QWaylandOutputExtension *mOutputExtension; + QtWayland::wl_surface_extension *mWindowExtension; + QtWayland::wl_sub_surface_extension *mSubSurfaceExtension; + QtWayland::wl_output_extension *mOutputExtension; QWaylandTouchExtension *mTouchExtension; QWaylandQtKeyExtension *mQtKeyExtension; @@ -169,28 +170,7 @@ private: int mWritableNotificationFd; bool mScreensInitialized; - static const struct wl_registry_listener registryListener; - static const struct wl_output_listener outputListener; - - static void displayHandleGlobal(void *data, - struct wl_registry *registry, - uint32_t id, - const char *interface, - uint32_t version); - static void outputHandleGeometry(void *data, - struct wl_output *output, - int32_t x, int32_t y, - int32_t width, int32_t height, - int subpixel, - const char *make, - const char *model, - int32_t transform); - static void mode(void *data, - struct wl_output *wl_output, - uint32_t flags, - int width, - int height, - int refresh); + void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE; #ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *mEglIntegration; diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp index 7b6f9f3ca..ce80d4874 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp @@ -43,44 +43,17 @@ #include "qwaylandscreen.h" -#include "wayland-output-extension-client-protocol.h" - #include <qpa/qwindowsysteminterface.h> #include <QtCore/QDebug> QT_USE_NAMESPACE -QWaylandOutputExtension::QWaylandOutputExtension(QWaylandDisplay *display, uint32_t id) -{ - m_output_extension = static_cast<struct wl_output_extension *>( - wl_registry_bind(display->wl_registry(), id, &wl_output_extension_interface, 1)); - - QList<QPlatformScreen *> platformScreens = display->screens(); - for (int i = 0; i < platformScreens.size(); i++) { - QWaylandScreen *waylandScreen = static_cast<QWaylandScreen *>(platformScreens.at(i)); - if (!waylandScreen->extendedOutput()) { - QWaylandExtendedOutput *extendedOutput = getExtendedOutput(waylandScreen); - waylandScreen->setExtendedOutput(extendedOutput); - qDebug() << "extended output enabled"; - } - } -} - -QWaylandExtendedOutput *QWaylandOutputExtension::getExtendedOutput(QWaylandScreen *screen) -{ - qDebug() << "getExtendedOutput"; - struct wl_extended_output *extended_output = - wl_output_extension_get_extended_output(m_output_extension,screen->output()); - return new QWaylandExtendedOutput(screen,extended_output); -} - -QWaylandExtendedOutput::QWaylandExtendedOutput(QWaylandScreen *screen, wl_extended_output *extended_output) - : m_extended_output(extended_output) +QWaylandExtendedOutput::QWaylandExtendedOutput(QWaylandScreen *screen, struct ::wl_extended_output *extended_output) + : QtWayland::wl_extended_output(extended_output) , m_screen(screen) , m_orientation(m_screen->orientation()) { - wl_extended_output_add_listener(m_extended_output,&extended_output_listener,this); } Qt::ScreenOrientation QWaylandExtendedOutput::currentOrientation() const @@ -99,33 +72,27 @@ void QWaylandExtendedOutput::setOrientationUpdateMask(Qt::ScreenOrientations ori mask |= WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION; if (orientations & Qt::InvertedLandscapeOrientation) mask |= WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION; - wl_extended_output_set_orientation_update_mask(m_extended_output, mask); + set_orientation_update_mask(mask); } -void QWaylandExtendedOutput::set_screen_rotation(void *data, wl_extended_output *wl_extended_output, int32_t rotation) +void QWaylandExtendedOutput::extended_output_set_screen_rotation(int32_t rotation) { - Q_UNUSED(wl_extended_output); - QWaylandExtendedOutput *extended_output = static_cast<QWaylandExtendedOutput *>(data); switch (rotation) { case WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION: - extended_output->m_orientation = Qt::PortraitOrientation; + m_orientation = Qt::PortraitOrientation; break; case WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION: - extended_output->m_orientation = Qt::LandscapeOrientation; + m_orientation = Qt::LandscapeOrientation; break; case WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION: - extended_output->m_orientation = Qt::InvertedPortraitOrientation; + m_orientation = Qt::InvertedPortraitOrientation; break; case WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION: - extended_output->m_orientation = Qt::InvertedLandscapeOrientation; + m_orientation = Qt::InvertedLandscapeOrientation; break; default: - extended_output->m_orientation = Qt::PortraitOrientation; + m_orientation = Qt::PortraitOrientation; break; } - QWindowSystemInterface::handleScreenOrientationChange(extended_output->m_screen->screen(), extended_output->m_orientation); + QWindowSystemInterface::handleScreenOrientationChange(m_screen->screen(), m_orientation); } - -const struct wl_extended_output_listener QWaylandExtendedOutput::extended_output_listener = { - QWaylandExtendedOutput::set_screen_rotation -}; diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h index 780f57023..35b4510c2 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h +++ b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h @@ -43,38 +43,25 @@ #define QWAYLANDEXTENDEDOUTPUT_H #include "qwaylanddisplay.h" +#include "qwayland-output-extension.h" QT_BEGIN_NAMESPACE class QWaylandExtendedOutput; -class QWaylandOutputExtension +class QWaylandExtendedOutput : public QtWayland::wl_extended_output { public: - QWaylandOutputExtension(QWaylandDisplay *display, uint32_t id); - - QWaylandExtendedOutput* getExtendedOutput(QWaylandScreen *screen); -private: - struct wl_output_extension *m_output_extension; -}; - -class QWaylandExtendedOutput -{ -public: - QWaylandExtendedOutput(QWaylandScreen *screen, struct wl_extended_output *extended_output); + QWaylandExtendedOutput(QWaylandScreen *screen, struct ::wl_extended_output *extended_output); Qt::ScreenOrientation currentOrientation() const; void setOrientationUpdateMask(Qt::ScreenOrientations mask); private: - struct wl_extended_output *m_extended_output; + void extended_output_set_screen_rotation(int32_t rotation) Q_DECL_OVERRIDE; + QWaylandScreen *m_screen; Qt::ScreenOrientation m_orientation; - - static void set_screen_rotation(void *data, - struct wl_extended_output *wl_extended_output, - int32_t rotation); - static const struct wl_extended_output_listener extended_output_listener; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp index 82b294b09..f3373eb23 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp @@ -44,7 +44,6 @@ #include "qwaylandwindow.h" #include "wayland-client.h" -#include "wayland-surface-extension-client-protocol.h" #include "qwaylanddisplay.h" @@ -56,49 +55,25 @@ QT_USE_NAMESPACE -QWaylandSurfaceExtension::QWaylandSurfaceExtension(QWaylandDisplay *display, uint32_t id) -{ - m_surface_extension = static_cast<struct wl_surface_extension *>( - wl_registry_bind(display->wl_registry(), id, &wl_surface_extension_interface, 1)); -} - -QWaylandExtendedSurface *QWaylandSurfaceExtension::getExtendedWindow(QWaylandWindow *window) -{ - struct wl_surface *surface = window->wl_surface(); - Q_ASSERT(surface); - struct wl_extended_surface *extended_surface = - wl_surface_extension_get_extended_surface(m_surface_extension,surface); - - return new QWaylandExtendedSurface(window,extended_surface); -} - - -QWaylandExtendedSurface::QWaylandExtendedSurface(QWaylandWindow *window, struct wl_extended_surface *extended_surface) - : m_window(window) - , m_extended_surface(extended_surface) +QWaylandExtendedSurface::QWaylandExtendedSurface(QWaylandWindow *window, struct ::wl_extended_surface *extended_surface) + : QtWayland::wl_extended_surface(extended_surface) + , m_window(window) , m_exposed(true) { - wl_extended_surface_add_listener(m_extended_surface,&QWaylandExtendedSurface::extended_surface_listener,this); } void QWaylandExtendedSurface::updateGenericProperty(const QString &name, const QVariant &value) { - QByteArray byteValue; QDataStream ds(&byteValue, QIODevice::WriteOnly); ds << value; - struct wl_array data; - data.size = byteValue.size(); - data.data = (void*)byteValue.constData(); - data.alloc = 0; - - wl_extended_surface_update_generic_property(m_extended_surface,qPrintable(name),&data); + update_generic_property(name, byteValue); - m_properties.insert(name,value); + m_properties.insert(name, value); QWaylandNativeInterface *nativeInterface = static_cast<QWaylandNativeInterface *>( QGuiApplication::platformNativeInterface()); - nativeInterface->emitWindowPropertyChanged(m_window,name); + nativeInterface->emitWindowPropertyChanged(m_window, name); } static int32_t waylandRotationFromScreenOrientation(Qt::ScreenOrientation orientation) @@ -114,7 +89,7 @@ static int32_t waylandRotationFromScreenOrientation(Qt::ScreenOrientation orient void QWaylandExtendedSurface::setContentOrientation(Qt::ScreenOrientation orientation) { - wl_extended_surface_set_content_orientation(m_extended_surface, waylandRotationFromScreenOrientation(orientation)); + set_content_orientation(waylandRotationFromScreenOrientation(orientation)); } QVariantMap QWaylandExtendedSurface::properties() const @@ -132,18 +107,14 @@ QVariant QWaylandExtendedSurface::property(const QString &name, const QVariant & return m_properties.value(name,defaultValue); } -void QWaylandExtendedSurface::onscreen_visibility(void *data, wl_extended_surface *wl_extended_surface, int32_t visible) +void QWaylandExtendedSurface::extended_surface_onscreen_visibility(int32_t visible) { - QWaylandExtendedSurface *extendedWindow = static_cast<QWaylandExtendedSurface *>(data); - Q_UNUSED(extendedWindow); - Q_UNUSED(wl_extended_surface); - // Do not send events when the state is not changing... - if (visible == extendedWindow->m_window->isExposed()) + if (visible == m_exposed) return; - extendedWindow->m_exposed = visible; - QWaylandWindow *w = extendedWindow->m_window; + m_exposed = visible; + QWaylandWindow *w = m_window; QWindowSystemInterface::handleExposeEvent(w->window(), visible ? QRegion(w->geometry()) @@ -151,40 +122,29 @@ void QWaylandExtendedSurface::onscreen_visibility(void *data, wl_extended_surfac QWindowSystemInterface::flushWindowSystemEvents(); } -void QWaylandExtendedSurface::set_generic_property(void *data, wl_extended_surface *wl_extended_surface, const char *name, wl_array *value) +void QWaylandExtendedSurface::extended_surface_set_generic_property(const QString &name, wl_array *value) { - Q_UNUSED(wl_extended_surface); - - QWaylandExtendedSurface *extended_window = static_cast<QWaylandExtendedSurface *>(data); + QByteArray data = QByteArray::fromRawData(static_cast<char *>(value->data), value->size); QVariant variantValue; - QByteArray baValue = QByteArray((const char*)value->data, value->size); - QDataStream ds(&baValue, QIODevice::ReadOnly); + QDataStream ds(data); ds >> variantValue; - QString qstring_name = QString::fromLatin1(name); - extended_window->m_properties.insert(qstring_name,variantValue); + m_properties.insert(name, variantValue); QWaylandNativeInterface *nativeInterface = static_cast<QWaylandNativeInterface *>( - QGuiApplication::platformNativeInterface()); - nativeInterface->emitWindowPropertyChanged(extended_window->m_window,QString::fromLatin1(name)); + QGuiApplication::platformNativeInterface()); + nativeInterface->emitWindowPropertyChanged(m_window, name); } Qt::WindowFlags QWaylandExtendedSurface::setWindowFlags(Qt::WindowFlags flags) { uint wlFlags = 0; + if (flags & Qt::WindowStaysOnTopHint) wlFlags |= WL_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP; if (flags & Qt::WindowOverridesSystemGestures) wlFlags |= WL_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES; - wl_extended_surface_set_window_flags(m_extended_surface, wlFlags); + set_window_flags(wlFlags); - return flags & ( - Qt::WindowStaysOnTopHint - | Qt::WindowOverridesSystemGestures - ); + return flags & (Qt::WindowStaysOnTopHint | Qt::WindowOverridesSystemGestures); } - -const struct wl_extended_surface_listener QWaylandExtendedSurface::extended_surface_listener = { - QWaylandExtendedSurface::onscreen_visibility, - QWaylandExtendedSurface::set_generic_property -}; diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h index 940d9ab77..16a76dcef 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h +++ b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h @@ -46,31 +46,22 @@ #include <QtCore/QVariant> #include <wayland-client.h> +#include <qwayland-surface-extension.h> QT_BEGIN_NAMESPACE class QWaylandDisplay; class QWaylandWindow; -class QWaylandExtendedSurface; -class QWaylandSurfaceExtension +class QWaylandExtendedSurface : public QtWayland::wl_extended_surface { public: - QWaylandSurfaceExtension(QWaylandDisplay *display, uint32_t id); - - QWaylandExtendedSurface *getExtendedWindow(QWaylandWindow *window); -private: - struct wl_surface_extension *m_surface_extension; -}; - -class QWaylandExtendedSurface -{ -public: - QWaylandExtendedSurface(QWaylandWindow *window, struct wl_extended_surface *extended_surface); + QWaylandExtendedSurface(QWaylandWindow *window, struct ::wl_extended_surface *extended_surface); void setContentOrientation(Qt::ScreenOrientation orientation); void updateGenericProperty(const QString &name, const QVariant &value); + QVariantMap properties() const; QVariant property(const QString &name); QVariant property(const QString &name, const QVariant &defaultValue); @@ -80,22 +71,12 @@ public: bool isExposed() const { return m_exposed; } private: - QWaylandWindow *m_window; - struct wl_extended_surface *m_extended_surface; + void extended_surface_onscreen_visibility(int32_t visible) Q_DECL_OVERRIDE; + void extended_surface_set_generic_property(const QString &name, wl_array *value) Q_DECL_OVERRIDE; + QWaylandWindow *m_window; QVariantMap m_properties; - static void onscreen_visibility(void *data, - struct wl_extended_surface *wl_extended_surface, - int32_t visible); - - static void set_generic_property(void *data, - struct wl_extended_surface *wl_extended_surface, - const char *name, - struct wl_array *value); - - static const struct wl_extended_surface_listener extended_surface_listener; - bool m_exposed; }; diff --git a/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp index 9820854da..fe32628d6 100644 --- a/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp @@ -66,7 +66,8 @@ QT_USE_NAMESPACE QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id) - : mQDisplay(display) + : QtWayland::wl_seat(display->wl_registry(), id) + , mQDisplay(display) , mDisplay(display->wl_display()) , mCaps(0) , mTransferDevice(0) @@ -81,10 +82,6 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id) , mXkbState(0) #endif { - mSeat = static_cast<struct wl_seat *>(wl_registry_bind(display->wl_registry(), id, &wl_seat_interface, 1)); - wl_seat_add_listener(mSeat, &seatListener, this); - wl_seat_set_user_data(mSeat, this); - #ifndef QT_NO_WAYLAND_XKB xkb_rule_names names; names.rules = strdup("evdev"); @@ -122,59 +119,26 @@ QWaylandInputDevice::~QWaylandInputDevice() #endif } -const struct wl_seat_listener QWaylandInputDevice::seatListener = { - QWaylandInputDevice::seat_capabilities -}; - -const struct wl_pointer_listener QWaylandInputDevice::pointerListener = { - QWaylandInputDevice::pointer_enter, - QWaylandInputDevice::pointer_leave, - QWaylandInputDevice::pointer_motion, - QWaylandInputDevice::pointer_button, - QWaylandInputDevice::pointer_axis -}; - -const struct wl_keyboard_listener QWaylandInputDevice::keyboardListener = { - QWaylandInputDevice::keyboard_keymap, - QWaylandInputDevice::keyboard_enter, - QWaylandInputDevice::keyboard_leave, - QWaylandInputDevice::keyboard_key, - QWaylandInputDevice::keyboard_modifiers -}; - -const struct wl_touch_listener QWaylandInputDevice::touchListener = { - QWaylandInputDevice::touch_down, - QWaylandInputDevice::touch_up, - QWaylandInputDevice::touch_motion, - QWaylandInputDevice::touch_frame, - QWaylandInputDevice::touch_cancel -}; - -void QWaylandInputDevice::seat_capabilities(void *data, struct wl_seat *seat, uint32_t caps) +void QWaylandInputDevice::seat_capabilities(uint32_t caps) { - QWaylandInputDevice *self = static_cast<QWaylandInputDevice *>(data); - self->mCaps = caps; + mCaps = caps; - if (caps & WL_SEAT_CAPABILITY_KEYBOARD) { - self->mDeviceInterfaces.keyboard = wl_seat_get_keyboard(seat); - wl_keyboard_add_listener(self->mDeviceInterfaces.keyboard, &keyboardListener, self); - } + if (caps & WL_SEAT_CAPABILITY_KEYBOARD) + QtWayland::wl_keyboard::init(get_keyboard()); if (caps & WL_SEAT_CAPABILITY_POINTER) { - self->mDeviceInterfaces.pointer = wl_seat_get_pointer(seat); - self->mDeviceInterfaces.pointerSurface = self->mQDisplay->createSurface(self); - wl_pointer_add_listener(self->mDeviceInterfaces.pointer, &pointerListener, self); + QtWayland::wl_pointer::init(get_pointer()); + pointerSurface = mQDisplay->createSurface(this); } if (caps & WL_SEAT_CAPABILITY_TOUCH) { - self->mDeviceInterfaces.touch = wl_seat_get_touch(seat); - wl_touch_add_listener(self->mDeviceInterfaces.touch, &touchListener, self); - - if (!self->mTouchDevice) { - self->mTouchDevice = new QTouchDevice; - self->mTouchDevice->setType(QTouchDevice::TouchScreen); - self->mTouchDevice->setCapabilities(QTouchDevice::Position); - QWindowSystemInterface::registerTouchDevice(self->mTouchDevice); + QtWayland::wl_touch::init(get_touch()); + + if (!mTouchDevice) { + mTouchDevice = new QTouchDevice; + mTouchDevice->setType(QTouchDevice::TouchScreen); + mTouchDevice->setCapabilities(QTouchDevice::Position); + QWindowSystemInterface::registerTouchDevice(mTouchDevice); } } } @@ -189,7 +153,7 @@ void QWaylandInputDevice::handleWindowDestroyed(QWaylandWindow *window) void QWaylandInputDevice::setTransferDevice(struct wl_data_device *device) { - mTransferDevice = device; + mTransferDevice = device; } struct wl_data_device *QWaylandInputDevice::transferDevice() const @@ -206,51 +170,37 @@ void QWaylandInputDevice::removeMouseButtonFromState(Qt::MouseButton button) void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image) { if (mCaps & WL_SEAT_CAPABILITY_POINTER) { - wl_pointer_set_cursor(mDeviceInterfaces.pointer, mEnterSerial, mDeviceInterfaces.pointerSurface, - image->hotspot_x, image->hotspot_y); - wl_surface_attach(mDeviceInterfaces.pointerSurface, buffer, 0, 0); - wl_surface_damage(mDeviceInterfaces.pointerSurface, 0, 0, image->width, image->height); - wl_surface_commit(mDeviceInterfaces.pointerSurface); + set_cursor(mEnterSerial, pointerSurface, + image->hotspot_x, image->hotspot_y); + wl_surface_attach(pointerSurface, buffer, 0, 0); + wl_surface_damage(pointerSurface, 0, 0, image->width, image->height); + wl_surface_commit(pointerSurface); } } -void QWaylandInputDevice::pointer_enter(void *data, - struct wl_pointer *pointer, - uint32_t serial, struct wl_surface *surface, +void QWaylandInputDevice::pointer_enter(uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy) { - Q_UNUSED(pointer); Q_UNUSED(sx); Q_UNUSED(sy); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; if (!surface) return; QGuiApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); - QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface); + QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface); window->handleMouseEnter(); - window->handleMouse(inputDevice, - inputDevice->mTime, - inputDevice->mSurfacePos, - inputDevice->mGlobalPos, - inputDevice->mButtons, - Qt::NoModifier); - inputDevice->mPointerFocus = window; - - inputDevice->mTime = QWaylandDisplay::currentTimeMillisec(); - inputDevice->mSerial = serial; - inputDevice->mEnterSerial = serial; + window->handleMouse(this, mTime, mSurfacePos, mGlobalPos, mButtons, Qt::NoModifier); + mPointerFocus = window; + + mTime = QWaylandDisplay::currentTimeMillisec(); + mSerial = serial; + mEnterSerial = serial; } -void QWaylandInputDevice::pointer_leave(void *data, - struct wl_pointer *pointer, - uint32_t time, struct wl_surface *surface) +void QWaylandInputDevice::pointer_leave(uint32_t time, struct wl_surface *surface) { - Q_UNUSED(pointer); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - // The event may arrive after destroying the window, indicated by // a null surface. if (!surface) @@ -258,24 +208,20 @@ void QWaylandInputDevice::pointer_leave(void *data, QGuiApplication::restoreOverrideCursor(); - QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface); + QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface); window->handleMouseLeave(); - inputDevice->mPointerFocus = 0; - inputDevice->mButtons = Qt::NoButton; + mPointerFocus = 0; + mButtons = Qt::NoButton; - inputDevice->mTime = time; + mTime = time; } -void QWaylandInputDevice::pointer_motion(void *data, - struct wl_pointer *pointer, - uint32_t time, - wl_fixed_t surface_x, wl_fixed_t surface_y) +void QWaylandInputDevice::pointer_motion(uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) { - Q_UNUSED(pointer); Q_UNUSED(surface_x); Q_UNUSED(surface_y); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window = inputDevice->mPointerFocus; + + QWaylandWindow *window = mPointerFocus; if (window == NULL) { // We destroyed the pointer focus surface, but the server @@ -288,27 +234,18 @@ void QWaylandInputDevice::pointer_motion(void *data, QPointF global = window->window()->mapToGlobal(pos.toPoint()); global += delta; - inputDevice->mSurfacePos = pos; - inputDevice->mGlobalPos = global; - inputDevice->mTime = time; + mSurfacePos = pos; + mGlobalPos = global; + mTime = time; - window->handleMouse(inputDevice, - time, - inputDevice->mSurfacePos, - inputDevice->mGlobalPos, - inputDevice->mButtons, - Qt::NoModifier); + window->handleMouse(this, time, mSurfacePos, mGlobalPos, mButtons, Qt::NoModifier); } -void QWaylandInputDevice::pointer_button(void *data, - struct wl_pointer *pointer, - uint32_t serial, uint32_t time, +void QWaylandInputDevice::pointer_button(uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { - Q_UNUSED(pointer); Q_UNUSED(serial); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window = inputDevice->mPointerFocus; + QWaylandWindow *window = mPointerFocus; Qt::MouseButton qt_button; // translate from kernel (input.h) 'button' to corresponding Qt:MouseButton. @@ -334,32 +271,20 @@ void QWaylandInputDevice::pointer_button(void *data, } if (state) - inputDevice->mButtons |= qt_button; + mButtons |= qt_button; else - inputDevice->mButtons &= ~qt_button; + mButtons &= ~qt_button; - inputDevice->mTime = time; - inputDevice->mSerial = serial; + mTime = time; + mSerial = serial; - if (window) { - window->handleMouse(inputDevice, - time, - inputDevice->mSurfacePos, - inputDevice->mGlobalPos, - inputDevice->mButtons, - Qt::NoModifier); - } + if (window) + window->handleMouse(this, time, mSurfacePos, mGlobalPos, mButtons, Qt::NoModifier); } -void QWaylandInputDevice::pointer_axis(void *data, - struct wl_pointer *pointer, - uint32_t time, - uint32_t axis, - int32_t value) +void QWaylandInputDevice::pointer_axis(uint32_t time, uint32_t axis, int32_t value) { - Q_UNUSED(pointer); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window = inputDevice->mPointerFocus; + QWaylandWindow *window = mPointerFocus; QPoint pixelDelta; QPoint angleDelta; @@ -375,10 +300,8 @@ void QWaylandInputDevice::pointer_axis(void *data, } QWindowSystemInterface::handleWheelEvent(window->window(), - time, - inputDevice->mSurfacePos, - inputDevice->mGlobalPos, - pixelDelta, + time, mSurfacePos, + mGlobalPos, pixelDelta, angleDelta); } @@ -497,71 +420,49 @@ static uint32_t translateKey(uint32_t sym, char *string, size_t size) #endif // QT_NO_WAYLAND_XKB -void QWaylandInputDevice::keyboard_keymap(void *data, - struct wl_keyboard *keyboard, - uint32_t format, - int32_t fd, - uint32_t size) +void QWaylandInputDevice::keyboard_keymap(uint32_t format, int32_t fd, uint32_t size) { - Q_UNUSED(data); - Q_UNUSED(keyboard); Q_UNUSED(format); Q_UNUSED(fd); Q_UNUSED(size); } -void QWaylandInputDevice::keyboard_enter(void *data, - struct wl_keyboard *keyboard, - uint32_t time, - struct wl_surface *surface, - struct wl_array *keys) +void QWaylandInputDevice::keyboard_enter(uint32_t time, struct wl_surface *surface, struct wl_array *keys) { - Q_UNUSED(keyboard); Q_UNUSED(time); Q_UNUSED(keys); if (!surface) return; - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface); - inputDevice->mKeyboardFocus = window; - inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(inputDevice); + QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface); + mKeyboardFocus = window; + mQDisplay->setLastKeyboardFocusInputDevice(this); QWindowSystemInterface::handleWindowActivated(window->window()); } -void QWaylandInputDevice::keyboard_leave(void *data, - struct wl_keyboard *keyboard, - uint32_t time, - struct wl_surface *surface) +void QWaylandInputDevice::keyboard_leave(uint32_t time, struct wl_surface *surface) { - Q_UNUSED(keyboard); Q_UNUSED(time); Q_UNUSED(surface); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - inputDevice->mKeyboardFocus = NULL; - inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(0); + mKeyboardFocus = NULL; + mQDisplay->setLastKeyboardFocusInputDevice(0); } -void QWaylandInputDevice::keyboard_key(void *data, - struct wl_keyboard *keyboard, - uint32_t serial, uint32_t time, - uint32_t key, uint32_t state) +void QWaylandInputDevice::keyboard_key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { - Q_UNUSED(keyboard); Q_UNUSED(serial); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window = inputDevice->mKeyboardFocus; + QWaylandWindow *window = mKeyboardFocus; #ifndef QT_NO_WAYLAND_XKB - if (!inputDevice->mXkbMap) + if (!mXkbMap) return; uint32_t code = key + 8; bool isDown = state != 0; const xkb_keysym_t *syms; - uint32_t numSyms = xkb_key_get_syms(inputDevice->mXkbState, code, &syms); - xkb_state_update_key(inputDevice->mXkbState, code, + uint32_t numSyms = xkb_key_get_syms(mXkbState, code, &syms); + xkb_state_update_key(mXkbState, code, isDown ? XKB_KEY_DOWN : XKB_KEY_UP); if (!window) { @@ -572,7 +473,7 @@ void QWaylandInputDevice::keyboard_key(void *data, if (numSyms == 1) { xkb_keysym_t sym = syms[0]; - Qt::KeyboardModifiers modifiers = translateModifiers(inputDevice->mXkbState); + Qt::KeyboardModifiers modifiers = translateModifiers(mXkbState); QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease; char s[2]; @@ -597,20 +498,16 @@ void QWaylandInputDevice::keyboard_key(void *data, #endif } -void QWaylandInputDevice::keyboard_modifiers(void *data, - struct wl_keyboard *keyboard, - uint32_t serial, +void QWaylandInputDevice::keyboard_modifiers(uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { - Q_UNUSED(keyboard); Q_UNUSED(serial); #ifndef QT_NO_WAYLAND_XKB - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - if (inputDevice->mXkbState) - xkb_state_update_mask(inputDevice->mXkbState, + if (mXkbState) + xkb_state_update_mask(mXkbState, mods_depressed, mods_latched, mods_locked, 0, 0, group); #else @@ -622,70 +519,43 @@ void QWaylandInputDevice::keyboard_modifiers(void *data, #endif } -void QWaylandInputDevice::touch_down(void *data, - struct wl_touch *touch, - uint32_t serial, +void QWaylandInputDevice::touch_down(uint32_t serial, uint32_t time, struct wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y) { - Q_UNUSED(touch); Q_UNUSED(serial); Q_UNUSED(time); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - inputDevice->mTouchFocus = static_cast<QWaylandWindow *>(wl_surface_get_user_data(surface)); - inputDevice->handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointPressed); + mTouchFocus = QWaylandWindow::fromWlSurface(surface); + handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointPressed); } -void QWaylandInputDevice::touch_up(void *data, - struct wl_touch *touch, - uint32_t serial, - uint32_t time, - int32_t id) +void QWaylandInputDevice::touch_up(uint32_t serial, uint32_t time, int32_t id) { - Q_UNUSED(touch); Q_UNUSED(serial); Q_UNUSED(time); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - inputDevice->mTouchFocus = 0; - inputDevice->handleTouchPoint(id, 0, 0, Qt::TouchPointReleased); + mTouchFocus = 0; + handleTouchPoint(id, 0, 0, Qt::TouchPointReleased); } -void QWaylandInputDevice::touch_motion(void *data, - struct wl_touch *touch, - uint32_t time, - int32_t id, - wl_fixed_t x, - wl_fixed_t y) +void QWaylandInputDevice::touch_motion(uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) { - Q_UNUSED(touch); Q_UNUSED(time); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - inputDevice->handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointMoved); + handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointMoved); } -void QWaylandInputDevice::touch_frame(void *data, struct wl_touch *touch) +void QWaylandInputDevice::touch_cancel() { - Q_UNUSED(touch); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - inputDevice->handleTouchFrame(); -} - -void QWaylandInputDevice::touch_cancel(void *data, struct wl_touch *touch) -{ - Q_UNUSED(touch); - QWaylandInputDevice *self = static_cast<QWaylandInputDevice *>(data); - - self->mPrevTouchPoints.clear(); - self->mTouchPoints.clear(); + mPrevTouchPoints.clear(); + mTouchPoints.clear(); - QWaylandTouchExtension *touchExt = self->mQDisplay->touchExtension(); + QWaylandTouchExtension *touchExt = mQDisplay->touchExtension(); if (touchExt) touchExt->touchCanceled(); - QWindowSystemInterface::handleTouchCancelEvent(0, self->mTouchDevice); + QWindowSystemInterface::handleTouchCancelEvent(0, mTouchDevice); } void QWaylandInputDevice::handleTouchPoint(int id, double x, double y, Qt::TouchPointState state) @@ -726,7 +596,7 @@ void QWaylandInputDevice::handleTouchPoint(int id, double x, double y, Qt::Touch mTouchPoints.append(tp); } -void QWaylandInputDevice::handleTouchFrame() +void QWaylandInputDevice::touch_frame() { // Copy all points, that are in the previous but not in the current list, as stationary. for (int i = 0; i < mPrevTouchPoints.count(); ++i) { diff --git a/src/plugins/platforms/wayland_common/qwaylandinputdevice.h b/src/plugins/platforms/wayland_common/qwaylandinputdevice.h index 716343822..c0e57a909 100644 --- a/src/plugins/platforms/wayland_common/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland_common/qwaylandinputdevice.h @@ -52,6 +52,8 @@ #include <wayland-client.h> +#include "qwayland-wayland.h" + #ifndef QT_NO_WAYLAND_XKB struct xkb_context; struct xkb_keymap; @@ -63,14 +65,15 @@ QT_BEGIN_NAMESPACE class QWaylandWindow; class QWaylandDisplay; -class QWaylandInputDevice { +class QWaylandInputDevice : public QtWayland::wl_pointer, public QtWayland::wl_keyboard, public QtWayland::wl_touch, public QtWayland::wl_seat +{ public: QWaylandInputDevice(QWaylandDisplay *display, uint32_t id); ~QWaylandInputDevice(); uint32_t capabilities() const { return mCaps; } - struct wl_seat *wl_seat() const { return mSeat; } + struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); } void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image); void handleWindowDestroyed(QWaylandWindow *window); @@ -86,15 +89,9 @@ private: QWaylandDisplay *mQDisplay; struct wl_display *mDisplay; - struct wl_seat *mSeat; uint32_t mCaps; - struct { - struct wl_pointer *pointer; - struct wl_surface *pointerSurface; - struct wl_keyboard *keyboard; - struct wl_touch *touch; - } mDeviceInterfaces; + struct wl_surface *pointerSurface; struct wl_data_device *mTransferDevice; QWaylandWindow *mPointerFocus; @@ -108,91 +105,53 @@ private: uint32_t mSerial; uint32_t mEnterSerial; - static const struct wl_seat_listener seatListener; - - static void seat_capabilities(void *data, - struct wl_seat *seat, - uint32_t caps); - - static const struct wl_pointer_listener pointerListener; - - static void pointer_enter(void *data, - struct wl_pointer *pointer, - uint32_t serial, struct wl_surface *surface, - wl_fixed_t sx, wl_fixed_t sy); - static void pointer_leave(void *data, - struct wl_pointer *pointer, - uint32_t time, struct wl_surface *surface); - static void pointer_motion(void *data, - struct wl_pointer *pointer, - uint32_t time, - wl_fixed_t sx, wl_fixed_t sy); - static void pointer_button(void *data, - struct wl_pointer *pointer, - uint32_t serial, uint32_t time, - uint32_t button, uint32_t state); - static void pointer_axis(void *data, - struct wl_pointer *pointer, - uint32_t time, - uint32_t axis, - wl_fixed_t value); - - static const struct wl_keyboard_listener keyboardListener; - - static void keyboard_keymap(void *data, - struct wl_keyboard *keyboard, - uint32_t format, - int32_t fd, - uint32_t size); - static void keyboard_enter(void *data, - struct wl_keyboard *keyboard, - uint32_t time, - struct wl_surface *surface, - struct wl_array *keys); - static void keyboard_leave(void *data, - struct wl_keyboard *keyboard, - uint32_t time, - struct wl_surface *surface); - static void keyboard_key(void *data, - struct wl_keyboard *keyboard, - uint32_t serial, uint32_t time, - uint32_t key, uint32_t state); - static void keyboard_modifiers(void *data, - struct wl_keyboard *keyboard, - uint32_t serial, - uint32_t mods_depressed, - uint32_t mods_latched, - uint32_t mods_locked, - uint32_t group); - - static const struct wl_touch_listener touchListener; - - static void touch_down(void *data, - struct wl_touch *touch, - uint32_t serial, - uint32_t time, - struct wl_surface *surface, - int32_t id, - wl_fixed_t x, - wl_fixed_t y); - static void touch_up(void *data, - struct wl_touch *touch, - uint32_t serial, - uint32_t time, - int32_t id); - static void touch_motion(void *data, - struct wl_touch *touch, - uint32_t time, - int32_t id, - wl_fixed_t x, - wl_fixed_t y); - static void touch_frame(void *data, - struct wl_touch *touch); - static void touch_cancel(void *data, - struct wl_touch *touch); + void seat_capabilities(uint32_t caps) Q_DECL_OVERRIDE; + + void pointer_enter(uint32_t serial, struct wl_surface *surface, + wl_fixed_t sx, wl_fixed_t sy) Q_DECL_OVERRIDE; + void pointer_leave(uint32_t time, struct wl_surface *surface); + void pointer_motion(uint32_t time, + wl_fixed_t sx, wl_fixed_t sy) Q_DECL_OVERRIDE; + void pointer_button(uint32_t serial, uint32_t time, + uint32_t button, uint32_t state) Q_DECL_OVERRIDE; + void pointer_axis(uint32_t time, + uint32_t axis, + wl_fixed_t value) Q_DECL_OVERRIDE; + + void keyboard_keymap(uint32_t format, + int32_t fd, + uint32_t size) Q_DECL_OVERRIDE; + void keyboard_enter(uint32_t time, + struct wl_surface *surface, + struct wl_array *keys) Q_DECL_OVERRIDE; + void keyboard_leave(uint32_t time, + struct wl_surface *surface) Q_DECL_OVERRIDE; + void keyboard_key(uint32_t serial, uint32_t time, + uint32_t key, uint32_t state) Q_DECL_OVERRIDE; + void keyboard_modifiers(uint32_t serial, + uint32_t mods_depressed, + uint32_t mods_latched, + uint32_t mods_locked, + uint32_t group) Q_DECL_OVERRIDE; + + void touch_down(uint32_t serial, + uint32_t time, + struct wl_surface *surface, + int32_t id, + wl_fixed_t x, + wl_fixed_t y) Q_DECL_OVERRIDE; + void touch_up(uint32_t serial, + uint32_t time, + int32_t id) Q_DECL_OVERRIDE; + void touch_motion(uint32_t time, + int32_t id, + wl_fixed_t x, + wl_fixed_t y) Q_DECL_OVERRIDE; + void touch_frame() Q_DECL_OVERRIDE; + void touch_cancel() Q_DECL_OVERRIDE; void handleTouchPoint(int id, double x, double y, Qt::TouchPointState state); - void handleTouchFrame(); + QList<QWindowSystemInterface::TouchPoint> mTouchPoints; QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints; QTouchDevice *mTouchDevice; diff --git a/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp index f5829b275..31d25c0f9 100644 --- a/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp @@ -64,7 +64,7 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re if (lowerCaseResource == "display") return m_integration->display()->wl_display(); if (lowerCaseResource == "compositor") - return m_integration->display()->wl_compositor(); + return const_cast<wl_compositor *>(m_integration->display()->wl_compositor()); return 0; } @@ -76,7 +76,7 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc if (lowerCaseResource == "display") return m_integration->display()->wl_display(); if (lowerCaseResource == "compositor") - return m_integration->display()->wl_compositor(); + return const_cast<wl_compositor *>(m_integration->display()->wl_compositor()); if (lowerCaseResource == "surface") { return ((QWaylandWindow *) window->handle())->wl_surface(); } diff --git a/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp b/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp index 76d91c790..0f4b10bbc 100644 --- a/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp @@ -42,34 +42,26 @@ #include "qwaylandqtkey.h" #include "qwaylandinputdevice.h" -#include "wayland-qtkey-extension-client-protocol.h" - QT_USE_NAMESPACE QWaylandQtKeyExtension::QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id) - : m_display(display) + : QtWayland::wl_qtkey_extension(display->wl_registry(), id) + , m_display(display) { - m_qtkey = static_cast<struct wl_qtkey_extension *>(wl_registry_bind(display->wl_registry(), id, &wl_qtkey_extension_interface, 1)); - wl_qtkey_extension_add_listener(m_qtkey, &qtkey_listener, this); } -void QWaylandQtKeyExtension::handle_qtkey(void *data, - struct wl_qtkey_extension *ext, - uint32_t time, - uint32_t type, - uint32_t key, - uint32_t modifiers, - uint32_t nativeScanCode, - uint32_t nativeVirtualKey, - uint32_t nativeModifiers, - const char *text, - uint32_t autorep, - uint32_t count) +void QWaylandQtKeyExtension::qtkey_extension_qtkey(uint32_t time, + uint32_t type, + uint32_t key, + uint32_t modifiers, + uint32_t nativeScanCode, + uint32_t nativeVirtualKey, + uint32_t nativeModifiers, + const QString &text, + uint32_t autorep, + uint32_t count) { - Q_UNUSED(ext); - QWaylandQtKeyExtension *self = static_cast<QWaylandQtKeyExtension *>(data); - - QList<QWaylandInputDevice *> inputDevices = self->m_display->inputDevices(); + QList<QWaylandInputDevice *> inputDevices = m_display->inputDevices(); if (inputDevices.isEmpty()) { qWarning("wl_qtkey_extension: handle_qtkey: No input device"); return; @@ -85,11 +77,6 @@ void QWaylandQtKeyExtension::handle_qtkey(void *data, QWindow *window = win->window(); QWindowSystemInterface::handleExtendedKeyEvent(window, time, QEvent::Type(type), key, Qt::KeyboardModifiers(modifiers), - nativeScanCode, nativeVirtualKey, nativeModifiers, QString::fromUtf8(text), + nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count); } - -const struct wl_qtkey_extension_listener QWaylandQtKeyExtension::qtkey_listener = { - QWaylandQtKeyExtension::handle_qtkey -}; - diff --git a/src/plugins/platforms/wayland_common/qwaylandqtkey.h b/src/plugins/platforms/wayland_common/qwaylandqtkey.h index adcce6134..cc7d76d41 100644 --- a/src/plugins/platforms/wayland_common/qwaylandqtkey.h +++ b/src/plugins/platforms/wayland_common/qwaylandqtkey.h @@ -45,33 +45,28 @@ #include "qwaylanddisplay.h" #include <qpa/qwindowsysteminterface.h> -class wl_qtkey_extension; +#include "qwayland-qtkey-extension.h" QT_BEGIN_NAMESPACE -class QWaylandQtKeyExtension +class QWaylandQtKeyExtension : public QtWayland::wl_qtkey_extension { public: QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id); private: QWaylandDisplay *m_display; - wl_qtkey_extension *m_qtkey; - static const struct wl_qtkey_extension_listener qtkey_listener; - - static void handle_qtkey(void *data, - struct wl_qtkey_extension *ext, - uint32_t time, - uint32_t type, - uint32_t key, - uint32_t modifiers, - uint32_t nativeScanCode, - uint32_t nativeVirtualKey, - uint32_t nativeModifiers, - const char *text, - uint32_t autorep, - uint32_t count); + void qtkey_extension_qtkey(uint32_t time, + uint32_t type, + uint32_t key, + uint32_t modifiers, + uint32_t nativeScanCode, + uint32_t nativeVirtualKey, + uint32_t nativeModifiers, + const QString &text, + uint32_t autorep, + uint32_t count) Q_DECL_OVERRIDE; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland_common/qwaylandscreen.cpp b/src/plugins/platforms/wayland_common/qwaylandscreen.cpp index 8393058fd..bda0192a1 100644 --- a/src/plugins/platforms/wayland_common/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandscreen.cpp @@ -49,20 +49,17 @@ QT_USE_NAMESPACE -QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output) - : QPlatformScreen() +QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id) + : QtWayland::wl_output(waylandDisplay->wl_registry(), id) , mWaylandDisplay(waylandDisplay) - , mOutput(output) , mExtendedOutput(0) , mDepth(32) , mRefreshRate(60000) , mFormat(QImage::Format_ARGB32_Premultiplied) , mWaylandCursor(new QWaylandCursor(this)) { - //maybe the global is sent after the first screen? - if (waylandDisplay->outputExtension()) { - mExtendedOutput = waylandDisplay->outputExtension()->getExtendedOutput(this); - } + // handle case of output extension global being sent after outputs + createExtendedOutput(); } QWaylandScreen::~QWaylandScreen() @@ -75,15 +72,6 @@ QWaylandDisplay * QWaylandScreen::display() const return mWaylandDisplay; } -void QWaylandScreen::setGeometry(const QRect &geom) -{ - if (mGeometry == geom) - return; - - mGeometry = geom; - QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); -} - QRect QWaylandScreen::geometry() const { return mGeometry; @@ -127,10 +115,11 @@ QWaylandExtendedOutput *QWaylandScreen::extendedOutput() const return mExtendedOutput; } -void QWaylandScreen::setExtendedOutput(QWaylandExtendedOutput *extendedOutput) +void QWaylandScreen::createExtendedOutput() { - Q_ASSERT(!mExtendedOutput); - mExtendedOutput = extendedOutput; + QtWayland::wl_output_extension *extension = mWaylandDisplay->outputExtension(); + if (!mExtendedOutput && extension) + mExtendedOutput = new QWaylandExtendedOutput(this, extension->get_extended_output(output())); } QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) @@ -139,15 +128,41 @@ QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) return static_cast<QWaylandScreen *>(platformScreen); } -void QWaylandScreen::handleMode(const QSize &size, int refreshRate) +void QWaylandScreen::output_mode(uint32_t flags, int width, int height, int refresh) { + if (!(flags & WL_OUTPUT_MODE_CURRENT)) + return; + + QSize size(width, height); + if (size != mGeometry.size()) { mGeometry.setSize(size); QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); } - if (refreshRate != mRefreshRate) { - mRefreshRate = refreshRate; + if (refresh != mRefreshRate) { + mRefreshRate = refresh; QWindowSystemInterface::handleScreenRefreshRateChange(screen(), mRefreshRate); } } + +void QWaylandScreen::output_geometry(int32_t x, int32_t y, + int32_t width, int32_t height, + int subpixel, + const QString &make, + const QString &model, + int32_t transform) +{ + Q_UNUSED(subpixel); + Q_UNUSED(make); + Q_UNUSED(model); + Q_UNUSED(transform); + + QRect geom(x, y, width, height); + + if (mGeometry == geom) + return; + + mGeometry = geom; + QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); +} diff --git a/src/plugins/platforms/wayland_common/qwaylandscreen.h b/src/plugins/platforms/wayland_common/qwaylandscreen.h index 3d4b2948a..005f25eea 100644 --- a/src/plugins/platforms/wayland_common/qwaylandscreen.h +++ b/src/plugins/platforms/wayland_common/qwaylandscreen.h @@ -44,16 +44,18 @@ #include <qpa/qplatformscreen.h> +#include <qwayland-wayland.h> + QT_BEGIN_NAMESPACE class QWaylandDisplay; class QWaylandCursor; class QWaylandExtendedOutput; -class QWaylandScreen : public QPlatformScreen +class QWaylandScreen : public QPlatformScreen, QtWayland::wl_output { public: - QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output); + QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id); ~QWaylandScreen(); QWaylandDisplay *display() const; @@ -69,20 +71,23 @@ public: QPlatformCursor *cursor() const; - wl_output *output() const { return mOutput; } + ::wl_output *output() { return object(); } QWaylandExtendedOutput *extendedOutput() const; - void setExtendedOutput(QWaylandExtendedOutput *extendedOutput); + void createExtendedOutput(); static QWaylandScreen *waylandScreenFromWindow(QWindow *window); - void handleMode(const QSize &size, int refreshRate); - - void setGeometry(const QRect &geom); - private: + void output_mode(uint32_t flags, int width, int height, int refresh) Q_DECL_OVERRIDE; + void output_geometry(int32_t x, int32_t y, + int32_t width, int32_t height, + int subpixel, + const QString &make, + const QString &model, + int32_t transform) Q_DECL_OVERRIDE; + QWaylandDisplay *mWaylandDisplay; - struct wl_output *mOutput; QWaylandExtendedOutput *mExtendedOutput; QRect mGeometry; int mDepth; diff --git a/src/plugins/platforms/wayland_common/qwaylandshell.cpp b/src/plugins/platforms/wayland_common/qwaylandshell.cpp deleted file mode 100644 index 9c37235ca..000000000 --- a/src/plugins/platforms/wayland_common/qwaylandshell.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandshell.h" - -#include "qwaylandshellsurface.h" -#include "qwaylandwindow.h" - -QT_USE_NAMESPACE - -QWaylandShell::QWaylandShell(QWaylandDisplay *display, uint32_t id, uint32_t version) - : m_display(display) -{ - Q_UNUSED(version) - m_shell = static_cast<struct wl_shell *>(wl_registry_bind(m_display->wl_registry(), id, &wl_shell_interface, 1)); -} - -QWaylandShellSurface *QWaylandShell::getShellSurface(QWaylandWindow *window) -{ - Q_ASSERT(window->wl_surface()); - struct wl_shell_surface *shell_surface = wl_shell_get_shell_surface(m_shell,window->wl_surface()); - return new QWaylandShellSurface(shell_surface,window); -} diff --git a/src/plugins/platforms/wayland_common/qwaylandshell.h b/src/plugins/platforms/wayland_common/qwaylandshell.h deleted file mode 100644 index 3c2014f63..000000000 --- a/src/plugins/platforms/wayland_common/qwaylandshell.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDSHELL_H -#define QWAYLANDSHELL_H - -#include "qwaylanddisplay.h" - -QT_BEGIN_NAMESPACE - -class QWaylandWindow; -class QWaylandShellSurface; - -class QWaylandShell -{ -public: - QWaylandShell(QWaylandDisplay *display, uint32_t id, uint32_t version); - - QWaylandShellSurface *getShellSurface(QWaylandWindow *window); - -private: - struct wl_shell *m_shell; - - QWaylandDisplay *m_display; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDSHELL_H diff --git a/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp b/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp index 813922048..c9eb5da53 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp @@ -51,46 +51,44 @@ QT_USE_NAMESPACE -QWaylandShellSurface::QWaylandShellSurface(struct wl_shell_surface *shell_surface, QWaylandWindow *window) - : m_shell_surface(shell_surface) +QWaylandShellSurface::QWaylandShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window) + : QtWayland::wl_shell_surface(shell_surface) , m_window(window) , m_maximized(false) , m_fullscreen(false) { - wl_shell_surface_add_listener(m_shell_surface,&m_shell_surface_listener,this); } QWaylandShellSurface::~QWaylandShellSurface() { - wl_shell_surface_destroy(m_shell_surface); + wl_shell_surface_destroy(object()); } void QWaylandShellSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) { - wl_shell_surface_resize(m_shell_surface,inputDevice->wl_seat(), - inputDevice->serial(), - edges); + resize(inputDevice->wl_seat(), + inputDevice->serial(), + edges); } void QWaylandShellSurface::move(QWaylandInputDevice *inputDevice) { - wl_shell_surface_move(m_shell_surface, - inputDevice->wl_seat(), - inputDevice->serial()); + move(inputDevice->wl_seat(), + inputDevice->serial()); } void QWaylandShellSurface::setMaximized() { m_maximized = true; m_size = m_window->window()->geometry().size(); - wl_shell_surface_set_maximized(m_shell_surface, 0); + set_maximized(0); } void QWaylandShellSurface::setFullscreen() { m_fullscreen = true; m_size = m_window->window()->geometry().size(); - wl_shell_surface_set_fullscreen(m_shell_surface, 0, 0, 0); + set_fullscreen(0, 0, 0); } void QWaylandShellSurface::setNormal() @@ -110,7 +108,7 @@ void QWaylandShellSurface::setMinimized() void QWaylandShellSurface::setTopLevel() { - wl_shell_surface_set_toplevel(m_shell_surface); + set_toplevel(); } void QWaylandShellSurface::updateTransientParent(QWindow *parent) @@ -134,51 +132,34 @@ void QWaylandShellSurface::updateTransientParent(QWindow *parent) || wf.testFlag(Qt::WindowTransparentForInput)) flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE; - wl_shell_surface_set_transient(m_shell_surface, - parent_wayland_window->wl_surface(), - transientPos.x(), - transientPos.y(), - flags); + set_transient(parent_wayland_window->wl_surface(), + transientPos.x(), + transientPos.y(), + flags); } -void QWaylandShellSurface::setClassName(const char *_class) +void QWaylandShellSurface::setClassName(const char *className) { - wl_shell_surface_set_class(m_shell_surface, _class); + set_class(className); } void QWaylandShellSurface::setTitle(const char *title) { - wl_shell_surface_set_title(m_shell_surface, title); + set_title(title); } -void QWaylandShellSurface::ping(void *data, - struct wl_shell_surface *wl_shell_surface, - uint32_t serial) +void QWaylandShellSurface::shell_surface_ping(uint32_t serial) { - Q_UNUSED(data); - wl_shell_surface_pong(wl_shell_surface, serial); + pong(serial); } -void QWaylandShellSurface::configure(void *data, - wl_shell_surface *wl_shell_surface, - uint32_t edges, - int32_t width, - int32_t height) +void QWaylandShellSurface::shell_surface_configure(uint32_t edges, + int32_t width, + int32_t height) { - Q_UNUSED(wl_shell_surface); - QWaylandShellSurface *shell_surface = static_cast<QWaylandShellSurface *>(data); - shell_surface->m_window->configure(edges, width, height); + m_window->configure(edges, width, height); } -void QWaylandShellSurface::popup_done(void *data, - struct wl_shell_surface *wl_shell_surface) +void QWaylandShellSurface::shell_surface_popup_done() { - Q_UNUSED(data); - Q_UNUSED(wl_shell_surface); } - -const wl_shell_surface_listener QWaylandShellSurface::m_shell_surface_listener = { - QWaylandShellSurface::ping, - QWaylandShellSurface::configure, - QWaylandShellSurface::popup_done -}; diff --git a/src/plugins/platforms/wayland_common/qwaylandshellsurface.h b/src/plugins/platforms/wayland_common/qwaylandshellsurface.h index e54a46bf3..90dd04ff9 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshellsurface.h +++ b/src/plugins/platforms/wayland_common/qwaylandshellsurface.h @@ -46,19 +46,24 @@ #include <wayland-client.h> +#include "qwayland-wayland.h" + QT_BEGIN_NAMESPACE class QWaylandWindow; class QWaylandInputDevice; class QWindow; -class QWaylandShellSurface +class QWaylandShellSurface : public QtWayland::wl_shell_surface { public: - QWaylandShellSurface(struct wl_shell_surface *shell_surface, QWaylandWindow *window); + QWaylandShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window); ~QWaylandShellSurface(); + using QtWayland::wl_shell_surface::resize; void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges); + + using QtWayland::wl_shell_surface::move; void move(QWaylandInputDevice *inputDevice); private: @@ -70,29 +75,20 @@ private: void setTopLevel(); void updateTransientParent(QWindow *parent); - struct wl_shell_surface *handle() const { return m_shell_surface; } - void setClassName(const char *_class); void setTitle(const char *title); - struct wl_shell_surface *m_shell_surface; QWaylandWindow *m_window; bool m_maximized; bool m_fullscreen; QSize m_size; - static void ping(void *data, - struct wl_shell_surface *wl_shell_surface, - uint32_t serial); - static void configure(void *data, - struct wl_shell_surface *wl_shell_surface, - uint32_t edges, - int32_t width, - int32_t height); - static void popup_done(void *data, - struct wl_shell_surface *wl_shell_surface); - static const struct wl_shell_surface_listener m_shell_surface_listener; + void shell_surface_ping(uint32_t serial) Q_DECL_OVERRIDE; + void shell_surface_configure(uint32_t edges, + int32_t width, + int32_t height) Q_DECL_OVERRIDE; + void shell_surface_popup_done() Q_DECL_OVERRIDE; friend class QWaylandWindow; }; diff --git a/src/plugins/platforms/wayland_common/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland_common/qwaylandshmbackingstore.cpp index 36c3246d0..9a8c5d8b3 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandshmbackingstore.cpp @@ -202,7 +202,7 @@ void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, cons return; } - mFrameCallback = wl_surface_frame(waylandWindow()->wl_surface()); + mFrameCallback = waylandWindow()->frame(); wl_callback_add_listener(mFrameCallback,&frameCallbackListener,this); QMargins margins = windowDecorationMargins(); diff --git a/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp b/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp index 0ec955a86..6b1c9b329 100644 --- a/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp @@ -43,42 +43,23 @@ #include "qwaylandwindow.h" -#include "wayland-sub-surface-extension-client-protocol.h" - #include <QtCore/QDebug> QT_USE_NAMESPACE -QWaylandSubSurfaceExtension::QWaylandSubSurfaceExtension(QWaylandDisplay *display, uint32_t id) -{ - m_sub_surface_extension = static_cast<struct wl_sub_surface_extension *>( - wl_registry_bind(display->wl_registry(), id, &wl_sub_surface_extension_interface, 1)); -} - -QWaylandSubSurface *QWaylandSubSurfaceExtension::getSubSurfaceAwareWindow(QWaylandWindow *window) -{ - struct wl_surface *surface = window->wl_surface(); - Q_ASSERT(surface); - struct wl_sub_surface *sub_surface = - wl_sub_surface_extension_get_sub_surface_aware_surface(m_sub_surface_extension,surface); - - return new QWaylandSubSurface(window,sub_surface); - -} - -QWaylandSubSurface::QWaylandSubSurface(QWaylandWindow *window, struct wl_sub_surface *sub_surface) - : m_window(window) - , m_sub_surface(sub_surface) +QWaylandSubSurface::QWaylandSubSurface(QWaylandWindow *window, struct ::wl_sub_surface *sub_surface) + : QtWayland::wl_sub_surface(sub_surface) + , m_window(window) { } void QWaylandSubSurface::setParent(const QWaylandWindow *parent) { - QWaylandSubSurface *parentSurface = parent? parent->subSurfaceWindow():0; + QWaylandSubSurface *parentSurface = parent ? parent->subSurfaceWindow() : 0; if (parentSurface) { int x = m_window->geometry().x() + parent->frameMargins().left(); int y = m_window->geometry().y() + parent->frameMargins().top(); - wl_sub_surface_attach_sub_surface(parentSurface->m_sub_surface,m_sub_surface,x,y); + parentSurface->attach_sub_surface(object(), x, y); } } diff --git a/src/plugins/platforms/wayland_common/qwaylandsubsurface.h b/src/plugins/platforms/wayland_common/qwaylandsubsurface.h index e594050ec..7b0fd5b3f 100644 --- a/src/plugins/platforms/wayland_common/qwaylandsubsurface.h +++ b/src/plugins/platforms/wayland_common/qwaylandsubsurface.h @@ -46,34 +46,24 @@ #include <QtCore/qglobal.h> +#include <qwayland-sub-surface-extension.h> + QT_BEGIN_NAMESPACE class QWaylandDisplay; class QWaylandWindow; class QWaylandSubSurface; -class QWaylandSubSurfaceExtension -{ -public: - QWaylandSubSurfaceExtension(QWaylandDisplay *display, uint32_t id); - - QWaylandSubSurface *getSubSurfaceAwareWindow(QWaylandWindow *window); -private: - struct wl_sub_surface_extension *m_sub_surface_extension; -}; - -class QWaylandSubSurface +class QWaylandSubSurface : public QtWayland::wl_sub_surface { public: - QWaylandSubSurface(QWaylandWindow *window, struct wl_sub_surface *sub_surface); + QWaylandSubSurface(QWaylandWindow *window, struct ::wl_sub_surface *sub_surface); void setParent(const QWaylandWindow *parent); - void adjustPositionOfChildren(); private: QWaylandWindow *m_window; - struct wl_sub_surface *m_sub_surface; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland_common/qwaylandtouch.cpp b/src/plugins/platforms/wayland_common/qwaylandtouch.cpp index 26f57d576..07c879eaa 100644 --- a/src/plugins/platforms/wayland_common/qwaylandtouch.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandtouch.cpp @@ -42,20 +42,17 @@ #include "qwaylandtouch.h" #include "qwaylandinputdevice.h" -#include "wayland-touch-extension-client-protocol.h" - QT_USE_NAMESPACE QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id) - : mDisplay(display), + : QtWayland::wl_touch_extension(display->wl_registry(), id), + mDisplay(display), mTouchDevice(0), mPointsLeft(0), mFlags(0), mMouseSourceId(-1), mInputDevice(0) { - mTouch = static_cast<struct wl_touch_extension *>(wl_registry_bind(display->wl_registry(), id, &wl_touch_extension_interface, 1)); - wl_touch_extension_add_listener(mTouch, &touch_listener, this); } void QWaylandTouchExtension::registerDevice(int caps) @@ -71,53 +68,50 @@ static inline qreal fromFixed(int f) return f / qreal(10000); } -void QWaylandTouchExtension::handle_touch(void *data, wl_touch_extension *ext, uint32_t time, - uint32_t id, uint32_t state, int32_t x, int32_t y, - int32_t normalized_x, int32_t normalized_y, - int32_t width, int32_t height, uint32_t pressure, - int32_t velocity_x, int32_t velocity_y, - uint32_t flags, wl_array *rawdata) +void QWaylandTouchExtension::touch_extension_touch(uint32_t time, + uint32_t id, uint32_t state, int32_t x, int32_t y, + int32_t normalized_x, int32_t normalized_y, + int32_t width, int32_t height, uint32_t pressure, + int32_t velocity_x, int32_t velocity_y, + uint32_t flags, wl_array *rawdata) { - Q_UNUSED(ext); - QWaylandTouchExtension *self = static_cast<QWaylandTouchExtension *>(data); - - if (!self->mInputDevice) { - QList<QWaylandInputDevice *> inputDevices = self->mDisplay->inputDevices(); + if (!mInputDevice) { + QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); if (inputDevices.isEmpty()) { qWarning("wl_touch_extension: handle_touch: No input devices"); return; } - self->mInputDevice = inputDevices.first(); + mInputDevice = inputDevices.first(); } - QWaylandWindow *win = self->mInputDevice->mTouchFocus; + QWaylandWindow *win = mInputDevice->mTouchFocus; if (!win) - win = self->mInputDevice->mPointerFocus; + win = mInputDevice->mPointerFocus; if (!win) - win = self->mInputDevice->mKeyboardFocus; + win = mInputDevice->mKeyboardFocus; if (!win || !win->window()) { qWarning("wl_touch_extension: handle_touch: No pointer focus"); return; } - self->mTargetWindow = win->window(); + mTargetWindow = win->window(); QWindowSystemInterface::TouchPoint tp; tp.id = id; tp.state = Qt::TouchPointState(int(state & 0xFFFF)); int sentPointCount = state >> 16; - if (!self->mPointsLeft) { + if (!mPointsLeft) { Q_ASSERT(sentPointCount > 0); - self->mPointsLeft = sentPointCount; + mPointsLeft = sentPointCount; } tp.flags = QTouchEvent::TouchPoint::InfoFlags(int(flags & 0xFFFF)); - if (!self->mTouchDevice) - self->registerDevice(flags >> 16); + if (!mTouchDevice) + registerDevice(flags >> 16); tp.area = QRectF(0, 0, fromFixed(width), fromFixed(height)); // Got surface-relative coords but need a (virtual) screen position. QPointF relPos = QPointF(fromFixed(x), fromFixed(y)); QPointF delta = relPos - relPos.toPoint(); - tp.area.moveCenter(self->mTargetWindow->mapToGlobal(relPos.toPoint()) + delta); + tp.area.moveCenter(mTargetWindow->mapToGlobal(relPos.toPoint()) + delta); tp.normalPosition.setX(fromFixed(normalized_x)); tp.normalPosition.setY(fromFixed(normalized_y)); @@ -135,11 +129,11 @@ void QWaylandTouchExtension::handle_touch(void *data, wl_touch_extension *ext, u } } - self->mTouchPoints.append(tp); - self->mTimestamp = time; + mTouchPoints.append(tp); + mTimestamp = time; - if (!--self->mPointsLeft) - self->sendTouchEvent(); + if (!--mPointsLeft) + sendTouchEvent(); } void QWaylandTouchExtension::sendTouchEvent() @@ -207,14 +201,7 @@ void QWaylandTouchExtension::touchCanceled() QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal, Qt::NoButton); } -void QWaylandTouchExtension::handle_configure(void *data, wl_touch_extension *ext, uint32_t flags) +void QWaylandTouchExtension::touch_extension_configure(uint32_t flags) { - Q_UNUSED(ext); - QWaylandTouchExtension *self = static_cast<QWaylandTouchExtension *>(data); - self->mFlags = flags; + mFlags = flags; } - -const struct wl_touch_extension_listener QWaylandTouchExtension::touch_listener = { - QWaylandTouchExtension::handle_touch, - QWaylandTouchExtension::handle_configure -}; diff --git a/src/plugins/platforms/wayland_common/qwaylandtouch.h b/src/plugins/platforms/wayland_common/qwaylandtouch.h index 9762af22a..de22cab1f 100644 --- a/src/plugins/platforms/wayland_common/qwaylandtouch.h +++ b/src/plugins/platforms/wayland_common/qwaylandtouch.h @@ -45,11 +45,11 @@ #include "qwaylanddisplay.h" #include <qpa/qwindowsysteminterface.h> -class wl_touch_extension; +#include <qwayland-touch-extension.h> QT_BEGIN_NAMESPACE -class QWaylandTouchExtension +class QWaylandTouchExtension : public QtWayland::wl_touch_extension { public: QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id); @@ -60,28 +60,22 @@ private: void registerDevice(int caps); QWaylandDisplay *mDisplay; - wl_touch_extension *mTouch; - static const struct wl_touch_extension_listener touch_listener; - static void handle_touch(void *data, - struct wl_touch_extension *ext, - uint32_t time, - uint32_t id, - uint32_t state, - int32_t x, - int32_t y, - int32_t normalized_x, - int32_t normalized_y, - int32_t width, - int32_t height, - uint32_t pressure, - int32_t velocity_x, - int32_t velocity_y, - uint32_t flags, - struct wl_array *rawdata); - static void handle_configure(void *data, - struct wl_touch_extension *ext, - uint32_t flags); + void touch_extension_touch(uint32_t time, + uint32_t id, + uint32_t state, + int32_t x, + int32_t y, + int32_t normalized_x, + int32_t normalized_y, + int32_t width, + int32_t height, + uint32_t pressure, + int32_t velocity_x, + int32_t velocity_y, + uint32_t flags, + struct wl_array *rawdata) Q_DECL_OVERRIDE; + void touch_extension_configure(uint32_t flags) Q_DECL_OVERRIDE; void sendTouchEvent(); diff --git a/src/plugins/platforms/wayland_common/qwaylandwindow.cpp b/src/plugins/platforms/wayland_common/qwaylandwindow.cpp index e452f4db3..cdfef320d 100644 --- a/src/plugins/platforms/wayland_common/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandwindow.cpp @@ -45,7 +45,6 @@ #include "qwaylanddisplay.h" #include "qwaylandinputdevice.h" #include "qwaylandscreen.h" -#include "qwaylandshell.h" #include "qwaylandshellsurface.h" #include "qwaylandextendedsurface.h" #include "qwaylandsubsurface.h" @@ -69,7 +68,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window) : QObject() , QPlatformWindow(window) , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) - , mSurface(mDisplay->createSurface(this)) , mShellSurface(0) , mExtendedWindow(0) , mSubSurfaceWindow(0) @@ -83,15 +81,17 @@ QWaylandWindow::QWaylandWindow(QWindow *window) , mSentInitialResize(false) , mState(Qt::WindowNoState) { + init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this))); + static WId id = 1; mWindowId = id++; if (mDisplay->shell()) - mShellSurface = mDisplay->shell()->getShellSurface(this); + mShellSurface = new QWaylandShellSurface(mDisplay->shell()->get_shell_surface(wl_surface()), this); if (mDisplay->windowExtension()) - mExtendedWindow = mDisplay->windowExtension()->getExtendedWindow(this); + mExtendedWindow = new QWaylandExtendedSurface(this, mDisplay->windowExtension()->get_extended_surface(wl_surface())); if (mDisplay->subSurfaceExtension()) - mSubSurfaceWindow = mDisplay->subSurfaceExtension()->getSubSurfaceAwareWindow(this); + mSubSurfaceWindow = new QWaylandSubSurface(this, mDisplay->subSurfaceExtension()->get_sub_surface_aware_surface(wl_surface())); #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid()); @@ -118,10 +118,10 @@ QWaylandWindow::QWaylandWindow(QWindow *window) QWaylandWindow::~QWaylandWindow() { - if (mSurface) { + if (isInitialized()) { delete mShellSurface; delete mExtendedWindow; - wl_surface_destroy(mSurface); + destroy(); } QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); @@ -129,6 +129,11 @@ QWaylandWindow::~QWaylandWindow() inputDevices.at(i)->handleWindowDestroyed(this); } +QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface) +{ + return static_cast<QWaylandWindow *>(static_cast<QtWayland::wl_surface *>(wl_surface_get_user_data(surface))); +} + WId QWaylandWindow::winId() const { return mWindowId; @@ -177,7 +182,7 @@ void QWaylandWindow::setVisible(bool visible) if (visible) { if (mBuffer) - wl_surface_attach(mSurface, mBuffer->buffer(), 0, 0); + attach(mBuffer->buffer(), 0, 0); if (!mSentInitialResize) { QWindowSystemInterface::handleGeometryChange(window(), geometry()); @@ -190,7 +195,7 @@ void QWaylandWindow::setVisible(bool visible) // QWaylandShmBackingStore::beginPaint(). } else { QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); - wl_surface_attach(mSurface, 0,0,0); + attach(static_cast<QWaylandBuffer *>(0), 0, 0); } damage(QRect(QPoint(0,0),geometry().size())); } @@ -257,9 +262,8 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y) { mBuffer = buffer; - if (window()->isVisible()) { - wl_surface_attach(mSurface, mBuffer->buffer(), x, y); - } + if (window()->isVisible()) + attach(mBuffer->buffer(), x, y); } void QWaylandWindow::attachOffset(QWaylandBuffer *buffer) @@ -278,14 +282,13 @@ void QWaylandWindow::damage(const QRect &rect) //We have to do sync stuff before calling damage, or we might //get a frame callback before we get the timestamp if (!mWaitingForFrameSync) { - mFrameCallback = wl_surface_frame(mSurface); + mFrameCallback = frame(); wl_callback_add_listener(mFrameCallback,&QWaylandWindow::callbackListener,this); mWaitingForFrameSync = true; } - wl_surface_damage(mSurface, - rect.x(), rect.y(), rect.width(), rect.height()); - wl_surface_commit(mSurface); + damage(rect.x(), rect.y(), rect.width(), rect.height()); + commit(); } const wl_callback_listener QWaylandWindow::callbackListener = { diff --git a/src/plugins/platforms/wayland_common/qwaylandwindow.h b/src/plugins/platforms/wayland_common/qwaylandwindow.h index 613f17e70..b90af1f6e 100644 --- a/src/plugins/platforms/wayland_common/qwaylandwindow.h +++ b/src/plugins/platforms/wayland_common/qwaylandwindow.h @@ -50,6 +50,8 @@ #include "qwaylanddisplay.h" +#include "qwayland-wayland.h" + struct wl_egl_window; QT_BEGIN_NAMESPACE @@ -81,7 +83,7 @@ public: uint32_t edges; }; -class QWaylandWindow : public QObject, public QPlatformWindow +class QWaylandWindow : public QObject, public QPlatformWindow, public QtWayland::wl_surface { Q_OBJECT public: @@ -107,18 +109,24 @@ public: void configure(uint32_t edges, int32_t width, int32_t height); + using QtWayland::wl_surface::attach; void attach(QWaylandBuffer *buffer, int x, int y); void attachOffset(QWaylandBuffer *buffer); QWaylandBuffer *attached() const; QPoint attachOffset() const; + using QtWayland::wl_surface::damage; void damage(const QRect &rect); void waitForFrameSync(); QMargins frameMargins() const; - struct wl_surface *wl_surface() const { return mSurface; } + // TODO: remove? + struct ::wl_surface *wl_surface() { return object(); } + const struct ::wl_surface *wl_surface() const { return object(); } + + static QWaylandWindow *fromWlSurface(::wl_surface *surface); QWaylandShellSurface *shellSurface() const; QWaylandExtendedSurface *extendedWindow() const; @@ -155,7 +163,6 @@ public slots: protected: QWaylandDisplay *mDisplay; - struct wl_surface *mSurface; QWaylandShellSurface *mShellSurface; QWaylandExtendedSurface *mExtendedWindow; QWaylandSubSurface *mSubSurfaceWindow; diff --git a/src/plugins/platforms/wayland_common/wayland_common.pri b/src/plugins/platforms/wayland_common/wayland_common.pri index e3a380ead..4888a26bf 100644 --- a/src/plugins/platforms/wayland_common/wayland_common.pri +++ b/src/plugins/platforms/wayland_common/wayland_common.pri @@ -26,3 +26,5 @@ INCLUDEPATH += $$PWD $$PWD/../../../shared staticlib = $$shadowed($$PWD)/$${QMAKE_PREFIX_STATICLIB}wayland_common.$${QMAKE_EXTENSION_STATICLIB} LIBS += $$staticlib PRE_TARGETDEPS += $$staticlib + +WAYLANDCLIENTSOURCES += ../../../3rdparty/protocol/wayland.xml diff --git a/src/plugins/platforms/wayland_common/wayland_common.pro b/src/plugins/platforms/wayland_common/wayland_common.pro index 381b7bda6..64176d6ea 100644 --- a/src/plugins/platforms/wayland_common/wayland_common.pro +++ b/src/plugins/platforms/wayland_common/wayland_common.pro @@ -31,7 +31,6 @@ SOURCES += qwaylandintegration.cpp \ qwaylanddataoffer.cpp \ qwaylanddatadevicemanager.cpp \ qwaylanddatasource.cpp \ - qwaylandshell.cpp \ qwaylandshellsurface.cpp \ qwaylandextendedoutput.cpp \ qwaylandextendedsurface.cpp \ @@ -57,7 +56,6 @@ HEADERS += qwaylandintegration.h \ qwaylanddataoffer.h \ qwaylanddatadevicemanager.h \ qwaylanddatasource.h \ - qwaylandshell.h \ qwaylandshellsurface.h \ qwaylandextendedoutput.h \ qwaylandextendedsurface.h \ @@ -73,9 +71,14 @@ contains(DEFINES, QT_WAYLAND_GL_SUPPORT) { HEADERS += qwaylandglintegration.h } -WAYLANDSOURCES += \ +WAYLANDCLIENTSOURCES += \ ../../../extensions/surface-extension.xml \ ../../../extensions/sub-surface-extension.xml \ ../../../extensions/output-extension.xml \ ../../../extensions/touch-extension.xml \ - ../../../extensions/qtkey-extension.xml + ../../../extensions/qtkey-extension.xml \ + ../../../3rdparty/protocol/wayland.xml + +PLUGIN_TYPE = platforms + +load(qt_common) diff --git a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index 68a7fdfab..c23f7eacd 100644 --- a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qwaylandwindowmanagerintegration.h" -#include "wayland-windowmanager-client-protocol.h" #include "qwaylandscreen.h" #include "qwaylandwindow.h" @@ -62,7 +61,6 @@ public: QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay); bool m_blockPropertyUpdates; QWaylandDisplay *m_waylandDisplay; - struct wl_windowmanager *m_waylandWindowManager; QHash<QWindow*, QVariantMap> m_queuedProperties; bool m_showIsFullScreen; }; @@ -70,23 +68,14 @@ public: QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay) : m_blockPropertyUpdates(false) , m_waylandDisplay(waylandDisplay) - , m_waylandWindowManager(0) , m_showIsFullScreen(false) { } -QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0; - -QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandWindowManagerIntegration(waylandDisplay); -} - QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay) : d_ptr(new QWaylandWindowManagerIntegrationPrivate(waylandDisplay)) { - m_instance = this; waylandDisplay->addRegistryListener(&wlHandleListenerGlobal, this); } @@ -95,83 +84,56 @@ QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration() } -QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::instance() -{ - return m_instance; -} - -struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const -{ - Q_D(const QWaylandWindowManagerIntegration); - return d->m_waylandWindowManager; -} - bool QWaylandWindowManagerIntegration::showIsFullScreen() const { Q_D(const QWaylandWindowManagerIntegration); return d->m_showIsFullScreen; } -void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(void *data, wl_registry *registry, uint32_t id, const char *interface, uint32_t version) +void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) { Q_UNUSED(version); - if (strcmp(interface, "wl_windowmanager") == 0) { - QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data); - integration->d_ptr->m_waylandWindowManager = - static_cast<struct wl_windowmanager *>(wl_registry_bind(registry, id, &wl_windowmanager_interface, 1)); - wl_windowmanager_add_listener(integration->d_ptr->m_waylandWindowManager, &windowmanager_listener, integration); - } + if (interface == "wl_windowmanager") + static_cast<QWaylandWindowManagerIntegration *>(data)->init(registry, id); } -const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::windowmanager_listener = { - QWaylandWindowManagerIntegration::handle_hints, - QWaylandWindowManagerIntegration::handle_quit -}; - -void QWaylandWindowManagerIntegration::handle_hints(void *data, wl_windowmanager *ext, int32_t showIsFullScreen) +void QWaylandWindowManagerIntegration::windowmanager_hints(int32_t showIsFullScreen) { - Q_UNUSED(ext); - QWaylandWindowManagerIntegration *self = static_cast<QWaylandWindowManagerIntegration *>(data); - self->d_func()->m_showIsFullScreen = showIsFullScreen; + Q_D(QWaylandWindowManagerIntegration); + d->m_showIsFullScreen = showIsFullScreen; } -void QWaylandWindowManagerIntegration::handle_quit(void *data, wl_windowmanager *ext) +void QWaylandWindowManagerIntegration::windowmanager_quit() { - Q_UNUSED(data); - Q_UNUSED(ext); QGuiApplication::quit(); } void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId) { - Q_D(QWaylandWindowManagerIntegration); - if (d->m_waylandWindowManager) - wl_windowmanager_map_client_to_process(d->m_waylandWindowManager, (uint32_t) processId); + if (isInitialized()) + map_client_to_process(uint32_t(processId)); } void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token) { - Q_D(QWaylandWindowManagerIntegration); QByteArray authToken = token; if (authToken.isEmpty()) authToken = qgetenv("WL_AUTHENTICATION_TOKEN"); - if (d->m_waylandWindowManager && !authToken.isEmpty()) { - wl_windowmanager_authenticate_with_token(d->m_waylandWindowManager, authToken.constData()); - } + if (isInitialized() && !authToken.isEmpty()) + authenticate_with_token(authToken.constData()); } void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url) { - Q_D(QWaylandWindowManagerIntegration); - if (d->m_waylandWindowManager) { + if (isInitialized()) { QByteArray data = url.toString().toUtf8(); static const int chunkSize = 128; while (!data.isEmpty()) { QByteArray chunk = data.left(chunkSize); data = data.mid(chunkSize); - wl_windowmanager_open_url(d->m_waylandWindowManager, !data.isEmpty(), chunk.constData()); + open_url(!data.isEmpty(), QString::fromUtf8(chunk)); } } } diff --git a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h index 9145401db..17a21db0e 100644 --- a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h +++ b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h @@ -49,23 +49,21 @@ #include "qwaylanddisplay.h" #include <qpa/qplatformservices.h> +#include "qwayland-windowmanager.h" + QT_BEGIN_NAMESPACE class QWaylandWindow; class QWaylandWindowManagerIntegrationPrivate; -class QWaylandWindowManagerIntegration : public QObject, public QPlatformServices +class QWaylandWindowManagerIntegration : public QObject, public QPlatformServices, public QtWayland::wl_windowmanager { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWindowManagerIntegration) public: explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay); virtual ~QWaylandWindowManagerIntegration(); - static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay); - struct wl_windowmanager *windowManager() const; - - static QWaylandWindowManagerIntegration *instance(); void mapSurfaceToProcess(struct wl_surface *surface, long long processId); void mapClientToProcess(long long processId); @@ -77,17 +75,12 @@ public: private: static void wlHandleListenerGlobal(void *data, wl_registry *registry, uint32_t id, - const char *interface, uint32_t version); + const QString &interface, uint32_t version); QScopedPointer<QWaylandWindowManagerIntegrationPrivate> d_ptr; - static QWaylandWindowManagerIntegration *m_instance; - - static const struct wl_windowmanager_listener windowmanager_listener; - static void handle_hints(void *data, - struct wl_windowmanager *ext, - int32_t showIsFullScreen); - static void handle_quit(void *data, struct wl_windowmanager *ext); + void windowmanager_hints(int32_t showIsFullScreen) Q_DECL_OVERRIDE; + void windowmanager_quit() Q_DECL_OVERRIDE; void openUrl_helper(const QUrl &url); }; diff --git a/src/plugins/platforms/wayland_common/windowmanager_integration/windowmanager_integration.pri b/src/plugins/platforms/wayland_common/windowmanager_integration/windowmanager_integration.pri index 57905ad9a..9228358ec 100644 --- a/src/plugins/platforms/wayland_common/windowmanager_integration/windowmanager_integration.pri +++ b/src/plugins/platforms/wayland_common/windowmanager_integration/windowmanager_integration.pri @@ -2,7 +2,7 @@ DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) { - WAYLANDSOURCES += $$PWD/../../../../extensions/windowmanager.xml + WAYLANDCLIENTSOURCES += $$PWD/../../../../extensions/windowmanager.xml HEADERS += \ $$PWD/qwaylandwindowmanagerintegration.h diff --git a/src/plugins/platforms/xcomposite_share/xcomposite_share.pri b/src/plugins/platforms/xcomposite_share/xcomposite_share.pri index 190fa4697..77d56f4c5 100644 --- a/src/plugins/platforms/xcomposite_share/xcomposite_share.pri +++ b/src/plugins/platforms/xcomposite_share/xcomposite_share.pri @@ -1,6 +1,6 @@ INCLUDEPATH += $$PWD -WAYLANDSOURCES += $$PWD/../../../extensions/xcomposite.xml +WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/xcomposite.xml HEADERS += \ $$PWD/qwaylandxcompositebuffer.h diff --git a/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro b/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro index c397c6131..401d6d461 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro +++ b/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro @@ -19,4 +19,4 @@ HEADERS += \ OTHER_FILES += brcm-egl.json -WAYLANDSOURCES += $$PWD/../../../extensions/brcm.xml +WAYLANDSERVERSOURCES += $$PWD/../../../extensions/brcm.xml diff --git a/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri b/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri index 631ddaf2e..823925d1e 100644 --- a/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri +++ b/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri @@ -1,6 +1,6 @@ INCLUDEPATH += $$PWD -WAYLANDSOURCES += $$PWD/../../../extensions/xcomposite.xml +WAYLANDSERVERSOURCES += $$PWD/../../../extensions/xcomposite.xml HEADERS += \ $$PWD/xcompositebuffer.h \ diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 86fc4937c..fe91b796b 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -593,10 +593,7 @@ void process(QXmlStreamReader &xml) printf(" void %s::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)\n", interfaceName); printf(" {\n"); printf(" Q_UNUSED(version);\n"); - printf(" %s *that = static_cast<%s *>(data);\n", interfaceName, interfaceName); - printf(" Resource *resource = that->bind(client, id);\n"); - printf(" resource->handle->destroy = destroy_func;\n"); - printf(" that->%s_bind_resource(resource);\n", interfaceNameStripped); + printf(" static_cast<%s *>(data)->bind(client, id);\n", interfaceName); printf(" }\n"); printf("\n"); @@ -622,6 +619,8 @@ void process(QXmlStreamReader &xml) printf(" resource->handle = wl_client_add_object(client, &::%s_interface, &m_%s_interface, id, resource);\n", interfaceName, interfaceName); else printf(" resource->handle = wl_client_add_object(client, &::%s_interface, 0, id, resource);\n", interfaceName); + printf(" resource->handle->destroy = destroy_func;\n"); + printf(" %s_bind_resource(resource);\n", interfaceNameStripped); printf(" wl_list_init(&resource->handle->link);\n"); printf(" return resource;\n"); printf(" }\n"); |