Skip to content

Commit

Permalink
GH-3: restore client's position after unfullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Jan 2, 2016
1 parent f5eb147 commit 7e40231
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion control/action/client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,57 @@ script:
control:
action:

client_fullscreen!: curr_client.fullscreen!
client_fullscreen!: |
# wmii doesn't properly restore a client to its pre-fullscreen position
# so we keep track of that information and perform correct restoration
@client_fullscreen_placeholder ||= {}
client = curr_client
if client.fullscreen?
client.unfullscreen
if restore_info = @client_fullscreen_placeholder.delete(client.id)
is_top_left = restore_info[:is_top] and restore_info[:is_left]
is_top_right = restore_info[:is_top] and restore_info[:is_right]
neighbor_id = is_top_left ? restore_info[:next_id] : restore_info[:prev_id]
if (neighbor = Client.new(neighbor_id)).exist?
unless is_top_right
client.send :left rescue nil
neighbor.focus
neighbor.area.insert client
end
if is_top_left
client.send :left rescue nil
client.send :up rescue nil
end
if restore_info[:is_top] and not restore_info[:is_left]
if client.area.next.floating?
client.send :right rescue nil
else
client.area.next.unshift client
end
end
if restore_info[:is_alone]
lengths = curr_view.columns.flat_map do |column|
if column == client.area
[1, column.length-1]
else
column.length
end
end
curr_view.arrange_columns lengths
end
end
end
else
@client_fullscreen_placeholder[client.id] = {
prev_id: client.prev.id,
next_id: client.next.id,
is_left: client.area.id == 1,
is_right: client.area.next.floating?,
is_top: client.area.client_ids.first == client.id,
is_alone: client.area.client_ids.length == 1,
} unless client.float?
client.fullscreen
end
client_close: curr_client.kill

Expand Down

0 comments on commit 7e40231

Please sign in to comment.