Saturday, May 22, 2010

Nano-X window system

Recently I have worked in Linux environment with a great NanoX project
It is about 300k size. NanoX provide solution for timer support, windows management, user input.

To use Nano-X you need only gcc c/c++ compiler that it is included in many(most) Linux systems


- message based system
- small size
- simple API
- add/replace any keyboard/mouse/screen driver
- font support. It is possible to add Unicode TrueType fonts

Lets discuss how to use it:

To create nano-X window you need :

#include  "nano-x.h"
int main(int argv, char[][] argv)
   GR_WINDOW_ID wnd = 
     GrNewWindow( GR_ROOT_WINDOW_ID
                  , 0,0,100,100
                  , WINDOW_NO_BORDER
                  , FOREGROUND_COLOR
                  , BLACKGROUND_COLOR); // create a window

   gc = GrNewGC(); // create a graphic context

   //select events. you are able to select 
   //only that events that you need. this will boost your application  
   GrSelectEvents( wnd, GR_EVENT_MASK_ALL); 

   GrMapWindow( wnd ); // show window

   // you may create as many windows as you wish
   // there is only one message queue for all Nano-X windows

   GR_EVENT anEvent;
   while (true)
     if (anEvent.type == GR_EVENT_TYPE_NONE )
     if (HandleEvent(anEvent) == NEED_TO_EXIT) break; 
   // close all handles and exit
   GrUnmapWindow(wnd); // hide window
   GrDestroyGC( gc ); //
   GrDestroyWindow( wnd ); 


Now you might understand nano-x weak side: 

  • Messages might not be synchronized. ( for example when you kill window but some messages that was in queue might come)
  • Timer messages might not work proper under some circumstances  (for example when you create a timer event, then change time in your system) 
  • Pure focus management (for example you can use GrSetFocus() then destroy window and then GrGetFocus() doesn't return you focus to a parent window like it is in MS Window OS,
  • Font support is available but you have to dig into sources to add it. 

1 comment:

Anonymous said...

in this moment i'had to develop a software for handheld computers with nano-X.

I'have a lot of problems with key evnets, can you help me?