Historical system_X, Revision 1

 
include std/dll.e 
include std/console.e 
atom libxcb 
libxcb = open_dll("libxcb.so") -- If on a 64bit machine you must install the 32bit library. 
if libxcb = 0 then 
   puts(1, "Could not open libxcb.so") -- If libxcb = 0 then open_dll needs the path and/or 32bit libxcb.so installed. 
end if 
 
constant xcb_connect_ = define_c_func(libxcb, "xcb_connect", {C_POINTER, C_POINTER}, C_POINTER),  
xcb_get_setup_ = define_c_func(libxcb, "xcb_get_setup", {C_POINTER}, C_POINTER),  
-- C wrapper code  
--xcb_setup_roots_iterator_ = define_c_func(open_dll("libxcbeuwrapper.so"), "eu_xcb_setup_roots_iterator", {C_POINTER}, C_POINTER),  
-- no C wrapper code  
xcb_setup_roots_iterator_ = define_c_func(libxcb, "xcb_setup_roots_iterator", {C_POINTER}, C_POINTER),  
xcb_generate_id_ = define_c_func(libxcb, "xcb_generate_id", {C_POINTER}, C_UINT),  
xcb_create_window_ = define_c_proc(libxcb, "xcb_create_window", {C_POINTER, C_INT, C_UINT, C_UINT, C_INT, C_INT, C_INT, C_INT, C_INT, C_INT, C_UINT, C_INT, C_POINTER}),  
xcb_map_window_ = define_c_proc(libxcb, "xcb_map_window", {C_POINTER,C_UINT}),  
xcb_flush_ = define_c_proc(libxcb, "xcb_flush", {C_POINTER}),  
xcb_disconnect_ = define_c_proc(libxcb, "xcb_disconnect", {C_POINTER}),  
XCB_COPY_FROM_PARENT = 0,  
XCB_WINDOW_CLASS_INPUT_OUTPUT = 1  
  
public function xcb_connect(atom a1, atom a2)  
	return c_func(xcb_connect_, {a1, a2}) -- Changed xcb_connect to xcb_connect_ 
end function  
  
public function xcb_get_setup(atom connection)  
	return c_func(xcb_get_setup_, {connection})  
end function   
 
--Added public function xcb_setup_roots_iterator to iamlost's code. 
public function xcb_setup_roots_iterator(atom connection) 
	return c_func(xcb_setup_roots_iterator_, {connection}) 
end function 
  
public function xcb_generate_id(atom connection)  
	return c_func(xcb_generate_id_, {connection})  
end function  
  
public procedure xcb_create_window(atom connection, integer copy, atom window,  
	atom parentwindow, integer x, integer y, integer w, integer h,  
	integer border, integer class, atom visual, integer flags, atom notused)  
  
	c_proc(xcb_create_window_, {connection, copy, window, parentwindow,  
		x, y, w, h, border, class, visual, flags, notused})  
end procedure  
  
public procedure xcb_map_window(atom connection, atom window)  
	c_proc(xcb_map_window_, {connection, window}) -- Added a ) to the end of this line. 
end procedure  
  
public procedure xcb_flush(atom connection)  
	c_proc(xcb_flush_, {connection}) -- Added a ) to the end of this line.  
end procedure  
  
public procedure xcb_disconnect(atom connection)  
	c_proc(xcb_disconnect_, {connection}) -- Added a ) to the end of this line.  
end procedure  
  
procedure main()  
        -- Open the connection to the X server  
        atom connection = xcb_connect (0, 0)  
  
  
        -- Get the first screen  
        atom setup  = xcb_get_setup (connection)  
  
	-- this returns a raw struct, so there is no way to convert this to  
	-- euphoria without a C wrapper  
        --xcb_screen_iterator_t   iter   = xcb_setup_roots_iterator (setup);  
  
	-- C wrapper code  
        -- atom iter = xcb_setup_roots_iterator (setup)  
        -- atom screen = peek4u(iter, 0) -- data  
  
	-- no C wrapper code - take advantage of the fact that the only  
	-- element of the struct we really need is the first one  
        atom screen = xcb_setup_roots_iterator (setup) 
  
  
        -- Create the window  
        atom window = xcb_generate_id (connection)  
        xcb_create_window (connection,                    -- Connection           
                           XCB_COPY_FROM_PARENT,          -- depth(same as root)  
                           window,                        -- window Id            
                           peek4u({screen, 0}), -- root     -- parent window -- Added { }       
                           0, 0,                          -- x, y                 
                           150, 150,                      -- width, height        
                           10,                            -- border_width         
                           XCB_WINDOW_CLASS_INPUT_OUTPUT, -- class                
                           peek4u({screen, 8}),--root_visual-- visual              -- Added { } 
                           0, 0 )                     -- masks, not used yet  
  
  
        -- Map the window on the screen  
        xcb_map_window (connection, window)  
  
  
        -- Make sure commands are sent before we pause so that the window gets shown  
        xcb_flush (connection)  
  
  
        wait_key() -- pause ()    -- hold client until Ctrl-C -- 
  
        xcb_disconnect (connection)  
  
end procedure  
  
main()  
 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu