Ticket Hash: | 5d92222c26f88b9a59607302de55a83aa023e29d | |||
Title: | Change the sdltk root window from inside undroidwish | |||
Status: | Closed | Type: | Feature_Request | |
Severity: | Minor | Priority: | Immediate | |
Subsystem: | Resolution: | Fixed | ||
Last Modified: | 2019-05-16 14:16:13 | |||
Version Found In: | ||||
User Comments: | ||||
anonymous added on 2019-05-13 22:24:40:
Hi. I'm slowly building an androwish emulator, written in TCL, for testing tcl scripts on a desktop before deploying them to android devices. The emulator, which I call AWEMU, also creates borg and sdltk lookalikes, which provide some basic functionality similar to that found on an android device running AndroWish. The emulator is in pre-alpha state, but is already helping me test GUI functions. One of the requirements for this emulator is the ability to rotate the screen so that appearance and behavior of an application can be tested. With Xorg and Tk I accomplish this by using a small proc, [rotateToplevel], which can be found here . Tk toplevels are manipulated using [wm geometry ...] and window event bindings, but I haven't be able to do that to the root sdltk window using undroidwish. Can such resizing happen from a script running in undroidwish? It would be very helpful to have this ability, as this could help to reproduce the exact appearance and behavior of AndroWish on an Android with Undoidwish on a desktop PC, including the console and any toplevel windows created by the application, something which is difficult to do with X and Tk. Working around this adds complexity to the emulator. anonymous added on 2019-05-14 11:30:33: To help test the above, I added some more info regarding toplevel rotation here. chw added on 2019-05-14 17:13:00: Check-in [1fe1928844] now implements "sdltk size ?width? ?height?" in order to change the sdltk root window size provided -sdlresizable was given on the command line and -sdlfullscreen was not given. So far, I've tested on Linux with X11 and Wayland only, and there could be bad interactions with "sdltk root ..." and "sdltk viewport ...". anonymous added on 2019-05-14 20:36:01: I'll start trying some of my AWEMU stuff with it. Here are some issues I have encountered so far: 1. When changing sizes, the sdl window is not redrawn. I tried withdrawing and restoring the window, but it didn't help. 2. Events <Configure> and <<ViewportUpdate>> do not seem to be working. <Configure> didn't have a problem before. <<ViewportUpdate>> seems to be better suited for this purpose. [sdltk size W H] allows changing the aspect of the window to whatever is needed. The window can now flip from portrait to landscape mode. All seem to be ready for a convenience command, like [sdltk aspect ?0|1|portrait|landscape|toggle?], that would achieve the same result. If we also had X and Y for the NW corner of the sdl window and a way to set it on the Xorg screen, we could create the impression of a rotating window centered at X,Y of the Xorg root window, like I do with [rotateToplevel]. Tk does this in one go with [wm geometry . {width}x{height}+X+Y]. This WxH+X+Y notion seems to be well established for expressing window geometry. Could that [sdl size W H] be made identical to [wm geometry WxH=X+Y], i.e. [sdltk geometry ?WxH+X+Y?] ? That would provide all that is necessary for working with the top sdl window. It's not necessary though for emulating a device's changing aspect, which can already be achieved with [sdltk size ...]. Thank you. dzach anonymous added on 2019-05-14 21:00:56: I should note that the redraw problem seem to appear mostly when changing the size remotely, e.g. using tkconclient, and not always. I haven't figured out what exactly makes it happen. anonymous added on 2019-05-14 23:53:11: There seems to be a problem with testing when using my extended version of tkconclient, that has something to do with [update]. When not using it, events <Configure> and <<ViewportUpdate>> work for the main '.' window, but <<ViewportUpdate>> still does not work with toplevel windows other than '.'. chw added on 2019-05-15 05:27:41: Check-in [86cb80c164] improves "sdltk size ..." somewhat regarding expose/redraw. Now it needs thorough testing on other platforms. The geometry w.r.t. a corner is a nice to have feature, OTOH this quickly becomes PITA when multiple monitors are in use, thus I'll postpone this feature. anonymous added on 2019-05-15 09:13:16: Thank you chw, [sdltk size ...] is adequate for what I'm trying to accomplish. I checked again with the new build and the problem with the events persists. It seems <Configure> and <<ViewportUpdate>> events on different windows are masking each other, and they do not all appear to fire when resizing the sdl window. This is what I do: wm attribute . -fullscreen 1 toplevel .t wm attribute .t -fullscreen 1 pack [frame .f -width 50 -height 50 -background red] -side top -fill x bind . <Configure> {puts "config %W"} bind . <<ViewportUpdate>> {puts "viewport %W"} bind .t <Configure> {puts "config %W"} bind .t <<ViewportUpdate>> {puts "viewport %W"} When flip the size with [sdltk size ...], which resizes all ., .t toplevels and .f frame, I get only: config .f config .f If I change the horizontal size of the sdl window manually by dragging a vertical side, which resizes all existing windows, I get: config .t config .f config .t viewport .t config .f config .t config .f config .t viewport .t config .f config . viewport .t config .f viewport . But even then, these results are not consistent in their sequence, e.g. "config ." and "viewport ." are not as frequent and as regular as expected. Bindtags on undroidwish: % bindtags . . Test.tcl all %bindtags .f .f Frame . all % bindtags .t .t Toplevel all When testing the same (toplevel .t is an independent window in this case) with a regular wish, I get: config . config .f config . config . config .f config . config . config .f config . which is as expected. In this case there is no <<ViewportUpdate>> defined. Bindtags on wish: % bindtags . . Wish all % bindtags .f .f Frame . all chw added on 2019-05-15 20:29:15: I've tried this one ---snip--- proc log {w what args} { sdltk log info "$what $w $args" } wm attribute . -fullscreen 1 toplevel .t wm attribute .t -fullscreen 1 pack [button .b1 -text 800x600 -command {sdltk size 800 600}] pack [button .b2 -text 600x800 -command {sdltk size 600 800}] bind . <Configure> {log %W <Configure> w=%w h=%h} bind . <<ViewportUpdate>> {log %W <<ViewportUpdate>> x=%x y=%y w=%X h=%Y} bind .t <Configure> {log %W <Configure> w=%w h=%h} bind .t <<ViewportUpdate>> {log %W <<ViewportUpdate>> x=%x y=%y w=%X h=%Y} lower .t ---snip--- with ./undroidwish script.tcl -sdllog 1 -sdlresizable and observed nothing unusual. anonymous added on 2019-05-16 13:24:32: Then, my extended tkconclient having some kind of problem with [update] must be the cause, since I too get the expected results with your script above and other scripts executed locally, wen this tkconclient is not employed. Thanks again for this new sdltk command, it really makes things a lot simpler when testing different top window configurations. dzach chw added on 2019-05-16 14:16:13: Good to know. So I close this ticket now and soon add documentation for the new size minor command in the wiki page for the sdltk command. |