Commit graph

78 commits

Author SHA1 Message Date
Chris Feng
9c95c03e18 Rework the X windows hierarchy model
This commit add workspace and X window containers support to avoid using
Emacs frames as the parents of X windows.  This should make it easier to
set input focus.

* exwm-core.el (exwm--container, exwm--floating-frame-position): New file
local variables.
(exwm--floating-frame-geometry): Removed file local variable.
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating, exwm-floating--do-moveresize)
(exwm-floating-move): Use container.
(exwm-floating--fit-frame-to-window): No longer adjust stacking order.
(exwm-floating--fit-frame-to-window): The first member is changed to
buffer.
(exwm-floating--start-moveresize): Use container.  Correctly set input
focus.
* exwm-input.el (exwm-input--redirected, exwm-input--on-focus-in): Removed.
(exwm-input--on-buffer-list-update): Remove the restriction on floating
frames which is no longer valid.
(exwm-input--update-focus): Adjust stacking order.
(exwm-input--on-minibuffer-setup): New function for setting focus on the
Emacs frame when entering minibuffer.
(exwm-input--on-KeyPress-line-mode): No longer compensate FocusOut event.
(exwm-input--grab-keyboard, exwm-input--release-keyboard): Local keys are
now grabbed on the X window container.
(exwm-input--init): Add `exwm-input--on-minibuffer-setup' to
`minibuffer-setup-hook'.
* exwm-layout.el (exwm-layout--resize-container): New function to
resize/reposition both the X window and its container.
(exwm-layout--show, exwm-layout--hide): Use container.
(exwm-layout-set-fullscreen): Use container.  No longer save width and
height.
(exwm-layout-unset-fullscreen, exwm-layout--set-frame-fullscreen): Use
container.
(exwm-layout--refresh): Update a frame parameter.  Remove dead code.
* exwm-manage.el (exwm-manage--manage-window): Reparent unmanaged X windows
to the workspace.  Create X window container as the parent of the X window.
(exwm-manage--unmanage-window): Unmap/destroy container when appropriate.
Use the position of container.
(exwm-manage--unmanage-window): Destroy the container.
* exwm-randr.el (exwm-randr--refresh): Resize workspace using container.
* exwm-workspace.el (exwm-workspace-switch): Raise workspace.
Correctly set input focus.
(exwm-workspace--on-focus-in): Removed.
(exwm-workspace-move-window): Reparent to workspace container.
(exwm-workspace--init): Create workspace frames as visible.
Create workspace containers.
Remove exwm-workspace--on-focus-in from focus-in-hook.
Update _NET_VIRTUAL_ROOTS.
* exwm.el (exwm-init): No longer disable hourglass window.
Initialize workspace module before input.

* exwm-core.el (exwm--debug): New macro for setting debug forms.

* exwm-floating.el (exwm-floating--set-floating): No longer do `exwm--lock'
and `exwm--unlock' since `make-frame' is already adviced to take care of
everything.  Correctly set input focus to the newly created floating
X window.

* exwm-core.el (exwm--floating-edges): Removed file local variable.
* exwm-floating.el (exwm-floating--set-floating)
(exwm-floating--unset-floating):
* exwm-layout.el (exwm-layout--show, exwm-layout-enlarge-window):
* exwm-manage.el (exwm-manage--on-ConfigureRequest):
No longer use floating geometry.

* exwm-input.el (exwm-input--update-global-prefix-keys): Grab global keys
on workspaces containers instead of the root window (or input focus would
transfer to the workspace containing the pointer when the grab is active).
* exwm-workspace.el (exwm-workspace-switch): No longer move mouse.
2016-02-03 12:12:24 +08:00
Chris Feng
0db666b4fb Update copyright year to 2016 2016-02-02 22:33:58 +08:00
Chris Feng
2779d2e418 Make the creation/destruction of floating frames more silent
* exwm-floating.el (exwm-floating--set-floating): Reparent floating frames
  as late as possible.
* exwm-manage.el (exwm-manage--unmanage-window): Hide floating frames first
  on unmanagement.
2015-10-28 14:05:56 +08:00
Chris Feng
d05df51b05 Fix problems introduced/exposed by last commit
* exwm-workspace.el (exwm-workspace-switch, exwm-workspace--on-focus-in):
  Use handle-switch-frame instead of exwm-workspace--switch-count to filter
  out events.

* exwm-workspace.el (exwm-workspace--init): Delay making workspaces
  fullscreen.

* exwm-workspace.el (exwm-workspace-move-window):
* exwm-floating.el (exwm-floating--set-floating):
* exwm-layout.el (exwm-layout--refresh):
  `set-buffer-major-mode` does not accept buffer names.
