Thanks :) I'll keep these style issues in mind :)
-m On Fri, Aug 15, 2014 at 3:10 PM, Pekka Paalanen <[email protected]> wrote: > On Tue, 5 Aug 2014 15:05:59 +0200 > [email protected] wrote: > >> From: Magnus Hoff <[email protected]> >> >> --- >> clients/terminal.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 48 insertions(+) >> >> diff --git a/clients/terminal.c b/clients/terminal.c >> index eb133cd..d238f04 100644 >> --- a/clients/terminal.c >> +++ b/clients/terminal.c >> @@ -447,6 +447,7 @@ struct terminal { >> int width, height, row, column, max_width; >> uint32_t buffer_height; >> uint32_t start, end, saved_start, log_size; >> + wl_fixed_t smooth_scroll; >> int saved_row, saved_column; >> int scrolling; >> int send_cursor_position; >> @@ -2785,6 +2786,52 @@ motion_handler(struct widget *widget, >> return CURSOR_IBEAM; >> } >> >> +// This magnitude is chosen rather arbitrarily. Really, the scrolling >> +// should happen on a (fractional) pixel basis, not a line basis. >> +#define AXIS_UNITS_PER_LINE 256 >> + >> +static void >> +axis_handler(struct widget *widget, >> + struct input *input, uint32_t time, >> + uint32_t axis, >> + wl_fixed_t value, >> + void *data) > > Mis-indented. > >> +{ >> + struct terminal *terminal = data; >> + >> + if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL) return; >> + >> + terminal->smooth_scroll += value; >> + int lines = terminal->smooth_scroll / AXIS_UNITS_PER_LINE; > > Variable declarations always in the beginning of a block. > >> + terminal->smooth_scroll -= lines * AXIS_UNITS_PER_LINE; >> + >> + if (lines > 0) { >> + if (terminal->scrolling) { >> + if ((uint32_t)lines > terminal->saved_start - >> terminal->start) >> + lines = terminal->saved_start - >> terminal->start; >> + } else { >> + lines = 0; >> + } >> + } else if (lines < 0) { >> + uint32_t neg_lines = -lines; > > Add empty line between declarations and code. > >> + if (neg_lines > terminal->log_size + terminal->start - >> terminal->end) >> + lines = terminal->end - terminal->log_size - >> terminal->start; >> + } >> + >> + if (lines) { >> + if (!terminal->scrolling) >> + terminal->saved_start = terminal->start; >> + terminal->scrolling = 1; >> + >> + terminal->start += lines; >> + terminal->row -= lines; >> + terminal->selection_start_row -= lines; >> + terminal->selection_end_row -= lines; >> + >> + widget_schedule_redraw(widget); >> + } >> +} >> + >> static void >> output_handler(struct window *window, struct output *output, int enter, >> void *data) >> @@ -2880,6 +2927,7 @@ terminal_create(struct display *display) >> widget_set_button_handler(terminal->widget, button_handler); >> widget_set_enter_handler(terminal->widget, enter_handler); >> widget_set_motion_handler(terminal->widget, motion_handler); >> + widget_set_axis_handler(terminal->widget, axis_handler); >> widget_set_touch_up_handler(terminal->widget, touch_up_handler); >> widget_set_touch_down_handler(terminal->widget, touch_down_handler); >> widget_set_touch_motion_handler(terminal->widget, >> touch_motion_handler); > > Hi, > > that's a nice feature, pushed with the above code style fixed up. The > too long lines are still left, since I didn't immediately see a nice > way to cut them. > > > Thanks, > pq _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
