Class: XlibObj::Screen
- Inherits:
-
Object
show all
- Defined in:
- lib/screen.rb,
lib/screen/crtc.rb,
lib/screen/crtc/output.rb
Defined Under Namespace
Classes: Crtc
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(display, screen_pointer) ⇒ Screen
Returns a new instance of Screen.
11
12
13
14
15
16
17
18
|
# File 'lib/screen.rb', line 11
def initialize(display, screen_pointer)
@display = display
@struct = Xlib::Screen.new(screen_pointer)
ObjectSpace.define_finalizer(self) do
Xlib.XRRFreeScreenResources(@resources.pointer) if @resources
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
31
32
33
|
# File 'lib/screen.rb', line 31
def method_missing(name)
attribute(name)
end
|
Instance Attribute Details
#display ⇒ Object
Returns the value of attribute display.
20
21
22
|
# File 'lib/screen.rb', line 20
def display
@display
end
|
Instance Method Details
#attribute(name) ⇒ Object
26
27
28
29
|
# File 'lib/screen.rb', line 26
def attribute(name)
return unless @struct.layout.members.include? name.to_sym
@struct[name]
end
|
#crtcs ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/screen.rb', line 58
def crtcs
(0..resources[:ncrtc]-1).map do |crtc_number|
crtc_id(resources[:crtcs], crtc_number)
end.map do |crtc_id|
Crtc.new(self, crtc_id)
end
end
|
#focused_window ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/screen.rb', line 43
def focused_window
window_ptr = FFI::MemoryPointer.new :Window
trash_ptr = FFI::MemoryPointer.new :int
Xlib.XGetInputFocus(@display.to_native, window_ptr, trash_ptr)
window = window_ptr.read_int
if window == Xlib::PointerRoot
root_window
elsif window == Xlib::None
nil
else
Window.new(@display, window)
end
end
|
#number ⇒ Object
35
36
37
|
# File 'lib/screen.rb', line 35
def number
Xlib.XScreenNumberOfScreen(to_native)
end
|
#root_window ⇒ Object
39
40
41
|
# File 'lib/screen.rb', line 39
def root_window
@root_window ||= Window.new(@display, Xlib.XRootWindowOfScreen(to_native))
end
|
#to_native ⇒ Object
22
23
24
|
# File 'lib/screen.rb', line 22
def to_native
@struct.pointer
end
|