19 posts
Posted 26 June 2016 - 12:37 PM
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?
7083 posts
Location
Tasmania (AU)
Posted 26 June 2016 - 02: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.
19 posts
Posted 26 June 2016 - 02:53 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.
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.
7083 posts
Location
Tasmania (AU)
Posted 26 June 2016 - 03: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.
19 posts
Posted 26 June 2016 - 04:05 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.
I could but how do i also redraw the other windows that are opened
8543 posts
Posted 26 June 2016 - 05: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.
19 posts
Posted 26 June 2016 - 05:53 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.
if i'm not mistaking yielding and such is from the coroutine API but i'm using parallel
218 posts
Location
tmpim
Posted 26 June 2016 - 09:37 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.
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.
7083 posts
Location
Tasmania (AU)
Posted 27 June 2016 - 01: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.
19 posts
Posted 27 June 2016 - 09:23 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.
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 on 27 June 2016 - 07:24 AM
7083 posts
Location
Tasmania (AU)
Posted 27 June 2016 - 09: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.
19 posts
Posted 27 June 2016 - 11:00 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.
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.
7083 posts
Location
Tasmania (AU)
Posted 27 June 2016 - 11: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.
19 posts
Posted 27 June 2016 - 12:52 PM
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??
7083 posts
Location
Tasmania (AU)
Posted 28 June 2016 - 02:06 AM