Jump to content




Window Updater


14 replies to this topic

#1 laica10

  • Members
  • 19 posts

Posted 26 June 2016 - 11:37 AM

Currently working on a multitasking project but i'm experiencing a couple of problems here
my OS api handles the taskbar and desktop update, every 0.05 secs this updates the taskbar and desktop nicely, this api also runs the programs started from the taskbar menu and then it all get's transfered to the program it selves this program uses an another api i called it 'frame' it is used to create the basic frame and also handles the exit event to it closes. But the problem is when the desktop and taskbar redraws (desk.redraw() , task.redraw() these are also windows but not using my 'frame' api) , you guessed it , it redraws the desktop and taskbar but the current window disappears.
Can anyone help me with this?

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 26 June 2016 - 01:42 PM

Is there any particular need to redraw the taskbar and desktop all the time? Why not wait until they specifically change in some way?

If you really need to redraw them at any point, then simply redraw the current window over the top of them when you're done.

#3 laica10

  • Members
  • 19 posts

Posted 26 June 2016 - 01:53 PM

View PostBomb Bloke, on 26 June 2016 - 01:42 PM, said:

Is there any particular need to redraw the taskbar and desktop all the time? Why not wait until they specifically change in some way?

If you really need to redraw them at any point, then simply redraw the current window over the top of them when you're done.
It is needed because you can drag these windows all over your screen so if there's no update for the desktop environment it would be messed up.

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 26 June 2016 - 02:14 PM

So redraw the desktop environment when the windows are dragged around the screen. There's not much point in doing it when that's not happening.

#5 laica10

  • Members
  • 19 posts

Posted 26 June 2016 - 03:05 PM

View PostBomb Bloke, on 26 June 2016 - 02:14 PM, said:

So redraw the desktop environment when the windows are dragged around the screen. There's not much point in doing it when that's not happening.

I could but how do i also redraw the other windows that are opened

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 26 June 2016 - 04:26 PM

Window contents can only change after the program that owns the window is resumed with an event, so redraw after the program has yielded. Have you taken a peek at LyqydOS's guts to see how it works? It may be very helpful for what you're trying to do.

#7 laica10

  • Members
  • 19 posts

Posted 26 June 2016 - 04:53 PM

View PostLyqyd, on 26 June 2016 - 04:26 PM, said:

Window contents can only change after the program that owns the window is resumed with an event, so redraw after the program has yielded. Have you taken a peek at LyqydOS's guts to see how it works? It may be very helpful for what you're trying to do.

if i'm not mistaking yielding and such is from the coroutine API but i'm using parallel

#8 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 26 June 2016 - 08:37 PM

View Postlaica10, on 26 June 2016 - 04:53 PM, said:

View PostLyqyd, on 26 June 2016 - 04:26 PM, said:

Window contents can only change after the program that owns the window is resumed with an event, so redraw after the program has yielded. Have you taken a peek at LyqydOS's guts to see how it works? It may be very helpful for what you're trying to do.

if i'm not mistaking yielding and such is from the coroutine API but i'm using parallel

Parallel is a wrapper for coroutine, it simply makes it easier to use coroutines instead of having to manage all of the thread's and their states by yourself. Yielding can trigger from a plethora of things such as os.pullEvent(), coroutine.yield(), sleep(), and many other things, however it all boils doing to coroutine.yield(). All of these functions reference coroutine.yield at the end of the day.

#9 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 June 2016 - 12:55 AM

Truth be told, all ComputerCraft scripts are run within coroutines. Each system in the world is really just an individual coroutine running within the one single Lua VM, which handles all the computers (and turtles) in the one Minecraft server.

To elaborate on what Incinirate was saying, os.pullEvent() is a wrapper for coroutine.yield(). When you go to pull an event, your computer's coroutine yields, and ComputerCraft later resumes it again when a relevant event occurs.

Any function that delays, such as sleep(), is simply calling os.pullEvent() for you and waiting for a certain event, such as "timer". That is to say, if you call sleep(), rednet.receive(), turtle.forward(), anything that has a "wait" associated with it, then you are by extension making your coroutine yield.

#10 laica10

  • Members
  • 19 posts

Posted 27 June 2016 - 08:23 AM

View PostBomb Bloke, on 27 June 2016 - 12:55 AM, said:

Truth be told, all ComputerCraft scripts are run within coroutines. Each system in the world is really just an individual coroutine running within the one single Lua VM, which handles all the computers (and turtles) in the one Minecraft server.

To elaborate on what Incinirate was saying, os.pullEvent() is a wrapper for coroutine.yield(). When you go to pull an event, your computer's coroutine yields, and ComputerCraft later resumes it again when a relevant event occurs.

Any function that delays, such as sleep(), is simply calling os.pullEvent() for you and waiting for a certain event, such as "timer". That is to say, if you call sleep(), rednet.receive(), turtle.forward(), anything that has a "wait" associated with it, then you are by extension making your coroutine yield.

That's great but aren't we a little off topic here ?
My original question was how to update (redraw) a couple of windows and still keeping other windows drawn, because if you'd redraw the desktop environment all other windows would dissapear.

Edited by laica10, 27 June 2016 - 08:24 AM.


#11 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 June 2016 - 08:54 AM

And as I told you: if you feel you "must" redraw your full desktop window and so on, then you'll need to redraw the top-focused windows on top afterwards. You're better off not redrawing anything unless you have to.

If you don't like either of those answers, then there's always other options (though they only get worse); the next would be to create your own window API, one which allows partial redraws.

#12 laica10

  • Members
  • 19 posts

Posted 27 June 2016 - 10:00 AM

View PostBomb Bloke, on 27 June 2016 - 08:54 AM, said:

And as I told you: if you feel you "must" redraw your full desktop window and so on, then you'll need to redraw the top-focused windows on top afterwards. You're better off not redrawing anything unless you have to.

If you don't like either of those answers, then there's always other options (though they only get worse); the next would be to create your own window API, one which allows partial redraws.

How would you guys do it if tou had 2 windows in desktop environment (taskbar & desktop) and there are multiple windows dragable. How would you guys do this because if you move a window , the background has to get redrawn right?? otherwise the window will have it's mark there.

#13 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 June 2016 - 10:51 AM

Again, the simple method is to simply redraw the draggable window immediately after redrawing the desktop.

You can even eliminate flicker by drawing the desktop and application windows through a single "master" window (that is to say, make that one the parent of each of the others); make it invisible while you redraw, then set it back to visible when the buffer contains what you're wanting.

Here's the thread for LyqydOS, by the way. As Lyqyd pointed out, you might pick up some tricks by reading through its source.

#14 laica10

  • Members
  • 19 posts

Posted 27 June 2016 - 11:52 AM

So, what do you mean by master window, my 'frame' API ??, but how do i tell my windows to go invisible, there isn't any custom event or something like that right??

#15 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 28 June 2016 - 01:06 AM

http://www.computerc...ndow.setVisible





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users