@@ -115,56 +115,51 @@ def adopt(wid, desktop=nil)
115
115
w = @windows [ wid ] # To avoid infinite recursion, this *must not* use #window
116
116
return w if w
117
117
w = Window . new ( self , wid )
118
- begin
119
- # FIXME: At least some of these ought to "adopted" but set as
120
- # floating/non-layout so they stay on a single desktop.
121
- #
122
- if w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_POPUP ) ||
123
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_NOTIFICATION ) ||
124
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_POPUP_MENU ) ||
125
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_MENU ) ||
126
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_DOCK ) ||
127
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_TOOLTIP ) ||
128
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_DIALOG ) ||
129
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_SPLASH ) ||
130
- w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_UTILITY )
131
- w . floating = true
132
- w . stack
133
- return w
134
- end
135
- if w . desktop?
136
- w . floating = true
137
- end
138
- attr = w . get_window_attributes
139
- return w if attr . wclass == 2 # InputOnly
140
- return w if attr . override_redirect
141
- w . mapped = attr . map_state != 0
142
- geom = w . get_geometry
143
- return w if geom . is_a? ( X11 ::Form ::Error ) || geom . width < 2 || geom . height < 2
144
- @windows [ wid ] = w
145
-
146
- wms = w . get_property ( :_NET_WM_STATE , :atom ) &.value
147
- if wms == dpy . atom ( :_NET_WM_STATE_ABOVE )
148
- # This seems like it's probably not a good idea.
149
- return w
150
- end
151
118
152
- w . set_border ( @border_normal )
153
-
154
- desktop = dpy . get_property ( wid , :_NET_WM_DESKTOP , :cardinal ) &. value
155
- desktop ||= current_desktop_id
156
- move_to_desktop ( wid , desktop )
157
- w . select_input (
158
- X11 :: Form :: FocusChangeMask |
159
- X11 :: Form :: PropertyChangeMask |
160
- X11 :: Form :: EnterWindowMask |
161
- X11 :: Form :: LeaveWindowMask
162
- )
163
- rescue Exception => e
164
- p [ :ZZZZZZZZZZZZZZZZZZZZZZZZZADOPT_FAILED , e ]
165
- # Failure here most likely reflects a window that has "disappeared".
166
- # We should handle that better, but for now this is fine
119
+ # FIXME: At least some of these ought to "adopted" but set as
120
+ # floating/non-layout so they stay on a single desktop.
121
+ #
122
+ if w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_POPUP ) ||
123
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_NOTIFICATION ) ||
124
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_POPUP_MENU ) ||
125
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_MENU ) | |
126
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_DOCK ) | |
127
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_TOOLTIP ) | |
128
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_DIALOG ) ||
129
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_SPLASH ) ||
130
+ w . type == dpy . atom ( :_NET_WM_WINDOW_TYPE_UTILITY )
131
+ w . floating = true
132
+ w . stack
133
+ return w
167
134
end
135
+ if w . desktop?
136
+ w . floating = true
137
+ end
138
+ attr = w . get_window_attributes
139
+ return w if attr . wclass == 2 # InputOnly
140
+ return w if attr . override_redirect
141
+ w . mapped = attr . map_state != 0
142
+ geom = w . get_geometry
143
+ return w if geom . width < 2 || geom . height < 2
144
+ @windows [ wid ] = w
145
+
146
+ wms = w . get_property ( :_NET_WM_STATE , :atom ) &.value
147
+ if wms == dpy . atom ( :_NET_WM_STATE_ABOVE )
148
+ # This seems like it's probably not a good idea.
149
+ return w
150
+ end
151
+
152
+ w . set_border ( @border_normal )
153
+
154
+ desktop = dpy . get_property ( wid , :_NET_WM_DESKTOP , :cardinal ) &.value
155
+ desktop ||= current_desktop_id
156
+ move_to_desktop ( wid , desktop )
157
+ w . select_input (
158
+ X11 ::Form ::FocusChangeMask |
159
+ X11 ::Form ::PropertyChangeMask |
160
+ X11 ::Form ::EnterWindowMask |
161
+ X11 ::Form ::LeaveWindowMask
162
+ )
168
163
update_client_list
169
164
return w
170
165
end
0 commit comments