Gui improvements
This commit is contained in:
parent
d51444e813
commit
1bdfd5d32b
237
gui.c
237
gui.c
@ -411,17 +411,18 @@ int gui_add_window(unsigned char *contents, char *name, int x, int y, int w, int
|
||||
}
|
||||
|
||||
void gui_destroy_window(int serialno, struct task_t *task) {
|
||||
struct window_t *window;
|
||||
int i, j, k;
|
||||
int isfocused = 0;
|
||||
for (i=0;i<window_count;i++) {
|
||||
for (int i = 0; i < window_count;i++) {
|
||||
if (windows[i]->serialno == serialno) {
|
||||
window = windows[i];
|
||||
isfocused = window->focused;
|
||||
for (k=0;k<task->window_count;k++) {
|
||||
if (task->window_list[k] == window) {
|
||||
for (j=k;j<task->window_count-1;j++) {
|
||||
task->window_list[j] = task->window_list[j+1];
|
||||
struct window_t *win = windows[i];
|
||||
for (int j = i; j < window_count - 1; j++) {
|
||||
windows[j] = windows[j+1];
|
||||
windows[j]->zorder--;
|
||||
}
|
||||
|
||||
for (int j = 0;j < task->window_count;j++) {
|
||||
if (task->window_list[j] == win) {
|
||||
for (int k = j; k < task->window_count - 1; k++) {
|
||||
task->window_list[k] = task->window_list[k+1];
|
||||
}
|
||||
task->window_count--;
|
||||
if (task->window_count == 0) {
|
||||
@ -429,37 +430,22 @@ void gui_destroy_window(int serialno, struct task_t *task) {
|
||||
task->window_list = (void *)0;
|
||||
} else {
|
||||
task->window_list = (struct window_t **)realloc(task->window_list, sizeof(struct window_t *) * task->window_count);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=i;j<window_count-1;j++) {
|
||||
windows[j] = windows[j+1];
|
||||
}
|
||||
|
||||
|
||||
window_count--;
|
||||
|
||||
if (isfocused) {
|
||||
if (window_count > 0) {
|
||||
struct window_t *tofocus = &windows[0];
|
||||
for (i = 1; i < window_count;i++) {
|
||||
if (window[i].zorder > tofocus->zorder && tofocus->minimized == 0) {
|
||||
tofocus = &windows[i];
|
||||
}
|
||||
}
|
||||
tofocus->focused = 1;
|
||||
}
|
||||
if (win->focused && window_count > 0) {
|
||||
windows[window_count - 1]->focused = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
windows = (struct window_t **)realloc(windows, sizeof(struct window_t *) * window_count);
|
||||
keyboard_set_handler(windows[window_count-1]->keyboard_dest);
|
||||
free(window->icon);
|
||||
free(window->contents);
|
||||
free(window);
|
||||
free(win->icon);
|
||||
free(win->contents);
|
||||
free(win);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -569,6 +555,64 @@ int gui_req_input(int wh, struct window_update_req *req) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void gui_sink_to_bottom(int wh) {
|
||||
struct window_t *win;
|
||||
win = windows[wh];
|
||||
|
||||
for (int i = wh; i >= 1; i--) {
|
||||
windows[i] = windows[i - 1];
|
||||
windows[i]->focused = 0;
|
||||
windows[i]->zorder++;
|
||||
}
|
||||
|
||||
windows[0] = win;
|
||||
windows[0]->zorder = 0;
|
||||
windows[0]->focused = 0;
|
||||
windows[window_count-1]->focused = 1;
|
||||
}
|
||||
|
||||
int gui_raise_to_icon_top(int wh) {
|
||||
struct window_t *win;
|
||||
int top_icon = 0;
|
||||
win = windows[wh];
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < window_count; i++) {
|
||||
if (windows[i]->minimized) {
|
||||
top_icon = i;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = wh; i < top_icon; i++) {
|
||||
windows[i] = windows[i+1];
|
||||
windows[i]->zorder--;
|
||||
}
|
||||
windows[top_icon] = win;
|
||||
windows[top_icon]->zorder = top_icon;
|
||||
return top_icon;
|
||||
}
|
||||
|
||||
void gui_raise_to_top(int wh) {
|
||||
struct window_t *win;
|
||||
win = windows[wh];
|
||||
|
||||
for (int i = 0; i < wh; i++) {
|
||||
windows[i]->focused = 0;
|
||||
}
|
||||
|
||||
for (int i = wh; i < window_count - 1; i++) {
|
||||
windows[i] = windows[i+1];
|
||||
windows[i]->zorder--;
|
||||
windows[i]->focused = 0;
|
||||
}
|
||||
windows[window_count - 1] = win;
|
||||
windows[window_count - 1]->zorder = window_count - 1;
|
||||
windows[window_count - 1]->focused = 1;
|
||||
}
|
||||
|
||||
void gui_flip() {
|
||||
int i, c, d;
|
||||
struct window_t *swap;
|
||||
@ -577,6 +621,7 @@ void gui_flip() {
|
||||
|
||||
if (window_count > 0) {
|
||||
if (mouse_get_click(0) == 1) {
|
||||
// search through windows to see if the click belongs to an un-minimized window
|
||||
for (i=window_count-1;i>=0;i--) {
|
||||
if (!(windows[i]->minimized)) {
|
||||
if (mouse_pos_x > windows[i]->posx && mouse_pos_x < windows[i]->posx + windows[i]->width && mouse_pos_y > windows[i]->posy - 25 && mouse_pos_y < windows[i]->posy + windows[i]->height) {
|
||||
@ -587,24 +632,24 @@ void gui_flip() {
|
||||
if (windows[i]->iconx == 0 && windows[i]->icony == 0) {
|
||||
gui_find_icon_space(windows[i]);
|
||||
}
|
||||
gui_sink_to_bottom(i);
|
||||
} else if (mouse_pos_x > windows[i]->posx && mouse_pos_x < windows[i]->posx + 25 && mouse_pos_y > windows[i]->posy - 25 && mouse_pos_y < windows[i]->posy) {
|
||||
windows[i]->close_req = 1;
|
||||
} else if (windows[i]->zorder != window_count -1) {
|
||||
windows[window_count-1]->focused = 0;
|
||||
windows[window_count-1]->zorder = windows[i]->zorder;
|
||||
windows[i]->zorder = window_count - 1;
|
||||
windows[i]->focused = 1;
|
||||
} else if (windows[i]->focused == 0) {
|
||||
keyboard_set_handler(windows[i]->keyboard_dest);
|
||||
gui_raise_to_top(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if the window is minimized restore window
|
||||
for (i=window_count-1;i>=0;i--) {
|
||||
if (windows[i]->minimized) {
|
||||
if (mouse_pos_x > windows[i]->iconx -16 && mouse_pos_x < windows[i]->iconx + 72 && mouse_pos_y > windows[i]->icony -16 && mouse_pos_y < windows[i]->icony + 72) {
|
||||
windows[i]->minimized = 0;
|
||||
gui_raise_to_top(i);
|
||||
keyboard_set_handler(windows[i]->keyboard_dest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -615,43 +660,43 @@ void gui_flip() {
|
||||
for (i=window_count-1;i>=0;i--) {
|
||||
if (!windows[i]->minimized) {
|
||||
if (mouse_pos_x > windows[i]->posx && mouse_pos_x < windows[i]->posx + windows[i]->width && mouse_pos_y > windows[i]->posy && mouse_pos_y < windows[i]->posy + windows[i]->height) {
|
||||
if (windows[i]->lclick != left_btn) {
|
||||
if (windows[i]->event_msg_count < 99) {
|
||||
struct event_msg_t *new_event = (struct event_msg_t *)malloc(sizeof(struct event_msg_t));
|
||||
new_event->type = 2;
|
||||
new_event->code = 1;
|
||||
new_event->state = left_btn;
|
||||
new_event->x = mouse_pos_x - windows[i]->posx;
|
||||
new_event->y = mouse_pos_y - windows[i]->posy;
|
||||
windows[i]->event_msgs[windows[i]->event_msg_count++] = new_event;
|
||||
}
|
||||
windows[i]->lclick = left_btn;
|
||||
}
|
||||
if (windows[i]->lclick != left_btn) {
|
||||
if (windows[i]->event_msg_count < 99) {
|
||||
struct event_msg_t *new_event = (struct event_msg_t *)malloc(sizeof(struct event_msg_t));
|
||||
new_event->type = 2;
|
||||
new_event->code = 1;
|
||||
new_event->state = left_btn;
|
||||
new_event->x = mouse_pos_x - windows[i]->posx;
|
||||
new_event->y = mouse_pos_y - windows[i]->posy;
|
||||
windows[i]->event_msgs[windows[i]->event_msg_count++] = new_event;
|
||||
}
|
||||
windows[i]->lclick = left_btn;
|
||||
}
|
||||
|
||||
if (windows[i]->mclick != middle_btn) {
|
||||
if (windows[i]->event_msg_count < 99) {
|
||||
struct event_msg_t *new_event = (struct event_msg_t *)malloc(sizeof(struct event_msg_t));
|
||||
new_event->type = 2;
|
||||
new_event->code = 2;
|
||||
new_event->state = middle_btn;
|
||||
new_event->x = mouse_pos_x - windows[i]->posx;
|
||||
new_event->y = mouse_pos_y - windows[i]->posy;
|
||||
windows[i]->event_msgs[windows[i]->event_msg_count++] = new_event;
|
||||
}
|
||||
windows[i]->mclick = middle_btn;
|
||||
}
|
||||
if (windows[i]->rclick != right_btn) {
|
||||
if (windows[i]->event_msg_count < 99) {
|
||||
struct event_msg_t *new_event = (struct event_msg_t *)malloc(sizeof(struct event_msg_t));
|
||||
new_event->type = 2;
|
||||
new_event->code = 3;
|
||||
new_event->state = right_btn;
|
||||
new_event->x = mouse_pos_x - windows[i]->posx;
|
||||
new_event->y = mouse_pos_y - windows[i]->posy;
|
||||
windows[i]->event_msgs[windows[i]->event_msg_count++] = new_event;
|
||||
}
|
||||
windows[i]->rclick =right_btn;
|
||||
}
|
||||
if (windows[i]->mclick != middle_btn) {
|
||||
if (windows[i]->event_msg_count < 99) {
|
||||
struct event_msg_t *new_event = (struct event_msg_t *)malloc(sizeof(struct event_msg_t));
|
||||
new_event->type = 2;
|
||||
new_event->code = 2;
|
||||
new_event->state = middle_btn;
|
||||
new_event->x = mouse_pos_x - windows[i]->posx;
|
||||
new_event->y = mouse_pos_y - windows[i]->posy;
|
||||
windows[i]->event_msgs[windows[i]->event_msg_count++] = new_event;
|
||||
}
|
||||
windows[i]->mclick = middle_btn;
|
||||
}
|
||||
if (windows[i]->rclick != right_btn) {
|
||||
if (windows[i]->event_msg_count < 99) {
|
||||
struct event_msg_t *new_event = (struct event_msg_t *)malloc(sizeof(struct event_msg_t));
|
||||
new_event->type = 2;
|
||||
new_event->code = 3;
|
||||
new_event->state = right_btn;
|
||||
new_event->x = mouse_pos_x - windows[i]->posx;
|
||||
new_event->y = mouse_pos_y - windows[i]->posy;
|
||||
windows[i]->event_msgs[windows[i]->event_msg_count++] = new_event;
|
||||
}
|
||||
windows[i]->rclick =right_btn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -661,20 +706,36 @@ void gui_flip() {
|
||||
if (mouse_is_dragging(0)) {
|
||||
for (i=window_count-1;i>=0;i--) {
|
||||
if (!(windows[i]->minimized)) {
|
||||
|
||||
if (windows[i]->drag_start_x > -1) {
|
||||
|
||||
// if allready dragging... update position
|
||||
int xoffset = mouse_pos_x - windows[i]->drag_start_x;
|
||||
int yoffset = mouse_pos_y - windows[i]->drag_start_y;
|
||||
|
||||
windows[i]->posx += xoffset;
|
||||
windows[i]->posy += yoffset;
|
||||
}
|
||||
|
||||
if (mouse_pos_x > windows[i]->posx && mouse_pos_x < windows[i]->posx + windows[i]->width && mouse_pos_y > windows[i]->posy - 25 && mouse_pos_y < windows[i]->posy) {
|
||||
windows[i]->drag_start_x = mouse_pos_x;
|
||||
windows[i]->drag_start_y = mouse_pos_y;
|
||||
handled_drag = 1;
|
||||
break;
|
||||
} else {
|
||||
// if not dragging, start
|
||||
if (mouse_pos_x > windows[i]->posx &&
|
||||
mouse_pos_x < windows[i]->posx + windows[i]->width &&
|
||||
mouse_pos_y > windows[i]->posy && mouse_pos_y < windows[i]->posy + windows[i]->height) {
|
||||
// break if titlebar for app is occluded by app area of higher app
|
||||
break;
|
||||
} else
|
||||
if (mouse_pos_x > windows[i]->posx &&
|
||||
mouse_pos_x < windows[i]->posx + windows[i]->width &&
|
||||
mouse_pos_y > windows[i]->posy - 25 && mouse_pos_y < windows[i]->posy) {
|
||||
// drag this app, but first move it to the top.
|
||||
gui_raise_to_top(i);
|
||||
windows[window_count - 1]->drag_start_x = mouse_pos_x;
|
||||
windows[window_count - 1]->drag_start_y = mouse_pos_y;
|
||||
handled_drag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -683,18 +744,28 @@ void gui_flip() {
|
||||
for (i=window_count-1;i>=0;i--) {
|
||||
if (windows[i]->minimized) {
|
||||
if (windows[i]->drag_start_x > -1) {
|
||||
|
||||
// if allready dragging... update position
|
||||
int xoffset = mouse_pos_x - windows[i]->drag_start_x;
|
||||
int yoffset = mouse_pos_y - windows[i]->drag_start_y;
|
||||
|
||||
windows[i]->iconx += xoffset;
|
||||
windows[i]->icony += yoffset;
|
||||
}
|
||||
if (mouse_pos_x > windows[i]->iconx -16 && mouse_pos_x < windows[i]->iconx + 72 && mouse_pos_y > windows[i]->icony -16 && mouse_pos_y < windows[i]->icony + 72) {
|
||||
|
||||
|
||||
windows[i]->drag_start_x = mouse_pos_x;
|
||||
windows[i]->drag_start_y = mouse_pos_y;
|
||||
break;
|
||||
} else {
|
||||
// if not dragging, start
|
||||
if (mouse_pos_x > windows[i]->iconx &&
|
||||
mouse_pos_x < windows[i]->iconx + 64 &&
|
||||
mouse_pos_y > windows[i]->icony && mouse_pos_y < windows[i]->icony + 64) {
|
||||
// drag this icon, but first move it to the bottom.
|
||||
int top_icon = gui_raise_to_icon_top(i);
|
||||
windows[top_icon]->drag_start_x = mouse_pos_x;
|
||||
windows[top_icon]->drag_start_y = mouse_pos_y;
|
||||
handled_drag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -707,6 +778,7 @@ void gui_flip() {
|
||||
}
|
||||
|
||||
// sort windows
|
||||
/*
|
||||
for (c = 0 ; c < ( window_count - 1 ); c++) {
|
||||
for (d = 0 ; d < window_count - c - 1; d++) {
|
||||
if (windows[d]->zorder > windows[d+1]->zorder) {
|
||||
@ -716,6 +788,7 @@ void gui_flip() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
// draw desktop
|
||||
if (wallpaper == (void *)0 || wallpaper_lock == 1) {
|
||||
@ -804,7 +877,7 @@ void render(unsigned char* dest, unsigned char* src, unsigned int src_width, uns
|
||||
}
|
||||
|
||||
for (index = 0,dindex=0; index < size; index += src_depth,dindex+=depth) {
|
||||
if (dest_x + (dindex / depth) > dest_width) {
|
||||
if (dest_x + (dindex / depth) >= dest_width) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -82,5 +82,4 @@ extern void quinn_free_textbox(struct widget_t *w);
|
||||
extern void quinn_surface_set_cooked(struct widget_t *w, int cooked);
|
||||
extern char *quinn_surface_get_surface(struct widget_t *w);
|
||||
extern void quinn_show_message_box_xy(int wh, char *title, char *message, unsigned char show_cancel, void (*callback)(), int x, int y);
|
||||
//extern void quinn_render_offset(unsigned char* dest, unsigned char* src, unsigned int src_width, unsigned int src_height, unsigned int offset_x, unsigned int offset_y, int dest_x, int dest_y, unsigned int dest_width, unsigned int dest_height);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user