From a429742d92fe9c61e6e52a14a20cf5135f2b29d0 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 20 Aug 2014 17:08:40 +0200 Subject: [PATCH] Add "Resize" autocommand (via outerWidth/outerHeight) Fixes: https://code.google.com/p/dactyl/issues/detail?id=1121 --- common/content/events.js | 7 +++++++ melodactyl/content/config.js | 1 + melodactyl/locale/en-US/autocommands.xml | 1 + pentadactyl/config.json | 1 + pentadactyl/locale/en-US/autocommands.xml | 1 + teledactyl/locale/en-US/autocommands.xml | 1 + 6 files changed, 12 insertions(+) diff --git a/common/content/events.js b/common/content/events.js index 844a5b512..73bdd52aa 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -113,6 +113,8 @@ var Events = Module("events", { }); this._fullscreen = window.fullScreen; + this._outerWidth = window.outerWidth; + this._outerHeight = window.outerHeight; this._lastFocus = { get: function () null }; this._macroKeys = []; this._lastMacro = ""; @@ -853,6 +855,11 @@ var Events = Module("events", { dactyl.triggerObserver("fullscreen", this._fullscreen); autocommands.trigger("Fullscreen", { url: this._fullscreen ? "on" : "off", state: this._fullscreen }); } + if (window.outerWidth != this._outerWidth || window.outerHeight != this._outerHeight) { + this._outerWidth = window.outerWidth; + this._outerHeight = window.outerHeight; + autocommands.trigger("Resize", {}); + } statusline.updateZoomLevel(); } }, diff --git a/melodactyl/content/config.js b/melodactyl/content/config.js index baa5b3b6f..f3db8f092 100644 --- a/melodactyl/content/config.js +++ b/melodactyl/content/config.js @@ -160,6 +160,7 @@ const Config = Module("config", ConfigBase, { LocationChange: "Triggered when changing tabs or when navigation to a new location", PageLoadPre: "Triggered after a page load is initiated", PageLoad: "Triggered when a page gets (re)loaded/opened", + Resize: "Triggered after the window has been resized", ShellCmdPost: "Triggered after executing a shell command with :!cmd", TrackChangePre: "Triggered before a playing track is changed", TrackChange: "Triggered after a playing track has changed", diff --git a/melodactyl/locale/en-US/autocommands.xml b/melodactyl/locale/en-US/autocommands.xml index 154ca6b58..b05924dbb 100644 --- a/melodactyl/locale/en-US/autocommands.xml +++ b/melodactyl/locale/en-US/autocommands.xml @@ -16,6 +16,7 @@
LocationChange
Triggered when changing tabs or when navigating to a new location
PageLoadPre
Triggered after a page load is initiated
PageLoad
Triggered when a page gets (re)loaded/opened
+
Resize
Triggered after the window has been resized
ShellCmdPost
Triggered after executing a shell command with :!#{cmd}
TrackChangePre
Triggered before a playing track is changed
TrackChange
Triggered after a playing track has changed
diff --git a/pentadactyl/config.json b/pentadactyl/config.json index dc1e8ec66..c4eda7894 100644 --- a/pentadactyl/config.json +++ b/pentadactyl/config.json @@ -44,6 +44,7 @@ "PageLoadPre": "Triggered after a page load is initiated", "PageLoad": "Triggered when a page gets (re)loaded/opened", "PrivateMode": "Triggered when private browsing mode is activated or deactivated", + "Resize": "Triggered after the window has been resized", "Sanitize": "Triggered when a sanitizeable item is cleared", "ShellCmdPost": "Triggered after executing a shell command with :!cmd", "Enter": "Triggered after Firefox starts", diff --git a/pentadactyl/locale/en-US/autocommands.xml b/pentadactyl/locale/en-US/autocommands.xml index d2aa0ce44..ec21d709b 100644 --- a/pentadactyl/locale/en-US/autocommands.xml +++ b/pentadactyl/locale/en-US/autocommands.xml @@ -19,6 +19,7 @@
PageLoadPre
Triggered after a page load is initiated
PageLoad
Triggered when a page gets (re)loaded/opened
PrivateMode
Triggered when private browsing mode is activated or deactivated
+
Resize
Triggered after the window has been resized
Sanitize
Triggered when private data are sanitized
ShellCmdPost
Triggered after executing a shell command with :!cmd
Enter
Triggered after &dactyl.host; starts
diff --git a/teledactyl/locale/en-US/autocommands.xml b/teledactyl/locale/en-US/autocommands.xml index edcaf5407..3e8d0eb46 100644 --- a/teledactyl/locale/en-US/autocommands.xml +++ b/teledactyl/locale/en-US/autocommands.xml @@ -15,6 +15,7 @@
LocationChange
Triggered when changing tabs or when navigating to a new location
PageLoadPre
Triggered after a page load is initiated
PageLoad
Triggered when a page gets (re)loaded/opened
+
Resize
Triggered after the window has been resized
ShellCmdPost
Triggered after executing a shell command with :!cmd
Enter
Triggered after &dactyl.host; starts
LeavePre
Triggered before exiting &dactyl.host;, just before destroying each module