mirror of
https://github.com/labwc/labwc.git
synced 2026-03-21 05:33:52 -04:00
Move server_new_output() to output.c
This commit is contained in:
parent
bc5accb089
commit
298d869092
5 changed files with 55 additions and 54 deletions
|
|
@ -174,10 +174,12 @@ void cursor_motion_absolute(struct wl_listener *listener, void *data);
|
||||||
void cursor_button(struct wl_listener *listener, void *data);
|
void cursor_button(struct wl_listener *listener, void *data);
|
||||||
void cursor_axis(struct wl_listener *listener, void *data);
|
void cursor_axis(struct wl_listener *listener, void *data);
|
||||||
void cursor_frame(struct wl_listener *listener, void *data);
|
void cursor_frame(struct wl_listener *listener, void *data);
|
||||||
|
void cursor_new(struct server *server, struct wlr_input_device *device);
|
||||||
|
|
||||||
void keyboard_new(struct server *server, struct wlr_input_device *device);
|
void keyboard_new(struct server *server, struct wlr_input_device *device);
|
||||||
|
|
||||||
void output_frame(struct wl_listener *listener, void *data);
|
void output_frame(struct wl_listener *listener, void *data);
|
||||||
|
void output_new(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
void dbg_show_one_view(struct view *view);
|
void dbg_show_one_view(struct view *view);
|
||||||
void dbg_show_views(struct server *server);
|
void dbg_show_views(struct server *server);
|
||||||
|
|
|
||||||
|
|
@ -225,3 +225,9 @@ void cursor_frame(struct wl_listener *listener, void *data)
|
||||||
/* Notify the client with pointer focus of the frame event. */
|
/* Notify the client with pointer focus of the frame event. */
|
||||||
wlr_seat_pointer_notify_frame(server->seat);
|
wlr_seat_pointer_notify_frame(server->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cursor_new(struct server *server, struct wlr_input_device *device)
|
||||||
|
{
|
||||||
|
/* TODO: Configure libinput on device to set tap, acceleration, etc */
|
||||||
|
wlr_cursor_attach_input_device(server->cursor, device);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ int main(int argc, char *argv[])
|
||||||
* Configure a listener to be notified when new outputs are available
|
* Configure a listener to be notified when new outputs are available
|
||||||
* on the backend.
|
* on the backend.
|
||||||
*/
|
*/
|
||||||
server.new_output.notify = server_new_output;
|
server.new_output.notify = output_new;
|
||||||
wl_signal_add(&server.backend->events.new_output, &server.new_output);
|
wl_signal_add(&server.backend->events.new_output, &server.new_output);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
45
src/output.c
45
src/output.c
|
|
@ -184,3 +184,48 @@ void output_frame(struct wl_listener *listener, void *data)
|
||||||
wlr_renderer_end(renderer);
|
wlr_renderer_end(renderer);
|
||||||
wlr_output_commit(output->wlr_output);
|
wlr_output_commit(output->wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void output_new(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
/* This event is rasied by the backend when a new output (aka a display
|
||||||
|
* or monitor) becomes available. */
|
||||||
|
struct server *server = wl_container_of(listener, server, new_output);
|
||||||
|
struct wlr_output *wlr_output = data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some backends don't have modes. DRM+KMS does, and we need to set a
|
||||||
|
* mode before we can use the output. The mode is a tuple of (width,
|
||||||
|
* height, refresh rate), and each monitor supports only a specific set
|
||||||
|
* of modes. We just pick the monitor's preferred mode.
|
||||||
|
* TODO: support user configuration
|
||||||
|
*/
|
||||||
|
if (!wl_list_empty(&wlr_output->modes)) {
|
||||||
|
struct wlr_output_mode *mode =
|
||||||
|
wlr_output_preferred_mode(wlr_output);
|
||||||
|
wlr_output_set_mode(wlr_output, mode);
|
||||||
|
wlr_output_enable(wlr_output, true);
|
||||||
|
if (!wlr_output_commit(wlr_output)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates and configures our state for this output */
|
||||||
|
struct output *output = calloc(1, sizeof(struct output));
|
||||||
|
output->wlr_output = wlr_output;
|
||||||
|
output->server = server;
|
||||||
|
/* Sets up a listener for the frame notify event. */
|
||||||
|
output->frame.notify = output_frame;
|
||||||
|
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||||
|
wl_list_insert(&server->outputs, &output->link);
|
||||||
|
|
||||||
|
/* Adds this to the output layout. The add_auto function arranges
|
||||||
|
* outputs from left-to-right in the order they appear. A more
|
||||||
|
* sophisticated compositor would let the user configure the arrangement
|
||||||
|
* of outputs in the layout.
|
||||||
|
*
|
||||||
|
* The output layout utility automatically adds a wl_output global to
|
||||||
|
* the display, which Wayland clients can see to find out information
|
||||||
|
* about the output (such as DPI, scale factor, manufacturer, etc).
|
||||||
|
*/
|
||||||
|
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
||||||
|
}
|
||||||
|
|
|
||||||
54
src/server.c
54
src/server.c
|
|
@ -1,12 +1,5 @@
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
|
||||||
static void server_new_pointer(struct server *server,
|
|
||||||
struct wlr_input_device *device)
|
|
||||||
{
|
|
||||||
/* TODO: Configure libinput on device to set tap, acceleration, etc */
|
|
||||||
wlr_cursor_attach_input_device(server->cursor, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
void server_new_input(struct wl_listener *listener, void *data)
|
void server_new_input(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
@ -20,7 +13,7 @@ void server_new_input(struct wl_listener *listener, void *data)
|
||||||
keyboard_new(server, device);
|
keyboard_new(server, device);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
server_new_pointer(server, device);
|
cursor_new(server, device);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -68,48 +61,3 @@ void seat_request_set_selection(struct wl_listener *listener, void *data)
|
||||||
struct wlr_seat_request_set_selection_event *event = data;
|
struct wlr_seat_request_set_selection_event *event = data;
|
||||||
wlr_seat_set_selection(server->seat, event->source, event->serial);
|
wlr_seat_set_selection(server->seat, event->source, event->serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_new_output(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
/* This event is rasied by the backend when a new output (aka a display
|
|
||||||
* or monitor) becomes available. */
|
|
||||||
struct server *server = wl_container_of(listener, server, new_output);
|
|
||||||
struct wlr_output *wlr_output = data;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some backends don't have modes. DRM+KMS does, and we need to set a
|
|
||||||
* mode before we can use the output. The mode is a tuple of (width,
|
|
||||||
* height, refresh rate), and each monitor supports only a specific set
|
|
||||||
* of modes. We just pick the monitor's preferred mode.
|
|
||||||
* TODO: support user configuration
|
|
||||||
*/
|
|
||||||
if (!wl_list_empty(&wlr_output->modes)) {
|
|
||||||
struct wlr_output_mode *mode =
|
|
||||||
wlr_output_preferred_mode(wlr_output);
|
|
||||||
wlr_output_set_mode(wlr_output, mode);
|
|
||||||
wlr_output_enable(wlr_output, true);
|
|
||||||
if (!wlr_output_commit(wlr_output)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocates and configures our state for this output */
|
|
||||||
struct output *output = calloc(1, sizeof(struct output));
|
|
||||||
output->wlr_output = wlr_output;
|
|
||||||
output->server = server;
|
|
||||||
/* Sets up a listener for the frame notify event. */
|
|
||||||
output->frame.notify = output_frame;
|
|
||||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
|
||||||
wl_list_insert(&server->outputs, &output->link);
|
|
||||||
|
|
||||||
/* Adds this to the output layout. The add_auto function arranges
|
|
||||||
* outputs from left-to-right in the order they appear. A more
|
|
||||||
* sophisticated compositor would let the user configure the arrangement
|
|
||||||
* of outputs in the layout.
|
|
||||||
*
|
|
||||||
* The output layout utility automatically adds a wl_output global to
|
|
||||||
* the display, which Wayland clients can see to find out information
|
|
||||||
* about the output (such as DPI, scale factor, manufacturer, etc).
|
|
||||||
*/
|
|
||||||
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue