WindowResize fills the whole window instead of just the new portion

Posted by Fiendish on Sun 06 May 2012 10:21 PM — 6 posts, 20,884 views.

USA Global Moderator #0
It's funny but this report is exactly the opposite of http://www.gammon.com.au/forum/bbshowpost.php?id=10517

Documentation for WindowResize says
Quote:
If the new size is larger than the existing size the BackgroundColour is used to fill any newly exposed area

But I am experiencing that backgroundcolour is filling the entire window and not just the newly exposed area.

A test plugin is available here that should demonstrate the problem:

http://pastebin.com/raw.php?i=NPhDUztt

Notice the one line using WindowResize that uses a blue background color. And when resizing the displayed window, indeed the whole thing turns blue instead of just the new part. It's the only place blue gets used.

I captured a video here:
http://www.youtube.com/watch?v=ZcWFDI7IgU0
Amended on Thu 10 May 2012 04:20 AM by Fiendish
Australia Forum Administrator #1

win = "test_" .. GetPluginID ()  -- get a unique name, ensure not empty if outside plugin
WindowCreate (win, 0, 0, 200, 200, miniwin.pos_center_all, 0, ColourNameToRGB("white"))  -- create window
WindowShow (win,  true)  -- show it 

-- Grid
  for i = 1, math.max (WindowInfo (win, 3), WindowInfo (win, 4)) / 20 do
    WindowLine (win, i * 20, 0, i * 20, WindowInfo (win, 4), 0xC0C0C0, miniwin.pen_solid, 1)
    WindowLine (win, 0, i * 20, WindowInfo (win, 3), i * 20, 0xC0C0C0, miniwin.pen_solid, 1)
  end -- for

-- resize it

WindowResize(win, 300, 300, 0xFF0000) 


After running that:



It resized correctly.
USA Global Moderator #2
Yeah, same for me. But my posted scenario still holds. It probably has to do with calling resize during a mousedrag handler event.
USA Global Moderator #3
I have updated the plugin url in the original post to be a stripped down test so that it's easier to verify.

My next test will be in Windows 7 as soon as I have a fresh install of it, since currently I am using Wine in Fedora. But other people on Aardwolf already tell me that they also see the whole miniwindow turning blue, so I doubt I'll see other than what is demonstrated in the video.


[EDIT]Actually, I can just put the code here so we don't have to rely on pastebin.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="Resize_Test"
   author="Fiendish"
   id="7d0a741a84e89b3b7fe9a09a"
   language="Lua"
   purpose="Resize Bug Tester"
   requires="4.73"
   save_state="y"
>
</plugin>
<script>
<![CDATA[

require "movewindow"

default_x = 468
default_y = 236
height = 215
width = 269
lastRefresh = 0

function ResizeMoveCallback()
   width = math.max(math.min(WindowInfo(win, 17)+offsetx, GetInfo(281)-windowinfo.window_left), 50)
   height = math.max(math.min(WindowInfo(win, 18)+offsety, GetInfo(280)-windowinfo.window_top), 50)

   if (utils.timer() - lastRefresh > 0.1) then -- don't choke on very slow machines

      -- !!!THE BLUE DISPLAY BUG HAPPENS HERE BECAUSE WINDOWRESIZE IS CALLED INSIDE A DRAG HANDLER!!!
      WindowResize(win, width, height, 0xFF0000)
      WindowMoveHotspot(win, "resize", width-10, height-10, width, height)
      Redraw()

      lastRefresh = utils.timer()
   end
end

function ResizeReleaseCallback()
    SetUpHotspotsAndDraw()
end

function SetUpHotspotsAndDraw()
   WindowCreate (win, windowinfo.window_left, windowinfo.window_top, width, height, windowinfo.window_mode, windowinfo.window_flags, 0x000000)
   movewindow.add_drag_handler (win, 0, 0, 0, 0)

   -- Add handler for resizing
   WindowAddHotspot(win, "resize", width-10, height-10, width, height, "MouseOver", "", "MouseDown", "", "", "", 6, 0)
   WindowDragHandler(win, "resize", "ResizeMoveCallback", "ResizeReleaseCallback", 0)
      WindowShow (win, true)

   -- draw the resize widget bottom right corner
   WindowLine(win, width-3, height-1, width-1, height-3, 0xffffff, 0, 1)
   WindowLine(win, width-5, height-1, width-1, height-5, 0x696969, 0, 2)
   WindowLine(win, width-6, height-1, width-1, height-6, 0xffffff, 0, 1)
   WindowLine(win, width-8, height-1, width-1, height-8, 0x696969, 0, 2)
   WindowLine(win, width-9, height-1, width-1, height-9, 0xffffff, 0, 1)
   WindowLine(win, width-11, height-1, width-1, height-11, 0x696969, 0, 2)
   WindowLine(win, width-12, height-1, width-1, height-12, 0xffffff, 0, 1)
   WindowLine(win, width-14, height-1, width-1, height-14, 0x696969, 0, 1)

   -- draw edge frame
   WindowRectOp (win, 1, 0, 0, 0, 0, 0xdddddd, 15)

   Redraw()
end

function MouseDown(flags, hotspot_id)
   if (hotspot_id == "resize") then
      offsetx = width-WindowInfo(win, 17)
      offsety = height-WindowInfo(win, 18)
   end
end

function OnPluginClose ()
   WindowDelete(win)
end

function OnPluginInstall()
   win = GetPluginID()
   WindowCreate (win, default_x, default_y, 200, 200, 0, miniwin.create_absolute_location, 0x000000)

   --- install the window movement handler, get back the window position.
   windowinfo = movewindow.install (win, miniwin.pos_center, miniwin.create_absolute_location, false, nil,nil,{x=default_x, y=default_y})
   
   -- Draw the initial group window
   SetUpHotspotsAndDraw()
end

]]>

</script>
</muclient>
Amended on Thu 20 Dec 2012 03:57 AM by Fiendish
Australia Forum Administrator #4
OK TY I'll look into it.
Australia Forum Administrator #5
I can reproduce it, but I can't see why.

I tried juggling the order in which the function did things, to no avail. The mouse is captured with SetCapture, which may or may not be the reason for this. I tried doing a ReleaseCapture but that had no effect.