Try completing event list
This commit is contained in:
9
X-kutu.c
9
X-kutu.c
@@ -225,8 +225,17 @@ Event wait_for_event(void) {
|
|||||||
case XCB_MAP_NOTIFY: {
|
case XCB_MAP_NOTIFY: {
|
||||||
xcb_map_notify_event_t *e;
|
xcb_map_notify_event_t *e;
|
||||||
e = (xcb_map_notify_event_t *)ev;
|
e = (xcb_map_notify_event_t *)ev;
|
||||||
|
ret.type = -1;
|
||||||
|
ret.window = e->window;
|
||||||
|
ret.override_redirect = e->override_redirect;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case XCB_MAP_REQUEST: {
|
||||||
|
xcb_map_request_event_t *e;
|
||||||
|
e = (xcb_map_request_event_t *)ev;
|
||||||
ret.type = 4;
|
ret.type = 4;
|
||||||
ret.window = e->window;
|
ret.window = e->window;
|
||||||
|
ret.override_redirect = 1;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case XCB_BUTTON_PRESS: {
|
case XCB_BUTTON_PRESS: {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ if ! XCB=$(pkg-config --cflags --libs xcb 2>/dev/null); then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! xrandr --version >/dev/null; then
|
if ! xrandr --version >/dev/null 2>&1 || ! xprop -version >/dev/null 2>&1; then
|
||||||
echo "Error: xrandr not found. Please install xrandr." >&2
|
echo "Error: xrandr or xprop not found. Please install xrandr and xprop." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
35
kutu.rb
35
kutu.rb
@@ -57,16 +57,29 @@ at_exit { X.cleanup }
|
|||||||
|
|
||||||
$monitors = {}
|
$monitors = {}
|
||||||
|
|
||||||
xrandr_output = `xrandr --query`
|
def refresh_monitors
|
||||||
connected = xrandr_output.each_line.select { |line| line.include?(" connected") }
|
$monitors.clear
|
||||||
connected.sort_by! { |line| line.include?(" primary") ? 0 : 1 }
|
xrandr_output = `xrandr --query`
|
||||||
connected.first(2).each_with_index do |line, index|
|
connected = xrandr_output.each_line.select { |line| line.include?(" connected") }
|
||||||
|
connected.sort_by! { |line| line.include?(" primary") ? 0 : 1 }
|
||||||
|
connected.first(2).each_with_index do |line, index|
|
||||||
next unless line =~ /(\d+)x(\d+)\+(\d+)\+(\d+)/
|
next unless line =~ /(\d+)x(\d+)\+(\d+)\+(\d+)/
|
||||||
w, h, x, y = $1.to_i, $2.to_i, $3.to_i, $4.to_i
|
w, h, x, y = $1.to_i, $2.to_i, $3.to_i, $4.to_i
|
||||||
key = index.zero? ? :primary : :secondary
|
key = index.zero? ? :primary : :secondary
|
||||||
$monitors[key] = { x: x, y: y, width: w, height: h }
|
$monitors[key] = { x: x, y: y, width: w, height: h }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
refresh_monitors
|
||||||
|
|
||||||
|
# def get_wm_normal_hints(window_id)
|
||||||
|
# xprop_output = `xprop -id 0x#{window_id.to_s(16)} WM_NORMAL_HINTS`
|
||||||
|
# return {} unless xprop_output =~ /WM_NORMAL_HINTS\(([^)]+)\):\s*(.*)/
|
||||||
|
# hints = {}
|
||||||
|
# # TODO: parse the output properly
|
||||||
|
# hints
|
||||||
|
# end
|
||||||
|
|
||||||
$workspaces = {}
|
$workspaces = {}
|
||||||
$windows = {}
|
$windows = {}
|
||||||
|
|
||||||
@@ -92,10 +105,12 @@ class Node
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Window < Node
|
class Window < Node
|
||||||
attr_accessor :window_id, :x, :y, :width, :height
|
attr_accessor :window_id, :x, :y, :width, :height#, :state
|
||||||
|
|
||||||
def initialize(window_id)
|
def initialize(window_id)
|
||||||
@window_id = window_id
|
@window_id = window_id
|
||||||
|
# @state = :widthrawn # :iconic, :withdrawn, :normal
|
||||||
|
# ADD: properties for https://tronche.com/gui/x/icccm/sec-4.html#s-4 sec 4.1.2.(3, 4)
|
||||||
super()
|
super()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -226,6 +241,7 @@ EVENT_TYPES = {
|
|||||||
1 => :create,
|
1 => :create,
|
||||||
2 => :close,
|
2 => :close,
|
||||||
3 => :enter,
|
3 => :enter,
|
||||||
|
-1 => :show_after,
|
||||||
4 => :show,
|
4 => :show,
|
||||||
5 => :mouse_press,
|
5 => :mouse_press,
|
||||||
6 => :mouse_drag,
|
6 => :mouse_drag,
|
||||||
@@ -265,21 +281,22 @@ loop do
|
|||||||
event = X.wait_for_event
|
event = X.wait_for_event
|
||||||
case EVENT_TYPES[event[:type]]
|
case EVENT_TYPES[event[:type]]
|
||||||
when :create
|
when :create
|
||||||
if event[:override_redirect].zero?
|
next unless event[:override_redirect].zero?
|
||||||
X.subscribe event[:window]
|
X.subscribe event[:window]
|
||||||
X.focus event[:window]
|
X.focus event[:window]
|
||||||
end
|
|
||||||
when :close
|
when :close
|
||||||
X.kill event[:window]
|
X.kill event[:window]
|
||||||
$windows[event[:window]]&.remove event[:window]
|
$windows[event[:window]]&.remove event[:window]
|
||||||
when :enter
|
when :enter
|
||||||
X.focus event[:window]
|
X.focus event[:window]
|
||||||
X.send_to_top event[:window]
|
X.send_to_top event[:window]
|
||||||
when :show
|
when :show_after
|
||||||
X.show event[:window]
|
next unless event[:override_redirect].zero?
|
||||||
X.focus event[:window]
|
X.focus event[:window]
|
||||||
$workspaces[:main].add event[:window] if $windows[event[:window]].nil?
|
$workspaces[:main].add event[:window] if $windows[event[:window]].nil?
|
||||||
$workspaces[:main].tiled_root_block.compute_geometry!
|
$workspaces[:main].tiled_root_block.compute_geometry!
|
||||||
|
when :show
|
||||||
|
X.show event[:window]
|
||||||
when :mouse_press
|
when :mouse_press
|
||||||
next if event[:is_root] != 0
|
next if event[:is_root] != 0
|
||||||
X.send_to_top event[:window]
|
X.send_to_top event[:window]
|
||||||
|
|||||||
40
list.tmp
Normal file
40
list.tmp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#define XCB_KEY_PRESS 2
|
||||||
|
#define XCB_KEY_RELEASE 3
|
||||||
|
|
||||||
|
#define XCB_BUTTON_PRESS 4
|
||||||
|
#define XCB_BUTTON_RELEASE 5
|
||||||
|
#define XCB_MOTION_NOTIFY 6
|
||||||
|
|
||||||
|
#define XCB_ENTER_NOTIFY 7
|
||||||
|
|
||||||
|
#define XCB_LEAVE_NOTIFY 8 - maybe
|
||||||
|
|
||||||
|
#define XCB_CREATE_NOTIFY 16
|
||||||
|
|
||||||
|
// treat these similarly
|
||||||
|
#define XCB_DESTROY_NOTIFY 17 // to remove from struct
|
||||||
|
#define XCB_UNMAP_NOTIFY 18 // i guess this is minimize but idk if it is icccm IconicState?
|
||||||
|
|
||||||
|
#define XCB_MAP_NOTIFY 19 // whatever im doin (dont map this is after mapping)
|
||||||
|
|
||||||
|
#define XCB_MAP_REQUEST 20 // Actual request to map // so map the window if possible
|
||||||
|
|
||||||
|
#define XCB_CONFIGURE_REQUEST 23 // for floats maybe
|
||||||
|
#define XCB_GRAVITY_NOTIFY 24 // similar to XCB_CONFIGURE_NOTIFY but for pos
|
||||||
|
#define XCB_RESIZE_REQUEST 25 // similar to XCB_CONFIGURE_REQUEST but for resize
|
||||||
|
|
||||||
|
#define XCB_CONFIGURE_NOTIFY 22 // prolly remove it
|
||||||
|
#define XCB_PROPERTY_NOTIFY 28 // only if netwm requires so
|
||||||
|
#define XCB_CLIENT_MESSAGE 33 // only if netwm requires
|
||||||
|
|
||||||
|
|
||||||
|
-- ICCCM
|
||||||
|
// TODO: add a function to set wm_state.
|
||||||
|
// actually no as there is no iconfied state .. all windows are maximized and ignore any client request to be iconfied
|
||||||
|
// therefore break ICCCM
|
||||||
|
|
||||||
|
// use xprop to get
|
||||||
|
// WM_NAME .. then ignore it cuz no titlebars
|
||||||
|
|
||||||
|
// WM_NORMAL_HINTS & WM_HINTS
|
||||||
|
// try to obey it for floats
|
||||||
Reference in New Issue
Block a user