system.linux.bmx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. SuperStrict
  2. ?Not android
  3. Import "-lX11"
  4. Import BRL.System
  5. Import "system.linux.c"
  6. Import "-lXxf86vm"
  7. Import pub.stdc
  8. Extern
  9. Function bbSystemStartup()
  10. Function bbSystemPoll()
  11. Function bbSystemWait()
  12. Function bbSetMouseVisible(visible:Int)
  13. Function bbMoveMouse(x:Int,y:Int)
  14. Function bbSystemDisplay()
  15. Function bbSystemEventHandler( callback(xevent:Byte Ptr) )
  16. Function bbSystemPostSyncOp( syncOp( syncInfo:Object,asyncRet:Int ),syncInfo:Object,asyncRet:Int )
  17. Function bbSystemStartAsyncOp( asyncOp( asyncInfo:Int ),asyncInfo:Int,syncOp( syncInfo:Object,asyncRet:Int ),syncInfo:Object )
  18. Function bbSystemAsyncFD:Int()
  19. Function bbSystemFlushAsyncOps()
  20. Function bbSystemDesktopWidth:Int()
  21. Function bbSystemDesktopHeight:Int()
  22. Function bbSystemDesktopDepth:Int()
  23. Function bbSystemDesktopHertz:Int()
  24. End Extern
  25. Const XKeyPress:Int=2
  26. Const XKeyRelease:Int=3
  27. Function XKeyHandler(keyevent:Int,key:Int,mask:Int)
  28. WriteStdout "XKeyHandler "+keyevent+","+key+","+mask+"~n"
  29. End Function
  30. Type TLinuxSystemDriver Extends TSystemDriver
  31. Method New()
  32. bbSystemStartup
  33. End Method
  34. Method Poll() Override
  35. bbSystemPoll()
  36. End Method
  37. Method Wait() Override
  38. bbSystemWait()
  39. End Method
  40. Method Emit( osevent:Byte Ptr,source:Object )
  41. Throw "simon come here"
  42. End Method
  43. Method SetMouseVisible( visible:Int ) Override
  44. bbSetMouseVisible(visible)
  45. End Method
  46. Method MoveMouse( x:Int,y:Int ) Override
  47. bbMoveMouse x,y
  48. End Method
  49. Method Notify( Text:String,serious:Int ) Override
  50. WriteStdout Text+"~r~n"
  51. End Method
  52. Method Confirm:Int( Text:String,serious:Int ) Override
  53. WriteStdout Text+" (Yes/No)?"
  54. Local t:String=ReadStdin().ToLower()
  55. If t[..1]="y" Return 1
  56. Return 0
  57. End Method
  58. Method Proceed:Int( Text:String,serious:Int ) Override
  59. WriteStdout Text+" (Yes/No/Cancel)?"
  60. Local t:String=ReadStdin().ToLower()
  61. If t[..1]="y" Return 1
  62. If t[..1]="n" Return 0
  63. Return -1
  64. End Method
  65. Method RequestFile:String( Text:String,exts:String,save:Int,file:String ) Override
  66. WriteStdout "Enter a filename:"
  67. Return ReadStdin()
  68. End Method
  69. Method RequestDir:String( Text:String,path:String ) Override
  70. WriteStdout "Enter a directory name:"
  71. Return ReadStdin()
  72. End Method
  73. Method OpenURL:Int( url:String ) Override
  74. 'environment variable is most likely set for desktop environments
  75. 'working with the freedesktop.org project / x.org
  76. 'So this works at least for KDE, Gnome and XFCE
  77. If getenv_("XDG_CURRENT_DESKTOP")
  78. system_("xdg-open ~q"+url+"~q")
  79. 'Fallback for KDE/GNOME
  80. ElseIf getenv_("KDE_FULL_DESKTOP")
  81. system_("kfmclient exec ~q"+url+"~q")
  82. ElseIf getenv_("GNOME_DESKTOP_SESSION_ID")
  83. system_("gnome-open ~q"+url+"~q")
  84. EndIf
  85. End Method
  86. Method DesktopWidth:Int(display:Int) Override
  87. Return bbSystemDesktopWidth()
  88. End Method
  89. Method DesktopHeight:Int(display:Int) Override
  90. Return bbSystemDesktopHeight()
  91. End Method
  92. Method DesktopDepth:Int(display:Int) Override
  93. Return bbSystemDesktopDepth()
  94. End Method
  95. Method DesktopHertz:Int(display:Int) Override
  96. Return bbSystemDesktopHertz()
  97. End Method
  98. Method Name:String() Override
  99. Return "LinuxSystemDriver"
  100. End Method
  101. End Type
  102. InitSystemDriver(New TLinuxSystemDriver)
  103. ?