Merge remote-tracking branch 'pq/simple-fixes'
This commit is contained in:
commit
a8479f1e3a
@ -11,6 +11,12 @@ libexec_PROGRAMS = \
|
||||
$(tablet_shell) \
|
||||
$(screenshooter)
|
||||
|
||||
AM_CFLAGS = $(GCC_CFLAGS)
|
||||
AM_CPPFLAGS = \
|
||||
-DDATADIR='"$(datadir)"' \
|
||||
-DBINDIR='"$(bindir)"' \
|
||||
$(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS)
|
||||
|
||||
if BUILD_SIMPLE_CLIENTS
|
||||
simple_clients_programs = \
|
||||
simple-egl \
|
||||
@ -18,12 +24,15 @@ simple_clients_programs = \
|
||||
simple-touch
|
||||
|
||||
simple_egl_SOURCES = simple-egl.c
|
||||
simple_egl_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
|
||||
simple_egl_LDADD = $(SIMPLE_CLIENT_LIBS) -lm
|
||||
|
||||
simple_shm_SOURCES = simple-shm.c
|
||||
simple_shm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
|
||||
simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS)
|
||||
|
||||
simple_touch_SOURCES = simple-touch.c
|
||||
simple_touch_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
|
||||
simple_touch_LDADD = $(SIMPLE_CLIENT_LIBS)
|
||||
endif
|
||||
|
||||
@ -46,12 +55,6 @@ screenshooter = weston-screenshooter
|
||||
|
||||
noinst_LIBRARIES = libtoytoolkit.a
|
||||
|
||||
AM_CFLAGS = $(GCC_CFLAGS)
|
||||
AM_CPPFLAGS = \
|
||||
-DDATADIR='"$(datadir)"' \
|
||||
-DBINDIR='"$(bindir)"' \
|
||||
$(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS)
|
||||
|
||||
libtoytoolkit_a_SOURCES = \
|
||||
window.c \
|
||||
window.h \
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-egl.h>
|
||||
|
||||
struct display {
|
||||
struct wl_display *display;
|
||||
@ -101,6 +100,17 @@ create_window(struct display *display, int width, int height)
|
||||
struct window *window;
|
||||
|
||||
window = malloc(sizeof *window);
|
||||
|
||||
window->buffer = create_shm_buffer(display,
|
||||
width, height,
|
||||
WL_SHM_FORMAT_XRGB8888,
|
||||
&window->shm_data);
|
||||
|
||||
if (!window->buffer) {
|
||||
free(window);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
window->callback = NULL;
|
||||
window->display = display;
|
||||
window->width = width;
|
||||
@ -108,10 +118,6 @@ create_window(struct display *display, int width, int height)
|
||||
window->surface = wl_compositor_create_surface(display->compositor);
|
||||
window->shell_surface = wl_shell_get_shell_surface(display->shell,
|
||||
window->surface);
|
||||
window->buffer = create_shm_buffer(display,
|
||||
width, height,
|
||||
WL_SHM_FORMAT_XRGB8888,
|
||||
&window->shm_data);
|
||||
|
||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||
|
||||
@ -130,21 +136,56 @@ destroy_window(struct window *window)
|
||||
free(window);
|
||||
}
|
||||
|
||||
static void
|
||||
paint_pixels(void *image, int width, int height, uint32_t time)
|
||||
{
|
||||
const int halfh = height / 2;
|
||||
const int halfw = width / 2;
|
||||
int ir, or;
|
||||
uint32_t *pixel = image;
|
||||
int y;
|
||||
|
||||
/* squared radii thresholds */
|
||||
or = (halfw < halfh ? halfw : halfh) - 8;
|
||||
ir = or - 32;
|
||||
or *= or;
|
||||
ir *= ir;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
int x;
|
||||
int y2 = (y - halfh) * (y - halfh);
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
uint32_t v;
|
||||
|
||||
/* squared distance from center */
|
||||
int r2 = (x - halfw) * (x - halfw) + y2;
|
||||
|
||||
if (r2 < ir)
|
||||
v = (r2 / 32 + time / 64) * 0x0080401;
|
||||
else if (r2 < or)
|
||||
v = (y + time / 32) * 0x0080401;
|
||||
else
|
||||
v = (x + time / 16) * 0x0080401;
|
||||
v &= 0x00ffffff;
|
||||
|
||||
/* cross if compositor uses X from XRGB as alpha */
|
||||
if (abs(x - y) > 6 && abs(x + y - height) > 6)
|
||||
v |= 0xff000000;
|
||||
|
||||
*pixel++ = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_callback_listener frame_listener;
|
||||
|
||||
static void
|
||||
redraw(void *data, struct wl_callback *callback, uint32_t time)
|
||||
{
|
||||
struct window *window = data;
|
||||
uint32_t *p;
|
||||
int i, end, offset;
|
||||
|
||||
p = window->shm_data;
|
||||
end = window->width * window->height;
|
||||
offset = time >> 4;
|
||||
for (i = 0; i < end; i++)
|
||||
p[i] = (i + offset) * 0x0080401;
|
||||
|
||||
paint_pixels(window->shm_data, window->width, window->height, time);
|
||||
wl_surface_attach(window->surface, window->buffer, 0, 0);
|
||||
wl_surface_damage(window->surface,
|
||||
0, 0, window->width, window->height);
|
||||
@ -258,6 +299,8 @@ main(int argc, char **argv)
|
||||
|
||||
display = create_display();
|
||||
window = create_window(display, 250, 250);
|
||||
if (!window)
|
||||
return 1;
|
||||
|
||||
sigint.sa_handler = signal_int;
|
||||
sigemptyset(&sigint.sa_mask);
|
||||
|
@ -2608,14 +2608,15 @@ load_module(const char *name, const char *entrypoint, void **handle)
|
||||
module = dlopen(path, RTLD_LAZY);
|
||||
if (!module) {
|
||||
fprintf(stderr,
|
||||
"failed to load module: %s\n", dlerror());
|
||||
"failed to load module '%s': %s\n", path, dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
init = dlsym(module, entrypoint);
|
||||
if (!init) {
|
||||
fprintf(stderr,
|
||||
"failed to lookup init function: %s\n", dlerror());
|
||||
"failed to lookup init function in '%s': %s\n",
|
||||
path, dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2639,7 +2640,7 @@ int main(int argc, char *argv[])
|
||||
char *shell = NULL;
|
||||
char *module = NULL;
|
||||
int32_t idle_time = 300;
|
||||
int32_t xserver;
|
||||
int32_t xserver = 0;
|
||||
char *socket_name = NULL;
|
||||
char *config_file;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user