Skip to content

Commit

Permalink
Reinstate built-in pointer bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Apr 7, 2016
1 parent e1b5f77 commit 12edac8
Show file tree
Hide file tree
Showing 32 changed files with 1,014 additions and 759 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VERSION := $(shell $(VERCMD) || cat VERSION)

CPPFLAGS += -D_POSIX_C_SOURCE=200112L -DVERSION=\"$(VERSION)\"
CFLAGS += -std=c99 -pedantic -Wall -Wextra
LDLIBS = -lm -lxcb -lxcb-util -lxcb-icccm -lxcb-ewmh -lxcb-randr -lxcb-xinerama
LDLIBS = -lm -lxcb -lxcb-util -lxcb-keysyms -lxcb-icccm -lxcb-ewmh -lxcb-randr -lxcb-xinerama

PREFIX ?= /usr/local
BINPREFIX ?= $(PREFIX)/bin
Expand Down
8 changes: 5 additions & 3 deletions bspwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "monitor.h"
#include "settings.h"
#include "messages.h"
#include "pointer.h"
#include "events.h"
#include "common.h"
#include "window.h"
Expand Down Expand Up @@ -191,6 +192,7 @@ int main(int argc, char *argv[])
cleanup();
close(sock_fd);
unlink(socket_path);
ungrab_buttons();
xcb_ewmh_connection_wipe(ewmh);
xcb_destroy_window(dpy, meta_window);
xcb_destroy_window(dpy, motion_recorder);
Expand All @@ -209,7 +211,6 @@ void init(void)
stack_head = stack_tail = NULL;
subscribe_head = subscribe_tail = NULL;
pending_rule_head = pending_rule_tail = NULL;
last_motion_time = last_motion_x = last_motion_y = 0;
auto_raise = sticky_still = record_history = true;
randr_base = 0;
exit_status = 0;
Expand All @@ -219,6 +220,8 @@ void setup(void)
{
init();
ewmh_init();
pointer_init();

screen = xcb_setup_roots_iterator(xcb_get_setup(dpy)).data;

if (screen == NULL) {
Expand All @@ -227,6 +230,7 @@ void setup(void)

root = screen->root;
register_events();
grab_buttons();

screen_width = screen->width_in_pixels;
screen_height = screen->height_in_pixels;
Expand Down Expand Up @@ -315,7 +319,6 @@ void setup(void)
ewmh_update_number_of_desktops();
ewmh_update_desktop_names();
ewmh_update_current_desktop();
frozen_pointer = make_pointer_state();
xcb_get_input_focus_reply_t *ifo = xcb_get_input_focus_reply(dpy, xcb_get_input_focus(dpy), NULL);
if (ifo != NULL && (ifo->focus == XCB_INPUT_FOCUS_POINTER_ROOT || ifo->focus == XCB_NONE)) {
clear_input_focus();
Expand Down Expand Up @@ -351,7 +354,6 @@ void cleanup(void)
}

empty_history();
free(frozen_pointer);
}

bool check_connection (xcb_connection_t *dpy)
Expand Down
1 change: 0 additions & 1 deletion bspwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ subscriber_list_t *subscribe_tail;
pending_rule_t *pending_rule_head;
pending_rule_t *pending_rule_tail;

pointer_state_t *frozen_pointer;
xcb_window_t meta_window;
xcb_window_t motion_recorder;
xcb_atom_t WM_TAKE_FOCUS;
Expand Down
4 changes: 2 additions & 2 deletions contrib/bash_completion
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_bspc() {
local commands='node desktop monitor query pointer rule restore wm subscribe config quit'
local commands='node desktop monitor query rule restore wm subscribe config quit'

local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity borderless_monocle gapless_monocle leaf_monocle focus_follows_pointer pointer_follows_focus pointer_follows_monitor history_aware_focus focus_by_distance ignore_ewmh_focus center_pseudo_tiled remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity borderless_monocle gapless_monocle leaf_monocle pointer_modifier click_to_focus focus_follows_pointer pointer_follows_focus pointer_follows_monitor history_aware_focus focus_by_distance ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'

COMPREPLY=()

Expand Down
4 changes: 2 additions & 2 deletions contrib/zsh_completion
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

_bspc() {
local -a commands settings
commands=('node' 'desktop' 'monitor' 'query' 'pointer' 'rule' 'restore' 'wm' 'subscribe' 'config' 'quit')
settings=('external_rules_command' 'status_prefix' 'normal_border_color' 'active_border_color' 'focused_border_color' 'presel_feedback_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'initial_polarity' 'borderless_monocle' 'gapless_monocle' 'leaf_monocle' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'history_aware_focus' 'focus_by_distance' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
commands=('node' 'desktop' 'monitor' 'query' 'rule' 'restore' 'wm' 'subscribe' 'config' 'quit')
settings=('external_rules_command' 'status_prefix' 'normal_border_color' 'active_border_color' 'focused_border_color' 'presel_feedback_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'initial_polarity' 'borderless_monocle' 'gapless_monocle' 'leaf_monocle' 'pointer_modifier' 'click_to_focus' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'history_aware_focus' 'focus_by_distance' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'honor_size_hints' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
if (( CURRENT == 2 )) ; then
_values 'command' "$commands[@]"
elif (( CURRENT == 3 )) ; then
Expand Down
7 changes: 1 addition & 6 deletions doc/TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
- Add zoom feature (view point distinct from root).
- Add receptacles (leaves with NULL client pointer).
- Handle window size constraints specified by size hints.
- Add support for showing/hiding nodes.
- Implement all the MUSTs in the EWMH specification.
- Set more attributes in `make_client` (instead of doing it in `apply_rules`) and don't pass `XCB_NONE` as argument.
- Add zoom feature (view point distinct from root).
- Use BSD `sys/{queue/tree}.h` for {list,tree} structures?
- Handle malloc failure everywhere.
106 changes: 67 additions & 39 deletions doc/bspwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 03/26/2016
.\" Date: 04/07/2016
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.1-7-geb209d8
.\" Source: Bspwm 0.9.1-11-ge1b5f77
.\" Language: English
.\"
.TH "BSPWM" "1" "03/26/2016" "Bspwm 0\&.9\&.1\-7\-geb209d8" "Bspwm Manual"
.TH "BSPWM" "1" "04/07/2016" "Bspwm 0\&.9\&.1\-11\-ge1b5f77" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -552,6 +552,24 @@ and the current preselection direction matches
Set the splitting ratio of the preselection area\&.
.RE
.PP
\fB\-v\fR, \fB\-\-move\fR \fIdx\fR \fIdy\fR
.RS 4
Move the selected window by
\fIdx\fR
pixels horizontally and
\fIdy\fR
pixels vertically\&.
.RE
.PP
\fB\-z\fR, \fB\-\-resize\fR top|left|bottom|right|top_left|top_right|bottom_right|bottom_left \fIdx\fR \fIdy\fR
.RS 4
Resize the selected window by moving the given handle by
\fIdx\fR
pixels horizontally and
\fIdy\fR
pixels vertically\&.
.RE
.PP
\fB\-r\fR, \fB\-\-ratio\fR \fIRATIO\fR|(+|\-)\fIPIXELS\fR
.RS 4
Set the splitting ratio of the selected node (0 <
Expand Down Expand Up @@ -848,42 +866,6 @@ Enable or disable the recording of node focus history\&.
Print the current status information\&.
.RE
.RE
.SS "Pointer"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBGeneral Syntax\fR
.RS 4
.sp
pointer \fICOMMANDS\fR
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBCommands\fR
.RS 4
.PP
\fB\-g\fR, \fB\-\-grab\fR focus|move|resize_side|resize_corner
.RS 4
Initiate the given pointer action\&.
.RE
.PP
\fB\-t\fR, \fB\-\-track\fR <x> <y>
.RS 4
Pass the pointer root coordinates for the current pointer action\&.
.RE
.PP
\fB\-u\fR, \fB\-\-ungrab\fR
.RS 4
Terminate the current pointer action\&.
.RE
.RE
.SS "Rule"
.sp
.it 1 an-trap
Expand Down Expand Up @@ -1063,6 +1045,24 @@ Set the desktop layout to
if there\(cqs only one tiled window in the tree\&.
.RE
.PP
\fIpointer_modifier\fR
.RS 4
Keyboard modifier used for moving or resizing windows\&. Accept the following values:
\fBshift\fR,
\fBcontrol\fR,
\fBlock\fR,
\fBmod1\fR,
\fBmod2\fR,
\fBmod3\fR,
\fBmod4\fR,
\fBmod5\fR\&.
.RE
.PP
\fIclick_to_focus\fR
.RS 4
Focus a window (or a monitor) by clicking it\&.
.RE
.PP
\fIfocus_follows_pointer\fR
.RS 4
Focus the window under the pointer\&.
Expand All @@ -1089,6 +1089,11 @@ Center pseudo tiled windows into their tiling rectangles\&. Defaults to
\fItrue\fR\&.
.RE
.PP
\fIhonor_size_hints\fR
.RS 4
Apply ICCCM window size hints\&.
.RE
.PP
\fIremove_disabled_monitors\fR
.RS 4
Consider disabled monitors as disconnected\&.
Expand Down Expand Up @@ -1121,6 +1126,29 @@ Size of the gap that separates windows\&.
.RS 4
Window border width\&.
.RE
.SH "POINTER BINDINGS"
.PP
\fIbutton1\fR
.RS 4
Focus the window under the pointer if
\fIclick_to_focus\fR
is set\&.
.RE
.PP
\fIpointer_modifier\fR + \fIbutton1\fR
.RS 4
Move the window under the pointer\&.
.RE
.PP
\fIpointer_modifier\fR + \fIbutton2\fR
.RS 4
Resize the window under the pointer by dragging the nearest side\&.
.RE
.PP
\fIpointer_modifier\fR + \fIbutton3\fR
.RS 4
Resize the window under the pointer by dragging the nearest corner\&.
.RE
.SH "EVENTS"
.PP
\fIreport\fR
Expand Down
49 changes: 29 additions & 20 deletions doc/bspwm.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ Commands
*-o*, *--presel-ratio* 'RATIO'::
Set the splitting ratio of the preselection area.

*-v*, *--move* 'dx' 'dy'::
Move the selected window by 'dx' pixels horizontally and 'dy' pixels vertically.

*-z*, *--resize* top|left|bottom|right|top_left|top_right|bottom_right|bottom_left 'dx' 'dy'::
Resize the selected window by moving the given handle by 'dx' pixels horizontally and 'dy' pixels vertically.

*-r*, *--ratio* 'RATIO'|(+|-)'PIXELS'::
Set the splitting ratio of the selected node (0 < 'RATIO' < 1).

Expand Down Expand Up @@ -502,26 +508,6 @@ Commands
*-g*, *--get-status*::
Print the current status information.

Pointer
~~~~~~~

General Syntax
^^^^^^^^^^^^^^

pointer 'COMMANDS'

Commands
^^^^^^^^

*-g*, *--grab* focus|move|resize_side|resize_corner::
Initiate the given pointer action.

*-t*, *--track* <x> <y>::
Pass the pointer root coordinates for the current pointer action.

*-u*, *--ungrab*::
Terminate the current pointer action.

Rule
~~~~

Expand Down Expand Up @@ -624,6 +610,12 @@ Global Settings
'single_monocle'::
Set the desktop layout to *monocle* if there's only one tiled window in the tree.

'pointer_modifier'::
Keyboard modifier used for moving or resizing windows. Accept the following values: *shift*, *control*, *lock*, *mod1*, *mod2*, *mod3*, *mod4*, *mod5*.

'click_to_focus'::
Focus a window (or a monitor) by clicking it.

'focus_follows_pointer'::
Focus the window under the pointer.

Expand All @@ -639,6 +631,9 @@ Global Settings
'center_pseudo_tiled'::
Center pseudo tiled windows into their tiling rectangles. Defaults to 'true'.

'honor_size_hints'::
Apply ICCCM window size hints.

'remove_disabled_monitors'::
Consider disabled monitors as disconnected.

Expand Down Expand Up @@ -669,6 +664,20 @@ Node Settings
'border_width'::
Window border width.

Pointer Bindings
----------------
'button1'::
Focus the window under the pointer if 'click_to_focus' is set.
'pointer_modifier' + 'button1'::
Move the window under the pointer.
'pointer_modifier' + 'button2'::
Resize the window under the pointer by dragging the nearest side.
'pointer_modifier' + 'button3'::
Resize the window under the pointer by dragging the nearest corner.
Events
------
Expand Down
Loading

0 comments on commit 12edac8

Please sign in to comment.