Home

Add

Edit

Without Linenumbers

Code in Textfield

test.bas

  1. #INCLUDE Once "crt.bi"
    
  2. 
    
  3. 
    
  4. '##############################################################################################################################################################
    
  5. #LIBPATH "/usr/X11/lib"
    
  6. #INCLIB "Xext"
    
  7. #INCLUDE Once "X11.bi"
    
  8. 
    
  9. 
    
  10. 
    
  11. '##############################################################################################################################################################
    
  12. Type ShmSeg As Uinteger
    
  13. Type XShmSegmentInfo
    
  14.     shmseg      As ShmSeg
    
  15.     shmid       As Integer
    
  16.     shmaddr     As Byte Ptr
    
  17.     readOnly    As Integer
    
  18. End Type
    
  19. 
    
  20. 
    
  21. 
    
  22. '##############################################################################################################################################################
    
  23. Type ipc_perm
    
  24.     __key       As __key_t
    
  25.     uid         As __uid_t
    
  26.     gid         As __gid_t
    
  27.     cuid        As __uid_t
    
  28.     cgid        As __gid_t
    
  29.     mode        As Ushort
    
  30.     __pad1      As Ushort
    
  31.     __seq       As Ushort
    
  32.     __pad2      As Ushort
    
  33.     __unused1   As Uinteger
    
  34.     __unused2   As Uinteger
    
  35. End Type
    
  36. 
    
  37. 
    
  38. 
    
  39. '##############################################################################################################################################################
    
  40. Type shmatt_t   As Uinteger
    
  41. 
    
  42. 
    
  43. 
    
  44. '##############################################################################################################################################################
    
  45. Type shmid_ds
    
  46.     shm_perm    As ipc_perm
    
  47.     shm_segsz   As size_t
    
  48.     shm_atime   As __time_t
    
  49.     __unused1   As Uinteger
    
  50.     shm_dtime   As __time_t
    
  51.     __unused2   As Uinteger
    
  52.     shm_ctime   As __time_t
    
  53.     __unused3   As Uinteger
    
  54.     shm_cpid    As __pid_t
    
  55.     shm_lpid    As __pid_t
    
  56.     shm_nattch  As shmatt_t
    
  57.     __unused4   As Uinteger
    
  58.     __unused5   As Uinteger
    
  59. End Type
    
  60. 
    
  61. 
    
  62. 
    
  63. '##############################################################################################################################################################
    
  64. #DEFINE IPC_RMID            &H0
    
  65. #DEFINE IPC_SET             &H1
    
  66. #DEFINE IPC_STAT            &H2
    
  67. #DEFINE SHM_SIZE            &H6
    
  68. 
    
  69. #DEFINE IPC_CREAT           &H200
    
  70. #DEFINE IPC_EXCL            &H400
    
  71. #DEFINE SHM_TS_NP           &H10000
    
  72. #DEFINE SHM_RESIZE_NP       &H40000
    
  73. #DEFINE SHM_MAP_FIXED_NP    &H100000
    
  74. 
    
  75. 
    
  76. 
    
  77. '##############################################################################################################################################################
    
  78. Extern "c"
    
  79.     Declare Function shmctl(Byval __shmid As Integer, Byval __cmd As Integer, Byval __buf As shmid_ds Ptr) As Integer
    
  80.     Declare Function shmget(Byval __key As Integer, Byval __size As Integer, Byval __shmflg As Integer) As Integer
    
  81.     Declare Function shmat(Byval __shmid As Integer, Byval __shmaddr As Byte Ptr, Byval __shmflg As Integer) As Any Ptr
    
  82.     Declare Function shmdt(Byval __shmaddr As Byte Ptr) As Integer
    
  83. End Extern
    
  84. 
    
  85. Declare Function XShmQueryExtension Cdecl Alias "XShmQueryExtension"(Byval lpTDisplay As Display Ptr) As XBOOLEAN
    
  86. Declare Function XShmQueryVersion Cdecl Alias "XShmQueryVersion"(Byval lpTDisplay As Display Ptr, Byval major As Integer Ptr, Byval minor As Integer Ptr, Byval pixmaps As XBOOLEAN Ptr) As Integer
    
  87. Declare Function XShmCreateImage Cdecl Alias "XShmCreateImage"(Byval lpTDisplay As Display Ptr, Byval visual As VISUAL Ptr, Byval depth As Integer, Byval Format As Integer, Byval offset As Integer, Byval shminfo As XShmSegmentInfo Ptr, Byval w As Uinteger, Byval height As Uinteger) As XImage Ptr
    
  88. Declare Function XShmAttach Cdecl Alias "XShmAttach"(Byval lpTDisplay As Display Ptr, Byval shminfo As XShmSegmentInfo Ptr) As Integer
    
  89. Declare Function XShmDetach Cdecl Alias "XShmDetach"(Byval lpTDisplay As Display Ptr, Byval shminfo As XShmSegmentInfo Ptr) As Integer
    
  90. Declare Function XShmPutImage Cdecl Alias "XShmPutImage"(Byval lpTDisplay As Display Ptr, Byval d As DRAWABLE, Byval gc As GCONTEXT, Byval image As XIMAGE Ptr, Byval src_x As Integer, Byval src_y As Integer, Byval des_x As Integer, Byval des_y As Integer, Byval Width As Uinteger, Byval height As Uinteger, Byval height As XBOOLEAN) As Integer
    
  91. 
    
  92. 
    
  93. 
    
  94. 
    
  95. Dim TDisplay As Display Ptr
    
  96. Dim Tscreen_num As Integer
    
  97. Dim TShmInfo As XShmSegmentInfo
    
  98. Dim TShmDs As shmid_ds
    
  99. Dim TShmDsC As shmid_ds
    
  100. 
    
  101. 
    
  102. TDisplay = XOpenDisplay()
    
  103. Tscreen_num = DefaultScreen(TDisplay)
    
  104. 
    
  105. Dim tattr As XSETWINDOWATTRIBUTES
    
  106. tattr.background_pixel = WhitePixel(TDisplay, Tscreen_num)
    
  107. Dim win As WindowID = XCreateWindow(TDisplay, RootWindow(TDisplay,Tscreen_num), 0, 0, 200, 300, 1, DefaultDepth(TDisplay, Tscreen_num), InputOutput, DefaultVisual(TDisplay,Tscreen_num), CWBackPixel, tattr)
    
  108. XSelectInput(TDisplay, win, ClientMessage Or StructureNotifyMask Or ExposuRemask Or KeyPressMask) ' or ResizeRedirectMask
    
  109. XFlush(TDisplay)
    
  110. 
    
  111. TShmInfo.shmid = shmget(0, 200 * 300 * 4, IPC_CREAT Or &O777)
    
  112. TShmInfo.shmaddr = shmat(TShmInfo.shmid, 0, 0)
    
  113. XShmAttach(TDisplay, @TShmInfo)
    
  114. 
    
  115. XMapWindow(TDisplay,win)
    
  116. Dim blnExit As Integer
    
  117. Dim report As XEVENT
    
  118. While blnExit = 0
    
  119.     XNextEvent(TDisplay, report)
    
  120.     Select Case (report.eventtype)
    
  121.         Case KeyPress:          Print "[" & Str(Fix(Timer())) & "] KeyPress"
    
  122.             blnExit = -1
    
  123.         Case KeyRelease:        Print "[" & Str(Fix(Timer())) & "] KeyRelease"
    
  124.         Case ButtonPress:       Print "[" & Str(Fix(Timer())) & "] ButtonPress"
    
  125.         Case ButtonRelease:     Print "[" & Str(Fix(Timer())) & "] Button Release"
    
  126.         Case MotionNotify:      Print "[" & Str(Fix(Timer())) & "] MotionNotify"
    
  127.         Case EnterNotify:       Print "[" & Str(Fix(Timer())) & "] EnterNotify"
    
  128.         Case LeaveNotify:       Print "[" & Str(Fix(Timer())) & "] LeaveNotify"
    
  129.         Case FocusIn:           Print "[" & Str(Fix(Timer())) & "] FocusIn"
    
  130.         Case FocusOut:          Print "[" & Str(Fix(Timer())) & "] FocusOut"
    
  131.         Case KeymapNotify:      Print "[" & Str(Fix(Timer())) & "] KeymapNotify"
    
  132.         Case Expose:            Print "[" & Str(Fix(Timer())) & "] Expose" & Str(report.XExpose.count)
    
  133.         Case GraphicsExpose:    Print "[" & Str(Fix(Timer())) & "] GraphicsExpose"
    
  134.         Case NoExpose:          Print "[" & Str(Fix(Timer())) & "] Noxpose"
    
  135.         Case VisibilityNotify:  Print "[" & Str(Fix(Timer())) & "] VisibiltyNotify"
    
  136.         Case CreateNotify:      Print "[" & Str(Fix(Timer())) & "] CreateNotify"
    
  137.         Case DestroyNotify:     Print "[" & Str(Fix(Timer())) & "] DestroyNotify"
    
  138.         Case UnmapNotify:       Print "[" & Str(Fix(Timer())) & "] UnmapNotify"
    
  139.         Case MapNotify:         Print "[" & Str(Fix(Timer())) & "] MapNotify"
    
  140.         Case MapRequest:        Print "[" & Str(Fix(Timer())) & "] MapRequest"
    
  141.         Case ReparentNotify:    Print "[" & Str(Fix(Timer())) & "] ReparentNotify"
    
  142.         Case ConfigureNotify:   Print "[" & Str(Fix(Timer())) & "] ConfigureNotify"
    
  143.             Print "SIZE:" & Str(report.XConfigure.Width) & "x" & Str(report.XConfigure.Height)
    
  144.             XShmDetach(TDisplay, @TShmInfo)
    
  145.             shmctl(TShmInfo.shmid, IPC_RMID, 0)
    
  146.             shmdt(TShmInfo.shmaddr)
    
  147.             TShmInfo.shmid = shmget(0, report.XConfigure.Width * report.XConfigure.Height * 4, IPC_CREAT Or &O777)
    
  148.             TShmInfo.shmaddr = shmat(TShmInfo.shmid, 0, 0)
    
  149.             XShmAttach(TDisplay, @TShmInfo)
    
  150.             
    
  151.         Case ConfigureRequest:  Print "[" & Str(Fix(Timer())) & "] ConfigureRequest"
    
  152.         Case GravityNotify:     Print "[" & Str(Fix(Timer())) & "] GravityNotify"
    
  153.         Case ResizeRequest:     Print "[" & Str(Fix(Timer())) & "] ResizeRequest"
    
  154.         Case CirculateNotify:   Print "[" & Str(Fix(Timer())) & "] CirculateNotify"
    
  155.         Case CirculateRequest:  Print "[" & Str(Fix(Timer())) & "] CirculateRequest"
    
  156.         Case PropertyNotify:    Print "[" & Str(Fix(Timer())) & "] PropertyNotify"
    
  157.         Case SelectionClear:    Print "[" & Str(Fix(Timer())) & "] SelectionClear"
    
  158.         Case SelectionRequest:  Print "[" & Str(Fix(Timer())) & "] SelectionRequest"
    
  159.         Case SelectionNotify:   Print "[" & Str(Fix(Timer())) & "] SelectionNotify"
    
  160.         Case ColormapNotify:    Print "[" & Str(Fix(Timer())) & "] ColormapNotify"
    
  161.         Case ClientMessage:     Print "[" & Str(Fix(Timer())) & "] ClientMessage"
    
  162.         Case MappingNotify:     Print "[" & Str(Fix(Timer())) & "] MappingNotify"
    
  163.         Case Else:              Print "[" & Str(Fix(Timer())) & "] !!! OTHER !!!"
    
  164.     End Select
    
  165. Wend
    
  166. 
    
  167. XDestroyWindow(TDisplay, win)
    
  168. XCloseDisplay(TDisplay)
    
  169. End 0