2015-10-26 12:38:20 +08:00
Chris Feng
3b518eec23 Fix a position calculation error on multi-monitor settings
* exwm-floating.el (exwm-floating--set-floating): Always use relative
  positions.
2015-10-01 09:30:14 +08:00
Chris Feng
5184f0d7c1 Work around subrs that block EXWM; other minor fixes
Some subrs (e.g. x-file-dialog) create X windows and block the execution of
EXWM, so they won't work normally.  This commit partly fixes this issue by
invoking them in a subordinate Emacs instance and trying to fetch the
result back.

* exwm.el (exwm-blocking-subrs): New variable for specify such subrs.
* exwm.el (exwm-enable, exwm--server-name, exwm--server-stop)
  (exwm--server-eval-at): The implementation.

* exwm-core.el:
* exwm-floating.el:
* exwm-layout.el:
* exwm-manage.el:
* exwm-randr.el:
  Evaluate constants at compile-time.

* README.md: Renamed from README.org to make the 'Commentary:' section
  used by GNU ELPA instead.

* exwm.el: Depends on XELB version 0.3.
2015-09-27 19:43:06 +08:00
Chris Feng
4ad76b879d Fix a calculation error of the position of a floating frame
* exwm-floating.el (exwm-floating--set-floating): The position of a
  floating frame should be relative to its workspace.
2015-09-24 20:03:57 +08:00
Chris Feng
22ee3e6c5f Adjust default prefix keys; advice x-create-frame
* exwm-input.el (exwm-input--on-KeyPress-line-mode, exwm-input-prefix-keys):
  Allow users to disable 'C-c' prefixed keys; Add 'C-c' to / remove 'M-!'
  from the default prefix keys.

* exwm-workspace.el (exwm-workspace--x-create-frame, exwm-workspace--init):
  Advice `x-create-frame' to prevent it from hanging EXWM, making e.g.
  speedbar working.
* exwm-floating.el (exwm-floating--set-floating): Remove the now unnecessary
  request that sets override-redirect on floating frames.
2015-09-23 12:53:08 +08:00
Chris Feng
921e6e5be9 Avoid autoloading variables
* exwm-floating.el:
* exwm-layout.el:
  Avoid autoloading exwm-floating-border-width.
* exwm-workspace.el:
  Avoid autoloading exwm-workspace--switch-history-outdated.
2015-09-19 12:34:30 +08:00
Chris Feng
26ebc32e60 Fix a compilation warning
* exwm-floating.el: Autoload exwm-floating-border-width.
2015-09-18 14:38:05 +08:00
Chris Feng
412d2a52bd Fix wrong/missing ConfigureNotify events
* exwm-floating.el (exwm-floating--set-floating): Set exwm--floating-edges
  as absolute edges (the relative edges can be easily determined).
* exwm-layout.el (exwm-layout--show): Send correct absolute positions to
  floating X windows.

* exwm-floating.el (exwm-floating--stop-moveresize, exwm-floating-move): Send
  ConfigureNotify events after moving floating X windows.
2015-09-18 14:17:52 +08:00
Chris Feng
4255f078a6 On-demand update exwm-workspace--switch-history
* exwm-workspace.el (exwm-workspace--switch-history-outdated)
  (exwm-workspace--update-switch-history, exwm-workspace-switch)
  (exwm-workspace-move-window):
* exwm.el (exwm--update-hints, exwm--on-ClientMessage):
* exwm-floating.el (exwm-floating--set-floating):
* exwm-manage.el (exwm-manage--manage-window, exwm-manage--unmanage-window):
  Update exwm-workspace--switch-history only when it's used.
2015-09-17 19:48:50 +08:00
Chris Feng
b458d5ac30 Allow showing buffers on other workspaces and moving an X window by switching
to its buffer

* exwm-workspace.el (exwm-workspace-show-all-buffers, exwm-workspace-switch)
  (exwm-workspace-move-window, exwm-workspace-switch-to-buffer): Show buffers
  on other workspaces if `exwm-workspace-show-all-buffers' is non-nil.

* exwm-layout.el (exwm-layout-show-all-buffers, exwm-layout--refresh): Allow
  moving an X window by switch to its corresponding buffer from another
  workspace when `exwm-layout-show-all-buffers' is non-nil.
* exwm.el (exwm--ido-buffer-window-other-frame): Handle the case when
  `exwm-layout-show-all-buffers' is non-nil.

* exwm-floating.el (exwm-floating--set-floating): Handle the case when
  *scratch* buffer is killed.

