Skip to content

Instantly share code, notes, and snippets.

@shibafu528
Created December 13, 2014 13:26
Show Gist options
  • Save shibafu528/3fda4a72a8082b5785f9 to your computer and use it in GitHub Desktop.
Save shibafu528/3fda4a72a8082b5785f9 to your computer and use it in GitHub Desktop.
地獄かよ
# coding: utf-8
=begin
https://github.com/meh/ruby-x11
↑これを使ったウィンドウ表示実験
なおrubygemsから依存死亡で直接インストールができないため、
以下のgemのソースも拾ってビルドする必要がある
retarded : https://github.com/meh/retarded
=end
require 'X11/Xlib'
disp = X11::Display.open
screen = disp.default_screen
root = screen.root_window
border = X11::C::XBlackPixel(disp.to_native, screen.to_i)
bg = X11::C::XWhitePixel(disp.to_native, screen.to_i)
window = X11::Window.new(disp, X11::C::XCreateSimpleWindow(
disp.to_native,
root.to_i,
0, 0, 320, 200, 1,
border, bg))
window.map
loop do
disp.next_event do
# たぶんこんな感じにnext_eventとかそれっぽいやつに
# ブロック渡してイベントループできるんだろうけど力尽きた、知らん
end
end
window.destroy
disp.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment