clients: Maximize window when double click on title bar
Signed-off-by: Xiong Zhang <panda0626@gmail.com> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
b9f863ca57
commit
bfb4ade1a0
+25
-1
@@ -365,6 +365,9 @@ struct window_frame {
|
|||||||
struct widget *widget;
|
struct widget *widget;
|
||||||
struct widget *child;
|
struct widget *child;
|
||||||
struct frame *frame;
|
struct frame *frame;
|
||||||
|
|
||||||
|
uint32_t last_time;
|
||||||
|
uint32_t did_double, double_click;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct menu {
|
struct menu {
|
||||||
@@ -2340,6 +2343,7 @@ frame_handle_status(struct window_frame *frame, struct input *input,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DOUBLE_CLICK_PERIOD 250
|
||||||
static void
|
static void
|
||||||
frame_button_handler(struct widget *widget,
|
frame_button_handler(struct widget *widget,
|
||||||
struct input *input, uint32_t time,
|
struct input *input, uint32_t time,
|
||||||
@@ -2350,7 +2354,27 @@ frame_button_handler(struct widget *widget,
|
|||||||
struct window_frame *frame = data;
|
struct window_frame *frame = data;
|
||||||
enum theme_location location;
|
enum theme_location location;
|
||||||
|
|
||||||
location = frame_pointer_button(frame->frame, input, button, state);
|
frame->double_click = 0;
|
||||||
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||||
|
if (time - frame->last_time <= DOUBLE_CLICK_PERIOD) {
|
||||||
|
frame->double_click = 1;
|
||||||
|
frame->did_double = 1;
|
||||||
|
} else
|
||||||
|
frame->did_double = 0;
|
||||||
|
|
||||||
|
frame->last_time = time;
|
||||||
|
} else if (frame->did_double == 1) {
|
||||||
|
frame->double_click = 1;
|
||||||
|
frame->did_double = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frame->double_click)
|
||||||
|
location = frame_double_click(frame->frame, input,
|
||||||
|
button, state);
|
||||||
|
else
|
||||||
|
location = frame_pointer_button(frame->frame, input,
|
||||||
|
button, state);
|
||||||
|
|
||||||
frame_handle_status(frame, input, time, location);
|
frame_handle_status(frame, input, time, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,6 +213,10 @@ frame_touch_down(struct frame *frame, void *data, int32_t id, int x, int y);
|
|||||||
void
|
void
|
||||||
frame_touch_up(struct frame *frame, void *data, int32_t id);
|
frame_touch_up(struct frame *frame, void *data, int32_t id);
|
||||||
|
|
||||||
|
enum theme_location
|
||||||
|
frame_double_click(struct frame *frame, void *pointer,
|
||||||
|
uint32_t button, enum frame_button_state state);
|
||||||
|
|
||||||
void
|
void
|
||||||
frame_repaint(struct frame *frame, cairo_t *cr);
|
frame_repaint(struct frame *frame, cairo_t *cr);
|
||||||
|
|
||||||
|
|||||||
@@ -837,6 +837,37 @@ frame_touch_up(struct frame *frame, void *data, int32_t id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum theme_location
|
||||||
|
frame_double_click(struct frame *frame, void *data,
|
||||||
|
uint32_t btn, enum frame_button_state state)
|
||||||
|
{
|
||||||
|
struct frame_pointer *pointer = frame_pointer_get(frame, data);
|
||||||
|
struct frame_button *button;
|
||||||
|
enum theme_location location = THEME_LOCATION_EXTERIOR;
|
||||||
|
|
||||||
|
location = theme_get_location(frame->theme, pointer->x, pointer->y,
|
||||||
|
frame->width, frame->height,
|
||||||
|
frame->flags & FRAME_FLAG_MAXIMIZED ?
|
||||||
|
THEME_FRAME_MAXIMIZED : 0);
|
||||||
|
|
||||||
|
button = frame_find_button(frame, pointer->x, pointer->y);
|
||||||
|
|
||||||
|
if (location != THEME_LOCATION_TITLEBAR || btn != BTN_LEFT)
|
||||||
|
return location;
|
||||||
|
|
||||||
|
if (state == FRAME_BUTTON_PRESSED) {
|
||||||
|
if (button)
|
||||||
|
frame_button_press(button);
|
||||||
|
else
|
||||||
|
frame->status |= FRAME_STATUS_MAXIMIZE;
|
||||||
|
} else if (state == FRAME_BUTTON_RELEASED) {
|
||||||
|
if (button)
|
||||||
|
frame_button_release(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
frame_repaint(struct frame *frame, cairo_t *cr)
|
frame_repaint(struct frame *frame, cairo_t *cr)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user