Well, you have your OS running and now you can thing about adding things to make it interesting...
...for example a windows interface...could smbdy tell me where to find info about how to manage the windows, I'm talking about algorithms and stuff like that...
thanks.
my own windows...
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:my own windows...
most windowing system rely on a hierarchical list of windows objects that will delegate a mouse/repaint event to the needed objects.
For instance, consider window.mouseClick(x,y).
You first have your Root Window (desktop) which holds every application windows sorted by "depth".
RootWindow.mouseClick(x,y) {
foreach win in (list_of_windows) {
if (win.x>x>win.x+win.width && win.y>y>win.y+win.height) {
win.mouseClick(x-win.x, y-win.y)
return;
}
}
In its turn, the application window that receives the click is also a container that has a border, a title-bar and a content and it will perform the same kind of algorithm to find the one of its child that must receive the event. And the process goes on recursively until you hit a "base" component like a button, an icon, whatever, which will have its own handler for mouseClick and that will do something more interresting like modifying its internal state.
Button.mouseClick(x,y) {
if (mouse.state==down) state=clicked;
else { state=normal; action.callback();
Root.request_repaint(absolute_x(), absolute_y(), width, height);
}
Now, when the call chain will have return to Root window, this one will notice the "request_repaint" event and will start calling back the chain for display refresh. The reason we don't repaint immediately is that the repaint request will be filtered at each level to handle overlapping areas, etc.
We could for instance have a 'repaint_needed' flag at each object and have the "containers" sweep their list looking for objects that intersect the repaint request and call repaint() method on them using the proper graphicContext.
Button.repaint(graphicContext gc) {
if (state.down) gc.fill(grey);
else gc.fill(lightgrey);
gc.puttext("Hello, world", CENTER_TEXT|CLIP_TEXT);
}
Well, there is surely a better algorithm than those list for the containers (think at grids, space partitionning trees, etc.) but if you manage the full click & redraw chain with linked lists, you can be proud already :-p
For instance, consider window.mouseClick(x,y).
You first have your Root Window (desktop) which holds every application windows sorted by "depth".
RootWindow.mouseClick(x,y) {
foreach win in (list_of_windows) {
if (win.x>x>win.x+win.width && win.y>y>win.y+win.height) {
win.mouseClick(x-win.x, y-win.y)
return;
}
}
In its turn, the application window that receives the click is also a container that has a border, a title-bar and a content and it will perform the same kind of algorithm to find the one of its child that must receive the event. And the process goes on recursively until you hit a "base" component like a button, an icon, whatever, which will have its own handler for mouseClick and that will do something more interresting like modifying its internal state.
Button.mouseClick(x,y) {
if (mouse.state==down) state=clicked;
else { state=normal; action.callback();
Root.request_repaint(absolute_x(), absolute_y(), width, height);
}
Now, when the call chain will have return to Root window, this one will notice the "request_repaint" event and will start calling back the chain for display refresh. The reason we don't repaint immediately is that the repaint request will be filtered at each level to handle overlapping areas, etc.
We could for instance have a 'repaint_needed' flag at each object and have the "containers" sweep their list looking for objects that intersect the repaint request and call repaint() method on them using the proper graphicContext.
Button.repaint(graphicContext gc) {
if (state.down) gc.fill(grey);
else gc.fill(lightgrey);
gc.puttext("Hello, world", CENTER_TEXT|CLIP_TEXT);
}
Well, there is surely a better algorithm than those list for the containers (think at grids, space partitionning trees, etc.) but if you manage the full click & redraw chain with linked lists, you can be proud already :-p