Skip to content

Commit

Permalink
FIX: issue #5506 (VID area blocked and slow on big text)
Browse files Browse the repository at this point in the history
Temporary fix until object! gets a 'on-get event.
Adds a `no-sync` flag to disable auto-sync of `/text` facet.
Use `system/view/platform/update-text <face>` to force updating of `/text` facet with the GUI widget text content.
  • Loading branch information
dockimbel committed May 24, 2024
1 parent 22290c9 commit 9e7ac80
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
8 changes: 8 additions & 0 deletions modules/view/backends/platform.red
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ system/view/platform: context [
FACET_FLAGS_TRISTATE: 00020000h
FACET_FLAGS_SCROLLABLE: 00040000h
FACET_FLAGS_PASSWORD: 00080000h
FACET_FLAGS_NO_SYNC: 00100000h

FACET_FLAGS_POPUP: 01000000h
FACET_FLAGS_MODAL: 02000000h
Expand Down Expand Up @@ -288,6 +289,7 @@ system/view/platform: context [
tri-state: symbol/make "tri-state"
scrollable: symbol/make "scrollable"
password: symbol/make "password"
no-sync: symbol/make "no-sync"

_accelerated: symbol/make "accelerated"

Expand Down Expand Up @@ -610,6 +612,7 @@ system/view/platform: context [
sym = tri-state [flags: flags or FACET_FLAGS_TRISTATE]
sym = scrollable [flags: flags or FACET_FLAGS_SCROLLABLE]
sym = password [flags: flags or FACET_FLAGS_PASSWORD]
sym = no-sync [flags: flags or FACET_FLAGS_NO_SYNC]
true [fire [TO_ERROR(script invalid-arg) word]]
]
word: word + 1
Expand Down Expand Up @@ -683,6 +686,11 @@ system/view/platform: context [
gui/OS-update-facet owner word value action new index part
]

update-text: routine [face [object!]][
gui/get-text-alt face -1
SET_RETURN(none-value)
]

update-font: routine [font [object!] flags [integer!]][
gui/update-font font flags
SET_RETURN(none-value)
Expand Down
8 changes: 6 additions & 2 deletions modules/view/backends/windows/events.reds
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ make-event: func [
state [integer!]
key [integer!]
char [integer!]
bits [integer!]
saved [handle!]
t? [logic!]
][
Expand Down Expand Up @@ -583,7 +584,10 @@ make-event: func [
either tab-panel = symbol/resolve word/symbol [
gui-evt/flags: flags and FFFFh ;-- already one-based
][
unless zero? flags [get-text msg -1] ;-- get text if not done already
unless zero? flags [
bits: get-flags as red-block! get-facet msg FACE_OBJ_FLAGS
if bits and FACET_FLAGS_NO_SYNC = 0 [get-text msg -1] ;-- get text if not done already
]
]
]
EVT_LEFT_DOWN
Expand Down Expand Up @@ -769,7 +773,7 @@ process-command-event: func [
type: as red-word! get-facet current-msg FACE_OBJ_TYPE
if type/symbol = area [
extend-area-limit child 16
update-scrollbars child null
; update-scrollbars child null
]
]
]
Expand Down
38 changes: 38 additions & 0 deletions modules/view/backends/windows/gui.reds
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,44 @@ get-selected: func [
int/value: idx
]

get-text-alt: func [
face [red-object!]
idx [integer!]
/local
str [red-string!]
out [c-string!]
hWnd [handle!]
size [integer!]
][
hWnd: face-handle? face
if null? hWnd [exit]

size: as-integer either idx = -1 [
SendMessage hWnd WM_GETTEXTLENGTH idx 0
][
SendMessage hWnd CB_GETLBTEXTLEN idx 0
]
if size >= 0 [
str: as red-string! (object/get-values face) + FACE_OBJ_TEXT
if TYPE_OF(str) <> TYPE_STRING [
string/make-at as red-value! str size UCS-2
]
if size = 0 [
string/rs-reset str
exit
]
out: unicode/get-cache str size + 1 * 4 ;-- account for surrogate pairs and terminal NUL

either idx = -1 [
SendMessage hWnd WM_GETTEXT size + 1 as-integer out ;-- account for NUL
][
SendMessage hWnd CB_GETLBTEXT idx as-integer out
]
unicode/load-utf16 null size str yes
ownership/bind as red-value! str face _text
]
]

get-text: func [
msg [tagMSG]
idx [integer!]
Expand Down

0 comments on commit 9e7ac80

Please sign in to comment.