Differenze tra le versioni di "Ottenere informazioni relative allo schermo mediante le funzioni del API di CBX"
Da Gambas-it.org - Wikipedia.
Riga 32: | Riga 32: | ||
<FONT Color=gray>' ''xcb_connection_t * xcb_connect (const char *display, int *screen)'' | <FONT Color=gray>' ''xcb_connection_t * xcb_connect (const char *display, int *screen)'' | ||
' ''Connects to the X server specified by display.''</font> | ' ''Connects to the X server specified by display.''</font> | ||
− | Private Extern xcb_connect(display As String, | + | Private Extern xcb_connect(display As String, screen As Pointer) As Pointer |
<FONT Color=gray>' ''const xcb_setup_t * xcb_get_setup (xcb_connection_t *c)'' | <FONT Color=gray>' ''const xcb_setup_t * xcb_get_setup (xcb_connection_t *c)'' | ||
Riga 50: | Riga 50: | ||
Dim disp, xcb_setup As Pointer | Dim disp, xcb_setup As Pointer | ||
− | Dim | + | Dim scr As Xcb_screen_t |
<FONT Color=gray>' ''Apre una connessione con il server X:''</font> | <FONT Color=gray>' ''Apre una connessione con il server X:''</font> | ||
Riga 58: | Riga 58: | ||
xcb_setup = xcb_get_setup(disp) | xcb_setup = xcb_get_setup(disp) | ||
− | + | scr = xcb_setup_roots_iterator(xcb_setup) | |
<FONT Color=gray>' ''Mostra in console alcune informazioni sullo schermo utilizzato:''</font> | <FONT Color=gray>' ''Mostra in console alcune informazioni sullo schermo utilizzato:''</font> | ||
− | With | + | With scr |
Print "Dimensioni dello schermo:\n" | Print "Dimensioni dello schermo:\n" | ||
Print "Larghezza in pixel: "; .width_in_pixels | Print "Larghezza in pixel: "; .width_in_pixels |
Versione delle 17:20, 3 feb 2017
Il protocollo XCB (X C-language Binding) è stato realizzato con lo scopo di sostituire Xlib presentando rispetto a quest'ultimo ad esempio dimensioni ridotte, un accesso diretto al protocollo, migliorando il threading e la estensibilità.
E' possibile mediante alcune risorse del API di CBX ottenere informazioni generali relative allo schermo in uso.
Per poter fruire delle risorse di XCB in Gambas, bisognerà utilizzare la libreria attualmente alla versione: "libxcb.so.1.1.0"
Mostriamo un semplice esempio:
Public Struct xcb_screen_t root As Integer default_colormap As Integer white_pixel As Integer black_pixel As Integer current_input_masks As Integer width_in_pixels As Short height_in_pixels As Short width_in_millimeters As Short height_in_millimeters As Short min_installed_maps As Short max_installed_maps As Short root_visual As Integer backing_stores As Byte save_unders As Byte root_depth As Byte allowed_depths_len As Byte End Struct Library "libxcb:1.1.0" ' xcb_connection_t * xcb_connect (const char *display, int *screen) ' Connects to the X server specified by display. Private Extern xcb_connect(display As String, screen As Pointer) As Pointer ' const xcb_setup_t * xcb_get_setup (xcb_connection_t *c) ' Accessor for the data returned by the server when the xcb_connection_t was initialized. Private Extern xcb_get_setup(c As Pointer) As Pointer ' xcb_screen_iterator_t xcb_setup_roots_iterator (const xcb_setup_t *R) ' Get the next element of the iterator. Private Extern xcb_setup_roots_iterator(R As Pointer) As Pointer ' void xcb_disconnect (xcb_connection *c) ' Closes the file descriptor and frees all memory associated with the connection. Private Extern xcb_disconnect(c As Pointer) Public Sub Main() Dim disp, xcb_setup As Pointer Dim scr As Xcb_screen_t ' Apre una connessione con il server X: disp = xcb_connect(Null, 0) ' Ottiene il primo schermo: xcb_setup = xcb_get_setup(disp) scr = xcb_setup_roots_iterator(xcb_setup) ' Mostra in console alcune informazioni sullo schermo utilizzato: With scr Print "Dimensioni dello schermo:\n" Print "Larghezza in pixel: "; .width_in_pixels Print "Altezza in pixel: "; .height_in_pixels Print "Larghezza in millimetri: "; .width_in_millimeters Print "Altezza in millimetri: "; .height_in_millimeters Print "Mappa dei colori predefinita: "; .default_colormap End With ' Va in chiusura: xcb_disconnect(disp) End