* exwm-workspace.el (exwm-workspace-switch-to-buffer): Renamed from
  `exwm-workspace-switch-to-window' to better reflect its role.
2015-09-16 21:36:36 +08:00
Chris Feng
dbcabe7946 Implement move/resize with keyboard
* exwm-floating.el: Remove an invalid TODO item.
* exwm-floating.el (exwm-floating--set-floating)
  (exwm-floating-hide-mode-line, exwm-floating-show-mode-line): Set
  window-size-fixed only for fixed-size floating windows.
* exwm-floating.el (exwm-floating-move): New function for moving a floating
  window.
* exwm-layout.el (exwm-layout-enlarge-window)
  (exwm-layout-enlarge-window-horizontally, exwm-layout-shrink-window)
  (exwm-layout-shrink-window-horizontally): New commands for interactively
  resizing a floating window.
2015-09-11 17:16:17 +08:00
Chris Feng
eafd031c55 Allow hide/show mode-line on floating frames
* exwm-core.el: new buffer-local variable exwm--floating-mode-line-format for
  saving mode-line-format when mode-line is hidden
* exwm-floating.el (exwm-floating--fit-frame-to-window)
  (exwm-floating-hide-mode-line, exwm-floating-show-mode-line): new functions
  for resizing frames, hiding/showing mode-line respectively;
  (exwm-floating--set-floating): use exwm-floating--fit-frame-to-window to
  resize frames
2015-09-07 17:33:22 +08:00
Chris Feng
6d63c71280 Prepare for GNU ELPA release
* Transfer copyright to Free Software Foundation
* Add packaging components (e.g. headers)
* Coding style fixes:
  + Quote functions with "#'"
  + Wrap long lines
  + Fix doc strings / comments
* Replace `string-to-int' with `string-to-number'
* Fix compiling errors / eliminate compiling warnings
  + Add exwm-core.el to hold common variables, functions and macros
* Remove the redundant COPYING file
* Add .gitignore
* Rename README to README.md
2015-09-04 09:15:20 +08:00
Chris Feng
f1d37b9a8c Ungrab pointer timely when resizing is aborted
* exwm-floating.el (exwm-floating--start-moveresize): when resizing type cannot
  be decided, ungrab the previously grabbed pointer.
2015-09-03 18:56:36 +08:00
Chris Feng
5f9f673791 Fix window size calculations
* When sending the synthetic ConfigureNotify event, make sure we are dealing
  with the correct Emacs window
* When managing a floating window, ensure it can be easily pick up by the user
2015-08-27 11:03:27 +08:00
Chris Feng
b50a6e6dd9 Correct several EWMH properties
The following EWMH properties on the root window are corrected in this commit:
_NET_VIRTUAL_ROOTS, _NET_WORKAREA and _NET_DESKTOP_VIEWPORT.
2015-08-26 17:40:39 +08:00
Chris Feng
d998b42b89 Provide hooks run when the floating state of a window changes (close #28) 2015-08-16 19:02:48 +08:00
Chris Feng
07e59e0429 Fix multi-screen bugs
* RandR module is now made optional; users can enable it with
  `exwm-randr-enable`.
* Correct the calculation of sizes/coordinates at various places.
* Input focus is now tracked with (Emacs) window instead of buffer since the
  latter can be ambiguous in multi-screen settings.
2015-08-13 12:02:44 +08:00
Chris Feng
04e4269617 Improve input focus switch mechanism
This commit should fix most input focus bugs (especially those related to
floating windows). The actual settings of input focus are delayed to exclude
redundant event. Dead code since this commit is removed.

This commit also fixes a bug for non-floating windows converted form floating
state. The workaround for `ido-mode` is also improved to properly handle
`exwm-mode` buffers.
2015-08-12 18:09:35 +08:00
Chris Feng
1ce18afd05 Center floating windows by default
This commit makes a floating window centered to its leading window if it has
a valid WM_TRANSIENT_FOR property set. Other it's placed at the center of the
screen.
2015-08-11 15:06:11 +08:00
Chris Feng
b755296f54 Remove redundant code caused by the concurrency of events (contd, 2)
* Remove locks that are no longer required
* Also fix #20 (inactive workspace frame steals input focus)
2015-08-11 09:18:21 +08:00
Chris Feng
2d4104a0ec Fix emacsclient bugs
`emacsclient` started with `-c` or `-t` argument create a new frame that shall
not be used to manage X windows.
Also fix some related input focus issues (with some remaining unfixed).
Close #17.
2015-08-10 10:55:28 +08:00
Chris Feng
3b9d0dd921 Fixes for manage/unmanage window
* Make sure `exwm-manage--manage-window-queue` is cleaned
* Improve input focus handling after unmanaging a window
* Remove a redundant call to `exwm-layout--show`
2015-08-08 08:29:57 +08:00
Chris Feng
7892ed36f1 Improve move/resize
The type of move/resize is consistent during one complete operation. So there
is no need to judge it on every mouse motion.
2015-07-18 10:23:24 +08:00
Chris Feng
10a7fe8d65 First commit 2015-07-17 19:16:08 +08:00