diff --git a/README.md b/README.md
index 2ffbca6..c5370e0 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,21 @@ An openbox clone on Wayland (WIP)
### Goals
The main goal of this project is to provide a similar feel to openbox but on wayland
-### Expectations
-I'm in school and working part-time but I will try my best to work on this and
-continue to improve it.
+### Dependencies
+
+*-wlroots
+*-wayland
+
+### Build instructions
+
+```
+meson build
+cd build
+ninja
+```
+
+After that, you should have an executable in build/
### Contact
I can be found as wiz on Rizon and WizBright on Freenode.
-Join #waybox on irc.freenode.net for discussion
+Join [#waybox](http://webchat.freenode.net/?channels=waybox) for discussion
diff --git a/meson.build b/meson.build
index 9f9ce65..c89b278 100644
--- a/meson.build
+++ b/meson.build
@@ -16,6 +16,7 @@ project(
add_project_arguments('-Wno-unused-parameter', language: 'c')
cc = meson.get_compiler('c')
+
if cc.get_id() == 'clang'
add_project_arguments('-Wno-missing-field-initializers', language: 'c')
add_project_arguments('-Wno-missing-braces', language: 'c')
@@ -27,6 +28,10 @@ add_project_arguments('-DWL_HIDE_DEPRECATED', language: 'c')
pixman = dependency('pixman-1')
wlroots = dependency('wlroots')
wayland_server = dependency('wayland-server')
+wayland_client = dependency('wayland-client')
+wayland_protos = dependency('wayland-protocols', version: '>=1.12')
+
+subdir('protocol')
executable(
'waybox',
@@ -37,5 +42,7 @@ executable(
pixman,
wlroots,
wayland_server,
+ wayland_protos,
+ wayland_client
]
)
diff --git a/protocol/gamma-control.xml b/protocol/gamma-control.xml
new file mode 100644
index 0000000..e6e3326
--- /dev/null
+++ b/protocol/gamma-control.xml
@@ -0,0 +1,57 @@
+
+
+
+
+ Copyright © 2015 Giulio camuffo
+
+ 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.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/protocol/gtk-primary-selection.xml b/protocol/gtk-primary-selection.xml
new file mode 100644
index 0000000..02cab94
--- /dev/null
+++ b/protocol/gtk-primary-selection.xml
@@ -0,0 +1,225 @@
+
+
+
+ Copyright © 2015, 2016 Red Hat
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+
+
+ This protocol provides the ability to have a primary selection device to
+ match that of the X server. This primary selection is a shortcut to the
+ common clipboard selection, where text just needs to be selected in order
+ to allow copying it elsewhere. The de facto way to perform this action
+ is the middle mouse button, although it is not limited to this one.
+
+ Clients wishing to honor primary selection should create a primary
+ selection source and set it as the selection through
+ wp_primary_selection_device.set_selection whenever the text selection
+ changes. In order to minimize calls in pointer-driven text selection,
+ it should happen only once after the operation finished. Similarly,
+ a NULL source should be set when text is unselected.
+
+ wp_primary_selection_offer objects are first announced through the
+ wp_primary_selection_device.data_offer event. Immediately after this event,
+ the primary data offer will emit wp_primary_selection_offer.offer events
+ to let know of the mime types being offered.
+
+ When the primary selection changes, the client with the keyboard focus
+ will receive wp_primary_selection_device.selection events. Only the client
+ with the keyboard focus will receive such events with a non-NULL
+ wp_primary_selection_offer. Across keyboard focus changes, previously
+ focused clients will receive wp_primary_selection_device.events with a
+ NULL wp_primary_selection_offer.
+
+ In order to request the primary selection data, the client must pass
+ a recent serial pertaining to the press event that is triggering the
+ operation, if the compositor deems the serial valid and recent, the
+ wp_primary_selection_source.send event will happen in the other end
+ to let the transfer begin. The client owning the primary selection
+ should write the requested data, and close the file descriptor
+ immediately.
+
+ If the primary selection owner client disappeared during the transfer,
+ the client reading the data will receive a
+ wp_primary_selection_device.selection event with a NULL
+ wp_primary_selection_offer, the client should take this as a hint
+ to finish the reads related to the no longer existing offer.
+
+ The primary selection owner should be checking for errors during
+ writes, merely cancelling the ongoing transfer if any happened.
+
+
+
+
+ The primary selection device manager is a singleton global object that
+ provides access to the primary selection. It allows to create
+ wp_primary_selection_source objects, as well as retrieving the per-seat
+ wp_primary_selection_device objects.
+
+
+
+
+ Create a new primary selection source.
+
+
+
+
+
+
+ Create a new data device for a given seat.
+
+
+
+
+
+
+
+ Destroy the primary selection device manager.
+
+
+
+
+
+
+
+ Replaces the current selection. The previous owner of the primary selection
+ will receive a wp_primary_selection_source.cancelled event.
+
+ To unset the selection, set the source to NULL.
+
+
+
+
+
+
+
+ Introduces a new wp_primary_selection_offer object that may be used
+ to receive the current primary selection. Immediately following this
+ event, the new wp_primary_selection_offer object will send
+ wp_primary_selection_offer.offer events to describe the offered mime
+ types.
+
+
+
+
+
+
+ The wp_primary_selection_device.selection event is sent to notify the
+ client of a new primary selection. This event is sent after the
+ wp_primary_selection.data_offer event introducing this object, and after
+ the offer has announced its mimetypes through
+ wp_primary_selection_offer.offer.
+
+ The data_offer is valid until a new offer or NULL is received
+ or until the client loses keyboard focus. The client must destroy the
+ previous selection data_offer, if any, upon receiving this event.
+
+
+
+
+
+
+ Destroy the primary selection device.
+
+
+
+
+
+
+ A wp_primary_selection_offer represents an offer to transfer the contents
+ of the primary selection clipboard to the client. Similar to
+ wl_data_offer, the offer also describes the mime types that the source
+ will transferthat the
+ data can be converted to and provides the mechanisms for transferring the
+ data directly to the client.
+
+
+
+
+ To transfer the contents of the primary selection clipboard, the client
+ issues this request and indicates the mime type that it wants to
+ receive. The transfer happens through the passed file descriptor
+ (typically created with the pipe system call). The source client writes
+ the data in the mime type representation requested and then closes the
+ file descriptor.
+
+ The receiving client reads from the read end of the pipe until EOF and
+ closes its end, at which point the transfer is complete.
+
+
+
+
+
+
+
+ Destroy the primary selection offer.
+
+
+
+
+
+ Sent immediately after creating announcing the wp_primary_selection_offer
+ through wp_primary_selection_device.data_offer. One event is sent per
+ offered mime type.
+
+
+
+
+
+
+
+ The source side of a wp_primary_selection_offer, it provides a way to
+ describe the offered data and respond to requests to transfer the
+ requested contents of the primary selection clipboard.
+
+
+
+
+ This request adds a mime type to the set of mime types advertised to
+ targets. Can be called several times to offer multiple types.
+
+
+
+
+
+
+ Destroy the primary selection source.
+
+
+
+
+
+ Request for the current primary selection contents from the client.
+ Send the specified mime type over the passed file descriptor, then
+ close it.
+
+
+
+
+
+
+
+ This primary selection source is no longer valid. The client should
+ clean up and destroy this primary selection source.
+
+
+
+
diff --git a/protocol/idle.xml b/protocol/idle.xml
new file mode 100644
index 0000000..92d9989
--- /dev/null
+++ b/protocol/idle.xml
@@ -0,0 +1,49 @@
+
+
+ .
+ ]]>
+
+
+ This interface allows to monitor user idle time on a given seat. The interface
+ allows to register timers which trigger after no user activity was registered
+ on the seat for a given interval. It notifies when user activity resumes.
+
+ This is useful for applications wanting to perform actions when the user is not
+ interacting with the system, e.g. chat applications setting the user as away, power
+ management features to dim screen, etc..
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/protocol/meson.build b/protocol/meson.build
new file mode 100644
index 0000000..004cd76
--- /dev/null
+++ b/protocol/meson.build
@@ -0,0 +1,65 @@
+wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')
+
+wayland_scanner = find_program('wayland-scanner')
+
+wayland_scanner_server = generator(
+ wayland_scanner,
+ output: '@BASENAME@-protocol.h',
+ arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
+)
+
+wayland_scanner_code = generator(
+ wayland_scanner,
+ output: '@BASENAME@-protocol.c',
+ arguments: ['code', '@INPUT@', '@OUTPUT@'],
+)
+
+wayland_scanner_client = generator(
+ wayland_scanner,
+ output: '@BASENAME@-client-protocol.h',
+ arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
+)
+
+protocols = [
+ [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
+ [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
+ [wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'],
+ [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
+ 'gamma-control.xml',
+ 'gtk-primary-selection.xml',
+ 'idle.xml',
+ 'screenshooter.xml',
+ 'server-decoration.xml',
+ 'wlr-layer-shell-unstable-v1.xml',
+]
+
+client_protocols = [
+ [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
+ [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
+ [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
+ 'idle.xml',
+ 'screenshooter.xml',
+ 'wlr-layer-shell-unstable-v1.xml',
+]
+
+wl_protos_src = []
+wl_protos_headers = []
+
+foreach p : protocols
+ xml = join_paths(p)
+ wl_protos_src += wayland_scanner_code.process(xml)
+ wl_protos_headers += wayland_scanner_server.process(xml)
+endforeach
+
+foreach p : client_protocols
+ xml = join_paths(p)
+ wl_protos_headers += wayland_scanner_client.process(xml)
+endforeach
+
+lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers,
+ dependencies: [wayland_client]) # for the include directory
+
+wlr_protos = declare_dependency(
+ link_with: lib_wl_protos,
+ sources: wl_protos_headers,
+)
\ No newline at end of file
diff --git a/protocol/screenshooter.xml b/protocol/screenshooter.xml
new file mode 100644
index 0000000..fc48eac
--- /dev/null
+++ b/protocol/screenshooter.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/protocol/server-decoration.xml b/protocol/server-decoration.xml
new file mode 100644
index 0000000..45f1128
--- /dev/null
+++ b/protocol/server-decoration.xml
@@ -0,0 +1,94 @@
+
+
+ .
+ ]]>
+
+
+ This interface allows to coordinate whether the server should create
+ a server-side window decoration around a wl_surface representing a
+ shell surface (wl_shell_surface or similar). By announcing support
+ for this interface the server indicates that it supports server
+ side decorations.
+
+
+
+ When a client creates a server-side decoration object it indicates
+ that it supports the protocol. The client is supposed to tell the
+ server whether it wants server-side decorations or will provide
+ client-side decorations.
+
+ If the client does not create a server-side decoration object for
+ a surface the server interprets this as lack of support for this
+ protocol and considers it as client-side decorated. Nevertheless a
+ client-side decorated surface should use this protocol to indicate
+ to the server that it does not want a server-side deco.
+
+
+
+
+
+
+
+
+
+
+
+
+ This event is emitted directly after binding the interface. It contains
+ the default mode for the decoration. When a new server decoration object
+ is created this new object will be in the default mode until the first
+ request_mode is requested.
+
+ The server may change the default mode at any time.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This event is emitted directly after the decoration is created and
+ represents the base decoration policy by the server. E.g. a server
+ which wants all surfaces to be client-side decorated will send Client,
+ a server which wants server-side decoration will send Server.
+
+ The client can request a different mode through the decoration request.
+ The server will acknowledge this by another event with the same mode. So
+ even if a server prefers server-side decoration it's possible to force a
+ client-side decoration.
+
+ The server may emit this event at any time. In this case the client can
+ again request a different mode. It's the responsibility of the server to
+ prevent a feedback loop.
+
+
+
+
+
diff --git a/protocol/wlr-layer-shell-unstable-v1.xml b/protocol/wlr-layer-shell-unstable-v1.xml
new file mode 100644
index 0000000..216e0d9
--- /dev/null
+++ b/protocol/wlr-layer-shell-unstable-v1.xml
@@ -0,0 +1,285 @@
+
+
+
+ Copyright © 2017 Drew DeVault
+
+ 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.
+
+
+
+
+ Clients can use this interface to assign the surface_layer role to
+ wl_surfaces. Such surfaces are assigned to a "layer" of the output and
+ rendered with a defined z-depth respective to each other. They may also be
+ anchored to the edges and corners of a screen and specify input handling
+ semantics. This interface should be suitable for the implementation of
+ many desktop shell components, and a broad number of other applications
+ that interact with the desktop.
+
+
+
+
+ Create a layer surface for an existing surface. This assigns the role of
+ layer_surface, or raises a protocol error if another role is already
+ assigned.
+
+ Creating a layer surface from a wl_surface which has a buffer attached
+ or committed is a client error, and any attempts by a client to attach
+ or manipulate a buffer prior to the first layer_surface.configure call
+ must also be treated as errors.
+
+ You may pass NULL for output to allow the compositor to decide which
+ output to use. Generally this will be the one that the user most
+ recently interacted with.
+
+ Clients can specify a namespace that defines the purpose of the layer
+ surface.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ These values indicate which layers a surface can be rendered in. They
+ are ordered by z depth, bottom-most first. Traditional shell surfaces
+ will typically be rendered between the bottom and top layers.
+ Fullscreen shell surfaces are typically rendered at the top layer.
+ Multiple surfaces can share a single layer, and ordering within a
+ single layer is undefined.
+
+
+
+
+
+
+
+
+
+
+
+ An interface that may be implemented by a wl_surface, for surfaces that
+ are designed to be rendered as a layer of a stacked desktop-like
+ environment.
+
+ Layer surface state (size, anchor, exclusive zone, margin, interactivity)
+ is double-buffered, and will be applied at the time wl_surface.commit of
+ the corresponding wl_surface is called.
+
+
+
+
+ Sets the size of the surface in surface-local coordinates. The
+ compositor will display the surface centered with respect to its
+ anchors.
+
+ If you pass 0 for either value, the compositor will assign it and
+ inform you of the assignment in the configure event. You must set your
+ anchor to opposite edges in the dimensions you omit; not doing so is a
+ protocol error. Both values are 0 by default.
+
+ Size is double-buffered, see wl_surface.commit.
+
+
+
+
+
+
+
+ Requests that the compositor anchor the surface to the specified edges
+ and corners. If two orthoginal edges are specified (e.g. 'top' and
+ 'left'), then the anchor point will be the intersection of the edges
+ (e.g. the top left corner of the output); otherwise the anchor point
+ will be centered on that edge, or in the center if none is specified.
+
+ Anchor is double-buffered, see wl_surface.commit.
+
+
+
+
+
+
+ Requests that the compositor avoids occluding an area of the surface
+ with other surfaces. The compositor's use of this information is
+ implementation-dependent - do not assume that this region will not
+ actually be occluded.
+
+ A positive value is only meaningful if the surface is anchored to an
+ edge, rather than a corner. The zone is the number of surface-local
+ coordinates from the edge that are considered exclusive.
+
+ Surfaces that do not wish to have an exclusive zone may instead specify
+ how they should interact with surfaces that do. If set to zero, the
+ surface indicates that it would like to be moved to avoid occluding
+ surfaces with a positive excluzive zone. If set to -1, the surface
+ indicates that it would not like to be moved to accommodate for other
+ surfaces, and the compositor should extend it all the way to the edges
+ it is anchored to.
+
+ For example, a panel might set its exclusive zone to 10, so that
+ maximized shell surfaces are not shown on top of it. A notification
+ might set its exclusive zone to 0, so that it is moved to avoid
+ occluding the panel, but shell surfaces are shown underneath it. A
+ wallpaper or lock screen might set their exclusive zone to -1, so that
+ they stretch below or over the panel.
+
+ The default value is 0.
+
+ Exclusive zone is double-buffered, see wl_surface.commit.
+
+
+
+
+
+
+ Requests that the surface be placed some distance away from the anchor
+ point on the output, in surface-local coordinates. Setting this value
+ for edges you are not anchored to has no effect.
+
+ The exclusive zone includes the margin.
+
+ Margin is double-buffered, see wl_surface.commit.
+
+
+
+
+
+
+
+
+
+ Set to 1 to request that the seat send keyboard events to this layer
+ surface. For layers below the shell surface layer, the seat will use
+ normal focus semantics. For layers above the shell surface layers, the
+ seat will always give exclusive keyboard focus to the top-most layer
+ which has keyboard interactivity set to true.
+
+ Layer surfaces receive pointer, touch, and tablet events normally. If
+ you do not want to receive them, set the input region on your surface
+ to an empty region.
+
+ Events is double-buffered, see wl_surface.commit.
+
+
+
+
+
+
+ This assigns an xdg_popup's parent to this layer_surface. This popup
+ should have been created via xdg_surface::get_popup with the parent set
+ to NULL, and this request must be invoked before committing the popup's
+ initial state.
+
+ See the documentation of xdg_popup for more details about what an
+ xdg_popup is and how it is used.
+
+
+
+
+
+
+ When a configure event is received, if a client commits the
+ surface in response to the configure event, then the client
+ must make an ack_configure request sometime before the commit
+ request, passing along the serial of the configure event.
+
+ If the client receives multiple configure events before it
+ can respond to one, it only has to ack the last configure event.
+
+ A client is not required to commit immediately after sending
+ an ack_configure request - it may even ack_configure several times
+ before its next surface commit.
+
+ A client may send multiple ack_configure requests before committing, but
+ only the last request sent before a commit indicates which configure
+ event the client really is responding to.
+
+
+
+
+
+
+ This request destroys the layer surface.
+
+
+
+
+
+ The configure event asks the client to resize its surface.
+
+ Clients should arrange their surface for the new states, and then send
+ an ack_configure request with the serial sent in this configure event at
+ some point before committing the new surface.
+
+ The client is free to dismiss all but the last configure event it
+ received.
+
+ The width and height arguments specify the size of the window in
+ surface-local coordinates.
+
+ 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). If the client picks a smaller size and
+ is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
+ surface will be centered on this axis.
+
+ If the width or height arguments are zero, it means the client should
+ decide its own window dimension.
+
+
+
+
+
+
+
+
+ The closed event is sent by the compositor when the surface will no
+ longer be shown. The output may have been destroyed or the user may
+ have asked for it to be removed. Further changes to the surface will be
+ ignored. The client should destroy the resource after receiving this
+ event, and create a new surface if they so choose.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main.c b/src/main.c
index 5a247ce..85150e8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,7 +5,15 @@
#include
#include
#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+//#include
+#include
+#include
struct wb_server {
@@ -13,6 +21,7 @@ struct wb_server {
struct wl_event_loop *wl_event_loop;
struct wlr_backend *backend;
+ struct wlr_compositor *compositor;
struct wl_listener new_output;
struct wl_list outputs; // wb_output::link
@@ -31,18 +40,41 @@ struct wb_output {
static void output_frame_notify(struct wl_listener *listener, void *data) {
struct wb_output *output = wl_container_of(listener, output, frame);
+// struct wlr_backend *backend = output->server->backend;
struct wlr_output *wlr_output = data;
struct wlr_renderer *renderer = wlr_backend_get_renderer(
wlr_output->backend);
- wlr_output_make_current(wlr_output, NULL);
- wlr_renderer_begin(renderer, wlr_output);
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
- float color[4] = {1.0, 0, 0, 1.0};
- wlr_renderer_clear(renderer, &color);
+ wlr_output_make_current(wlr_output, NULL);
+ wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
+
+ float color[4] = {0.4f, 0.4f, 0.4f, 1.0f};
+ wlr_renderer_clear(renderer, color);
+
+ struct wl_resource *_surface;
+ wl_resource_for_each(_surface, &output->server->compositor->surface_resources) {
+ struct wlr_surface *surface = wlr_surface_from_resource(_surface);
+ if (!wlr_surface_has_buffer(surface)) {
+ continue;
+ }
+ struct wlr_box render_box = {
+ .x = 20, .y = 20,
+ .width = surface->current->width,
+ .height = surface->current->height
+ };
+ float matrix[16];
+ wlr_matrix_project_box(matrix, &render_box, surface->current->transform,
+ 0, wlr_output->transform_matrix);
+ wlr_render_texture_with_matrix(renderer, surface->texture, matrix, 1.0f);
+ wlr_surface_send_frame_done(surface, &now);
+ }
wlr_output_swap_buffers(wlr_output, NULL, NULL);
wlr_renderer_end(renderer);
+ output->last_frame = now;
}
static void output_destroy_notify(struct wl_listener *listener, void *data) {
@@ -63,6 +95,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
struct wlr_output_mode *mode =
wl_container_of(wlr_output->modes.prev, mode, link);
wlr_output_set_mode(wlr_output, mode);
+
+ wlr_output_create_global(wlr_output);
}
struct wb_output *output = calloc(1, sizeof(struct wb_output));
@@ -85,7 +119,7 @@ int main(int argc, char **argv){
server.wl_event_loop = wl_display_get_event_loop(server.wl_display);
assert(server.wl_event_loop);
- server.backend = wlr_backend_autocreate(server.wl_display);
+ server.backend = wlr_backend_autocreate(server.wl_display, NULL);
assert(server.backend);
wl_list_init(&server.outputs);
@@ -93,12 +127,30 @@ int main(int argc, char **argv){
server.new_output.notify = new_output_notify;
wl_signal_add(&server.backend->events.new_output, &server.new_output);
+ const char *socket = wl_display_add_socket_auto(server.wl_display);
+ assert(socket);
+
if (!wlr_backend_start(server.backend)) {
fprintf(stderr, "Failed to start backend\n");
wl_display_destroy(server.wl_display);
return 1;
}
+ printf("Running compositer on wayland display '%s'\n", socket);
+ setenv("WAYLAND_DISPLAY", socket, true);
+
+ wl_display_init_shm(server.wl_display);
+ wlr_gamma_control_manager_create(server.wl_display);
+ wlr_screenshooter_create(server.wl_display);
+ wlr_primary_selection_device_manager_create(server.wl_display);
+ wlr_idle_create(server.wl_display);
+
+ server.compositor = wlr_compositor_create(server.wl_display,
+ wlr_backend_get_renderer(server.backend));
+
+// wlr_xdg_shell_v6_create(server.wl_display);
+ wlr_idle_create(server.wl_display);
+
wl_display_run(server.wl_display);
wl_display_destroy(server.wl_display);
return 0;