Ejemplo n.º 1
0
static void
surface_transform(void *data)
{
    struct weston_compositor *compositor = data;
    struct weston_surface *surface;
    struct weston_view *view;
    float x, y;

    surface = weston_surface_create(compositor);
    assert(surface);
    view = weston_view_create(surface);
    assert(view);
    surface->width = 200;
    surface->height = 200;
    weston_view_set_position(view, 100, 100);
    weston_view_update_transform(view);
    weston_view_to_global_float(view, 20, 20, &x, &y);

    fprintf(stderr, "20,20 maps to %f, %f\n", x, y);
    assert(x == 120 && y == 120);

    weston_view_set_position(view, 150, 300);
    weston_view_update_transform(view);
    weston_view_to_global_float(view, 50, 40, &x, &y);
    assert(x == 200 && y == 340);

    wl_display_terminate(compositor->wl_display);
}
Ejemplo n.º 2
0
static void
quit(void *data, uint32_t time, uint32_t value, uint32_t state)
{
	if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
		return;

	wl_display_terminate(display);
}
Ejemplo n.º 3
0
void sway_terminate(int exit_code) {
	if (!server.wl_display) {
		// Running as IPC client
		exit(exit_code);
	} else {
		// Running as server
		terminate_request = true;
		exit_value = exit_code;
		ipc_event_shutdown("exit");
		wl_display_terminate(server.wl_display);
	}
}
Ejemplo n.º 4
0
static int
sigchld_handler(int signal_number, void *data)
{
	struct display *display = data;
	int status;

	waitpid(-1, &status, 0);
	display->child_exit_status = status;

	wl_display_terminate(display->display);

	return 0;
}
Ejemplo n.º 5
0
Archivo: wlc.c Proyecto: UIKit0/wlc
void
wlc_set_active(bool active)
{
   if (active == wlc.active)
      return;

   wlc.active = active;
   struct wlc_activate_event ev = { .active = active, .vt = 0 };
   wl_signal_emit(&wlc.signals.activate, &ev);
   wlc_log(WLC_LOG_INFO, (wlc.active ? "become active" : "deactive"));
}

bool
wlc_get_active(void)
{
   return wlc.active;
}

const struct wlc_interface*
wlc_interface(void)
{
   return &wlc.interface;
}

struct wlc_system_signals*
wlc_system_signals(void)
{
   return &wlc.signals;
}

struct wl_event_loop*
wlc_event_loop(void)
{
   return wl_display_get_event_loop(wlc.display);
}

struct wl_display*
wlc_display(void)
{
   return wlc.display;
}

static void
compositor_event(struct wl_listener *listener, void *data)
{
   (void)listener, (void)data;
   // this event is currently only used for knowing when compositor died
   wl_display_terminate(wlc.display);
}
Ejemplo n.º 6
0
static void
surface_to_from_global(void *data)
{
	struct weston_compositor *compositor = data;
	struct weston_surface *surface;
	struct weston_view *view;
	float x, y;
	wl_fixed_t fx, fy;
	int32_t ix, iy;

	surface = weston_surface_create(compositor);
	assert(surface);
	view = weston_view_create(surface);
	assert(view);
	surface->width = 50;
	surface->height = 50;
	weston_view_set_position(view, 5, 10);
	weston_view_update_transform(view);

	weston_view_to_global_float(view, 33, 22, &x, &y);
	assert(x == 38 && y == 32);

	weston_view_to_global_float(view, -8, -2, &x, &y);
	assert(x == -3 && y == 8);

	weston_view_to_global_fixed(view, wl_fixed_from_int(12),
				       wl_fixed_from_int(5), &fx, &fy);
	assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));

	weston_view_from_global_float(view, 38, 32, &x, &y);
	assert(x == 33 && y == 22);

	weston_view_from_global_float(view, 42, 5, &x, &y);
	assert(x == 37 && y == -5);

	weston_view_from_global_fixed(view, wl_fixed_from_int(21),
					 wl_fixed_from_int(100), &fx, &fy);
	assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));

	weston_view_from_global(view, 0, 0, &ix, &iy);
	assert(ix == -5 && iy == -10);

	weston_view_from_global(view, 5, 10, &ix, &iy);
	assert(ix == 0 && iy == 0);

	wl_display_terminate(compositor->wl_display);
}
Ejemplo n.º 7
0
static void
surface_to_from_global(void *data)
{
	struct weston_compositor *compositor = data;
	struct weston_surface *surface;
	float x, y;
	wl_fixed_t fx, fy;
	int32_t ix, iy;

	surface = weston_surface_create(compositor);
	weston_surface_configure(surface, 5, 10, 50, 50);
	weston_surface_update_transform(surface);

	weston_surface_to_global_float(surface, 33, 22, &x, &y);
	assert(x == 38 && y == 32);

	weston_surface_to_global_float(surface, -8, -2, &x, &y);
	assert(x == -3 && y == 8);

	weston_surface_to_global_fixed(surface, wl_fixed_from_int(12),
				       wl_fixed_from_int(5), &fx, &fy);
	assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));

	weston_surface_from_global_float(surface, 38, 32, &x, &y);
	assert(x == 33 && y == 22);

	weston_surface_from_global_float(surface, 42, 5, &x, &y);
	assert(x == 37 && y == -5);

	weston_surface_from_global_fixed(surface, wl_fixed_from_int(21),
					 wl_fixed_from_int(100), &fx, &fy);
	assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));

	weston_surface_from_global(surface, 0, 0, &ix, &iy);
	assert(ix == -5 && iy == -10);

	weston_surface_from_global(surface, 5, 10, &ix, &iy);
	assert(ix == 0 && iy == 0);

	wl_display_terminate(compositor->wl_display);
}
Ejemplo n.º 8
0
static void
surface_transform(void *data)
{
	struct weston_compositor *compositor = data;
	struct weston_surface *surface;
	float x, y;

	surface = weston_surface_create(compositor);
	weston_surface_configure(surface, 100, 100, 200, 200);
	weston_surface_update_transform(surface);
	weston_surface_to_global_float(surface, 20, 20, &x, &y);

	fprintf(stderr, "20,20 maps to %f, %f\n", x, y);
	assert(x == 120 && y == 120);

	weston_surface_set_position(surface, 150, 300);
	weston_surface_update_transform(surface);
	weston_surface_to_global_float(surface, 50, 40, &x, &y);
	assert(x == 200 && y == 340);

	wl_display_terminate(compositor->wl_display);
}