Merge branch 'master' into wayland-input

This commit is contained in:
nyorain 2017-06-22 17:23:17 +02:00
commit 0813c1dd39
7 changed files with 11 additions and 53 deletions

View File

@ -47,15 +47,6 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_renderer_end(sample->renderer); wlr_renderer_end(sample->renderer);
} }
static void handle_keyboard_key(struct keyboard_state *kbstate,
xkb_keysym_t sym, enum wlr_key_state key_state) {
if (sym == XKB_KEY_Escape) {
kbstate->compositor->exit = true;
} else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
}
}
static void handle_pointer_motion(struct pointer_state *pstate, static void handle_pointer_motion(struct pointer_state *pstate,
double d_x, double d_y) { double d_x, double d_y) {
struct sample_state *state = pstate->compositor->data; struct sample_state *state = pstate->compositor->data;
@ -117,7 +108,6 @@ int main(int argc, char *argv[]) {
compositor.data = &state; compositor.data = &state;
compositor.output_add_cb = handle_output_add; compositor.output_add_cb = handle_output_add;
compositor.output_frame_cb = handle_output_frame; compositor.output_frame_cb = handle_output_frame;
compositor.keyboard_key_cb = handle_keyboard_key;
compositor.pointer_motion_cb = handle_pointer_motion; compositor.pointer_motion_cb = handle_pointer_motion;
compositor.pointer_button_cb = handle_pointer_button; compositor.pointer_button_cb = handle_pointer_button;
compositor.pointer_axis_cb = handle_pointer_axis; compositor.pointer_axis_cb = handle_pointer_axis;

View File

@ -107,9 +107,6 @@ static void handle_keyboard_key(struct keyboard_state *kbstate,
// Also, key repeat // Also, key repeat
if (key_state == WLR_KEY_PRESSED) { if (key_state == WLR_KEY_PRESSED) {
switch (sym) { switch (sym) {
case XKB_KEY_Escape:
kbstate->compositor->exit = true;
break;
case XKB_KEY_Left: case XKB_KEY_Left:
update_velocities(kbstate->compositor, -16, 0); update_velocities(kbstate->compositor, -16, 0);
break; break;
@ -123,10 +120,6 @@ static void handle_keyboard_key(struct keyboard_state *kbstate,
update_velocities(kbstate->compositor, 0, 16); update_velocities(kbstate->compositor, 0, 16);
break; break;
} }
if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
}
} }
} }

View File

@ -42,6 +42,11 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
if (kbstate->compositor->keyboard_key_cb) { if (kbstate->compositor->keyboard_key_cb) {
kbstate->compositor->keyboard_key_cb(kbstate, sym, key_state); kbstate->compositor->keyboard_key_cb(kbstate, sym, key_state);
} }
if (sym == XKB_KEY_Escape) {
wl_display_terminate(kbstate->compositor->display);
} else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
}
} }
xkb_state_update_key(kbstate->xkb_state, keycode, xkb_state_update_key(kbstate->xkb_state, keycode,
event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP); event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
@ -470,10 +475,7 @@ void compositor_init(struct compositor_state *state) {
} }
void compositor_run(struct compositor_state *state) { void compositor_run(struct compositor_state *state) {
while (!state->exit) { wl_display_run(state->display);
wl_event_loop_dispatch(state->event_loop, 0);
}
wlr_backend_destroy(state->backend); wlr_backend_destroy(state->backend);
wlr_session_finish(state->session); wlr_session_finish(state->session);
wl_display_destroy(state->display); wl_display_destroy(state->display);

View File

@ -38,15 +38,6 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
static void handle_keyboard_key(struct keyboard_state *kbstate,
xkb_keysym_t sym, enum wlr_key_state key_state) {
if (sym == XKB_KEY_Escape) {
kbstate->compositor->exit = true;
} else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
}
}
int main() { int main() {
struct sample_state state = { struct sample_state state = {
.color = { 1.0, 0.0, 0.0 }, .color = { 1.0, 0.0, 0.0 },
@ -55,7 +46,6 @@ int main() {
struct compositor_state compositor = { 0, struct compositor_state compositor = { 0,
.data = &state, .data = &state,
.output_frame_cb = handle_output_frame, .output_frame_cb = handle_output_frame,
.keyboard_key_cb = handle_keyboard_key,
}; };
compositor_init(&compositor); compositor_init(&compositor);
compositor_run(&compositor); compositor_run(&compositor);

View File

@ -76,15 +76,6 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_renderer_end(sample->renderer); wlr_renderer_end(sample->renderer);
} }
static void handle_keyboard_key(struct keyboard_state *kbstate,
xkb_keysym_t sym, enum wlr_key_state key_state) {
if (sym == XKB_KEY_Escape) {
kbstate->compositor->exit = true;
} else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
}
}
static void handle_tool_axis(struct tablet_tool_state *tstate, static void handle_tool_axis(struct tablet_tool_state *tstate,
struct wlr_event_tablet_tool_axis *event) { struct wlr_event_tablet_tool_axis *event) {
struct sample_state *sample = tstate->compositor->data; struct sample_state *sample = tstate->compositor->data;
@ -152,7 +143,6 @@ int main(int argc, char *argv[]) {
struct compositor_state compositor = { 0, struct compositor_state compositor = { 0,
.data = &state, .data = &state,
.output_frame_cb = handle_output_frame, .output_frame_cb = handle_output_frame,
.keyboard_key_cb = handle_keyboard_key,
.tool_axis_cb = handle_tool_axis, .tool_axis_cb = handle_tool_axis,
.tool_proximity_cb = handle_tool_proximity, .tool_proximity_cb = handle_tool_proximity,
.tool_button_cb = handle_tool_button, .tool_button_cb = handle_tool_button,

View File

@ -54,15 +54,6 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_renderer_end(sample->renderer); wlr_renderer_end(sample->renderer);
} }
static void handle_keyboard_key(struct keyboard_state *kbstate,
xkb_keysym_t sym, enum wlr_key_state key_state) {
if (sym == XKB_KEY_Escape) {
kbstate->compositor->exit = true;
} else if (key_state == WLR_KEY_PRESSED && sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
wlr_session_change_vt(kbstate->compositor->session, sym - XKB_KEY_F1 + 1);
}
}
static void handle_touch_down(struct touch_state *tstate, int32_t slot, static void handle_touch_down(struct touch_state *tstate, int32_t slot,
double x, double y, double width, double height) { double x, double y, double width, double height) {
struct sample_state *sample = tstate->compositor->data; struct sample_state *sample = tstate->compositor->data;
@ -104,7 +95,6 @@ int main(int argc, char *argv[]) {
struct compositor_state compositor = { 0, struct compositor_state compositor = { 0,
.data = &state, .data = &state,
.output_frame_cb = handle_output_frame, .output_frame_cb = handle_output_frame,
.keyboard_key_cb = handle_keyboard_key,
.touch_down_cb = handle_touch_down, .touch_down_cb = handle_touch_down,
.touch_up_cb = handle_touch_up, .touch_up_cb = handle_touch_up,
.touch_motion_cb = handle_touch_motion, .touch_motion_cb = handle_touch_motion,

View File

@ -89,8 +89,11 @@ bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode
if (!output->impl || !output->impl->set_mode) { if (!output->impl || !output->impl->set_mode) {
return false; return false;
} }
bool result = output->impl->set_mode(output->state, mode);
if (result) {
wlr_output_update_matrix(output); wlr_output_update_matrix(output);
return output->impl->set_mode(output->state, mode); }
return result;
} }
void wlr_output_transform(struct wlr_output *output, void wlr_output_transform(struct wlr_output *output,