From 50417f60b69203cd964dc2f29a1e0dccf6fe3c37 Mon Sep 17 00:00:00 2001 From: bitbegin Date: Mon, 13 Apr 2020 16:33:42 +0800 Subject: [PATCH] FIX: load gui-console's configs not right --- modules/view/backends/gtk3/events.reds | 11 +++++++-- modules/view/backends/gtk3/gtk.reds | 9 ++++++++ modules/view/backends/gtk3/gui.reds | 4 ++++ modules/view/backends/gtk3/handlers.reds | 29 ++++++++++++++++++------ 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/modules/view/backends/gtk3/events.reds b/modules/view/backends/gtk3/events.reds index a7a222e73d..79ebf60b56 100644 --- a/modules/view/backends/gtk3/events.reds +++ b/modules/view/backends/gtk3/events.reds @@ -496,8 +496,15 @@ get-event-offset: func [ offset/header: TYPE_PAIR widget: as handle! evt/msg - sz: (as red-pair! get-face-values widget) + FACE_OBJ_SIZE - as red-value! sz + either null? GET-HMENU(widget) [ + sz: (as red-pair! get-face-values widget) + FACE_OBJ_SIZE + offset/x: sz/x + offset/y: sz/y + ][ + offset/x: GET-CONTAINER-W(widget) + offset/y: GET-CONTAINER-H(widget) + ] + as red-value! offset ] any [ evt/type = EVT_ZOOM diff --git a/modules/view/backends/gtk3/gtk.reds b/modules/view/backends/gtk3/gtk.reds index a0fb8aa209..1ecee34e02 100644 --- a/modules/view/backends/gtk3/gtk.reds +++ b/modules/view/backends/gtk3/gtk.reds @@ -3275,6 +3275,9 @@ caption-id: g_quark_from_string "caption-id" in-loop-id: g_quark_from_string "in-loop-id" first-radio-id: g_quark_from_string "first-radio-id" resend-event-id: g_quark_from_string "resend-event-id" +hmenu-id: g_quark_from_string "hmenu-id" +container-w: g_quark_from_string "container-w" +container-h: g_quark_from_string "container-h" #define SET-CONTAINER(s d) [g_object_set_qdata s container-id d] #define GET-CONTAINER(s) [g_object_get_qdata s container-id] @@ -3294,3 +3297,9 @@ resend-event-id: g_quark_from_string "resend-event-id" #define GET-FIRST-RADIO(s) [g_object_get_qdata s first-radio-id] #define SET-RESEND-EVENT(s d) [g_object_set_qdata s resend-event-id d] #define GET-RESEND-EVENT(s) [g_object_get_qdata s resend-event-id] +#define SET-HMENU(s d) [g_object_set_qdata s hmenu-id d] +#define GET-HMENU(s) [g_object_get_qdata s hmenu-id] +#define SET-CONTAINER-W(s d) [g_object_set_qdata s container-w as int-ptr! d] +#define GET-CONTAINER-W(s) [as integer! g_object_get_qdata s container-w] +#define SET-CONTAINER-H(s d) [g_object_set_qdata s container-h as int-ptr! d] +#define GET-CONTAINER-H(s) [as integer! g_object_get_qdata s container-h] diff --git a/modules/view/backends/gtk3/gui.reds b/modules/view/backends/gtk3/gui.reds index a0d0e12c25..c8739ed3a9 100644 --- a/modules/view/backends/gtk3/gui.reds +++ b/modules/view/backends/gtk3/gui.reds @@ -1738,12 +1738,16 @@ OS-make-view: func [ winbox: gtk_box_new GTK_ORIENTATION_VERTICAL 0 gtk_container_add widget winbox + hMenu: null if menu-bar? menu window [ hMenu: gtk_menu_bar_new gtk_widget_show hMenu build-menu menu hMenu widget gtk_box_pack_start winbox hMenu no yes 0 + SET-CONTAINER-W(widget size/x) + SET-CONTAINER-H(widget size/y) ] + SET-HMENU(widget hMenu) gtk_widget_show winbox container: gtk_layout_new null null gtk_layout_set_size container size/x size/y diff --git a/modules/view/backends/gtk3/handlers.reds b/modules/view/backends/gtk3/handlers.reds index 0193dbbd7f..9e92609954 100644 --- a/modules/view/backends/gtk3/handlers.reds +++ b/modules/view/backends/gtk3/handlers.reds @@ -457,7 +457,16 @@ window-configure-event: func [ event [GdkEventConfigure!] widget [handle!] return: [integer!] + /local + x [integer!] + y [integer!] + offset [red-pair!] ][ + x: 0 y: 0 + gtk_window_get_position widget :x :y + offset: (as red-pair! get-face-values widget) + FACE_OBJ_OFFSET + offset/x: x + offset/y: y unless null? GET-STARTRESIZE(widget) [ SET-RESIZING(widget widget) ] @@ -479,15 +488,21 @@ window-size-allocate: func [ if null? GET-STARTRESIZE(widget) [ SET-STARTRESIZE(widget widget) ] - cont: GET-CONTAINER(widget) - w: gtk_widget_get_allocated_width cont - h: gtk_widget_get_allocated_height cont + + unless null? GET-HMENU(widget) [ + cont: GET-CONTAINER(widget) + w: gtk_widget_get_allocated_width cont + h: gtk_widget_get_allocated_height cont + SET-CONTAINER-W(widget w) + SET-CONTAINER-H(widget h) + ] + if any [ - sz/x <> w - sz/y <> h + sz/x <> rect/width + sz/y <> rect/height ][ - sz/x: w - sz/y: h + sz/x: rect/width + sz/y: rect/height either null? GET-RESIZING(widget) [ make-event widget 0 EVT_SIZE ][