Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 pdf-presenter-console (4.0.2-2) unstable; urgency=medium
 .
   * update homepage (closes: #820477)
   * bump standards version, no changes required
   * merge upstream development branch, with FTBFS fix (closes: #819858)
   * tweak debian/copyright
   * pass hardening flags per
     https://wiki.debian.org/Hardening#Notes_for_packages_using_Vala
Author: Barak A. Pearlmutter <bap@debian.org>
Bug-Debian: https://bugs.debian.org/819858
Bug-Debian: https://bugs.debian.org/820477

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- pdf-presenter-console-4.0.2.orig/README.rst
+++ pdf-presenter-console-4.0.2/README.rst
@@ -17,8 +17,30 @@ software.
 More information, including screenshots and a demo presentation, can be found
 at https://pdfpc.github.io/
 
-Requirements
+Installation
 ============
+- On Ubuntu or Debian systems::
+
+        sudo apt-get install pdf-presenter-console
+- `Compiling from source <#compile-and-install>`_
+- `Compiling from github <#compiling-from-github>`_
+
+Sample presentations
+--------------------
+
+- `Simple demo <https://pdfpc.github.io/demo/pdfpc-demo.pdf>`_
+- `Embedded movies <https://pdfpc.github.io/demo/pdfpc-video-example.zip>`_
+
+Try it out::
+
+    pdfpc pdfpc-demo.pdf
+
+
+Compile and install
+===================
+
+Requirements
+------------
 
 In order to compile and run pdfpc the following
 requirements need to be met:
@@ -30,8 +52,13 @@ requirements need to be met:
 - poppler with glib bindings
 - gstreamer 1.0
 
-Compile and install
-===================
+On Ubuntu systems, you can install these dependencies with::
+
+    sudo apt-get install cmake libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgee-0.8-dev librsvg2-dev libpoppler-glib-dev libgtk2.0-dev libgtk-3-dev valac
+
+and you should consider installing all the available gstreamer codecs::
+
+    sudo apt-get install gstreamer1.0-*
 
 Compiling from source tarballs
 ------------------------------
@@ -116,6 +143,29 @@ building the application::
 
 Congratulations you just installed pdfpc on your system.
 
+Compiling on Windows
+--------------------
+
+On issue #106 there is a short tutorial on how to compile pdfpc on Windows.
+First a cygwin installation with the following depedencies is needed:
+
+- cmake
+- automake
+- make
+- gcc
+- gcc-c++
+- libstdc++-4.8-dev
+- x11
+
+For pdfpc the following compile time dependencies are necessary:
+
+- vala
+- gtk
+- gee
+- libpoppler
+- gstreamer
+- libgstinterfaces1.0-devel (has gstreamer.audio included)
+
 Compiling Trouble Shooting
 --------------------------
 
@@ -125,14 +175,15 @@ try running cmake with::
 
     cmake -DVALA_EXECUTABLE:NAMES=valac-0.28 ..
 
-How to go on
-============
 
-Download the demo presentation from the downloads section and load it into
-pdfpc to get a feeling of it::
+Usage
+=====
+
+Now download some [sample presentations](#sample-presentations) and load  them up::
 
     pdfpc pdfpc-demo.pdf
 
+
 Acknowledgements
 ================
 
--- pdf-presenter-console-4.0.2.orig/man/pdfpc.in
+++ pdf-presenter-console-4.0.2/man/pdfpc.in
@@ -309,9 +309,12 @@ supported. (Also, run ps2pdf with the \-
 .PP
 As a perhaps simpler option, pdfpc will play back movies linked from a
 hyperlink of type "launch".  A query string may be added to the URL of the
-movie to enable the "autostart" and "loop" properties.  (E.g., a link to
-"movie.avi?autostart&loop" will start playing automatically, and loop when
-it reaches the end.)  In LaTeX, such links are created with
+movie to enable the "autostart", "loop" and "noprogress" properties, if
+necessary.  (E.g., a link to "movie.avi?autostart&loop&noprogress" will add a
+video that starts playing automatically, loops when it reaches the end, and
+does not show the progress bar.)
+
+In LaTeX, such links are created with
 
 .RS
 \\usepackage{hyperref}
@@ -352,7 +355,7 @@ For the programmers out there: slide ind
 .SH CONFIG FILES
 .PP
 The main configuration file for pdfpc is located in @SYSCONFDIR@/pdfpcrc.
-Additionally, $HOME/.pdfpcrc is also read, if present.
+Additionally, $XDG_CONFIG_DIR/pdfpc/pdfpcrc is also read, if present.
 
 .SS Keybindings
 .PP
@@ -384,6 +387,13 @@ A/M (for Alt/Meta). E.g.
 .TP
 bind S+Next    next10
 .P
+A shorthand for specifying key combinations constituting shift and an
+alphabetic character is to simply give the uppercase version of the
+alphabetic character. For example, to bind <shift>+r to the 'reset'
+function, use
+.TP
+bind R reset
+.P
 A list of all possible functions can be obtained
 via the \-L command line option.
 
@@ -430,7 +440,12 @@ Switch the presentation and the presente
 With GTK3 it is possible to modify the appearance of pdfpc. There are two
 locations where pdfpc is looking for files. The default location is
 @CMAKE_INSTALL_PREFIX@/share/pixmaps/pdfpc/pdfpc.css. A user can copy
-it to $XDG_CONFIG_HOME/pdfpc.css and change the attributes as he likes.
+it to $XDG_CONFIG_HOME/pdfpc/pdfpc.css and change the attributes as he likes.
+
+.SH INTEGRATION WITH OTHER TOOLS
+Pdfpc provides a dbus interface that other tools can use to execute any
+action listed by \fB--list-actions\fR.  The interface appears on the session bus
+as \fI io.github.pdfpc\fR.
 
 .SH BUGS
 
--- pdf-presenter-console-4.0.2.orig/rc/pdfpcrc
+++ pdf-presenter-console-4.0.2/rc/pdfpcrc
@@ -5,6 +5,7 @@ bind Next      next
 bind Return    next
 bind Right     next
 bind space     next
+bind l         lastOverlay
 bind Down      nextOverlay
 bind S+Next    next10
 bind S+Return  next10
--- pdf-presenter-console-4.0.2.orig/src/classes/action/movie.vala
+++ pdf-presenter-console-4.0.2/src/classes/action/movie.vala
@@ -64,6 +64,11 @@ namespace pdfpc {
          */
         protected bool loop;
 
+        /**
+         * A flag to indicated whether the progress bar should be supressed.
+         */
+        protected bool noprogress = false;
+
          /**
          * A flag to indicate whether the audio should be played or not.
          */
@@ -98,10 +103,11 @@ namespace pdfpc {
          */
         public virtual void init_other(ActionMapping other, Poppler.Rectangle area,
                 PresentationController controller, Poppler.Document document,
-                string uri, bool autostart, bool loop, bool noaudio, int start = 0, int stop = 0, bool temp=false) {
+                string uri, bool autostart, bool loop, bool noprogress, bool noaudio, int start = 0, int stop = 0, bool temp=false) {
             other.init(area, controller, document);
             Movie movie = (Movie) other;
             movie.loop = loop;
+            movie.noprogress = noprogress;
             movie.noaudio = noaudio;
             movie.starttime = start;
             movie.stoptime = stop;
@@ -157,6 +163,7 @@ namespace pdfpc {
             bool autostart = "autostart" in queryarray;
             bool noaudio = "noaudio" in queryarray;
             bool loop = "loop" in queryarray;
+            bool noprogress = "noprogress" in queryarray;
             var start = 0;
             var stop = 0;
             foreach (string param in queryarray) {
@@ -176,7 +183,7 @@ namespace pdfpc {
 
             Type type = Type.from_instance(this);
             ActionMapping new_obj = (ActionMapping) GLib.Object.new(type);
-            this.init_other(new_obj, mapping.area, controller, document, uri, autostart, loop, noaudio, start, stop);
+            this.init_other(new_obj, mapping.area, controller, document, uri, autostart, loop, noprogress, noaudio, start, stop);
             return new_obj;
         }
 
@@ -264,7 +271,7 @@ namespace pdfpc {
 
             Type type = Type.from_instance(this);
             ActionMapping new_obj = (ActionMapping) GLib.Object.new(type);
-            this.init_other(new_obj, mapping.area, controller, document, uri, false, false, false, 0, 0, temp);
+            this.init_other(new_obj, mapping.area, controller, document, uri, false, false, false, false, 0, 0, temp);
             return new_obj;
         }
 
@@ -484,8 +491,8 @@ namespace pdfpc {
          */
         public override void init_other(ActionMapping other, Poppler.Rectangle area,
                 PresentationController controller, Poppler.Document document, string file,
-                bool autostart, bool loop, bool noaudio, int start = 0, int stop = 0, bool temp=false) {
-            base.init_other(other, area, controller, document, file, autostart, loop, noaudio, start, stop, temp);
+                bool autostart, bool loop, bool noprogress, bool noaudio, int start = 0, int stop = 0, bool temp=false) {
+            base.init_other(other, area, controller, document, file, autostart, loop, noprogress, noaudio, start, stop, temp);
             ControlledMovie movie = (ControlledMovie) other;
             controller.main_view.motion_notify_event.connect(movie.on_motion);
             controller.main_view.button_release_event.connect(movie.on_button_release);
@@ -537,7 +544,7 @@ namespace pdfpc {
          * for the view with the controls.)
          */
         public void on_prepare(Gst.Element overlay, Gst.Caps caps) {
-            var info = Gst.Video.Info();
+            var info = new Gst.Video.Info();
             info.from_caps(caps);
             int width = info.width, height = info.height;
             this.scalex = (double) width / rect.width;
@@ -642,7 +649,7 @@ namespace pdfpc {
                 cr.show_text(timestring);
                 cr.restore();
 
-            } else {
+            } else if (this.noprogress == false) {
                 cr.rectangle(0, 0, rect.width, 4);
                 cr.set_source_rgba(0, 0, 0, 0.8);
                 cr.fill();
@@ -652,7 +659,7 @@ namespace pdfpc {
                 cr.rectangle(start_bar, 0, stop_bar - start_bar, 4);
                 cr.set_source_rgba(1,1,1,0.5);
                 cr.fill();
-             }
+            }
         }
 
         /**
--- pdf-presenter-console-4.0.2.orig/src/classes/configFileReader.vala
+++ pdf-presenter-console-4.0.2/src/classes/configFileReader.vala
@@ -7,6 +7,7 @@
  * Copyright 2015 Robert Schroll
  * Copyright 2015 Andreas Bilke
  * Copyright 2016 Andy Barry
+ * Copyright 2016 Joakim Nilsson
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -55,6 +56,14 @@ namespace pdfpc {
                 }
                 code = conversor(fields[1]);
             }
+            // 'X' adds keybinding shift+x
+            if ('A' <= code && code <= 'Z') { // If uppercase
+                modMask |= Gdk.ModifierType.SHIFT_MASK;
+            }
+            // 'S+x' adds keybinding shift+x
+            if ('a' <= code && code <= 'z' && ((modMask | Gdk.ModifierType.SHIFT_MASK) == modMask)) { // If lowercase without shift
+                code ^= (1 << 5); // Toggle case
+            }
         }
 
         private void bindKey(string wholeLine, string[] fields) {
--- /dev/null
+++ pdf-presenter-console-4.0.2/src/classes/dbus_server.vala
@@ -0,0 +1,86 @@
+/**
+ * Presentation Event controller
+ *
+ * This file is part of pdfpc.
+ *
+ * Copyright (C) 2015 Robert Schroll
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+namespace pdfpc {
+
+    [DBus (name = "io.github.pdfpc")]
+    public class DBusServer : Object {
+
+        private string _url;
+
+        public signal void overlay_change(int number);
+
+        public signal void slide_change(int number);
+
+        public int number_of_overlays {
+            get {
+                return (int) this.metadata.get_slide_count();
+            }
+        }
+
+        public int number_of_slides {
+            get {
+                return this.metadata.get_user_slide_count();
+            }
+        }
+
+
+        public string url {
+            get {
+                return _url;
+            }
+        }
+
+        protected PresentationController controller;
+        protected Metadata.Pdf metadata;
+
+        public DBusServer(PresentationController controller, Metadata.Pdf metadata) {
+            this.controller = controller;
+            this.metadata = metadata;
+            this._url = this.metadata.get_url();
+            controller.notify["current-slide-number"].connect(
+                () => overlay_change(controller.current_slide_number));
+            controller.notify["current-user-slide-number"].connect(
+                () => slide_change(controller.current_user_slide_number));
+        }
+
+        public static void start_server(PresentationController controller, Metadata.Pdf metadata) {
+            Bus.own_name(BusType.SESSION, "io.github.pdfpc", BusNameOwnerFlags.NONE,
+                (connection) => {
+                    try {
+                        connection.register_object("/io/github/pdfpc",
+                            new DBusServer(controller, metadata));
+                    } catch (IOError e) {
+                        warning("Could not register DBus service.");
+                    }
+                }, () => {}, () => warning("Could not acquire DBus bus."));
+        }
+
+        public void trigger_action(string name) {
+            this.controller.trigger_action(name);
+        }
+
+        public string get_notes() {
+            return this.metadata.get_notes().get_note_for_slide(controller.current_user_slide_number);
+        }
+    }
+}
--- pdf-presenter-console-4.0.2.orig/src/classes/presentation_controller.vala
+++ pdf-presenter-console-4.0.2/src/classes/presentation_controller.vala
@@ -150,6 +150,7 @@ namespace pdfpc {
 
         /**
          * Stores the "history" of the slides (jumps only)
+         * A stack would be more useful.
          */
         private int[] history;
 
@@ -241,6 +242,7 @@ namespace pdfpc {
 
             readKeyBindings();
             readMouseBindings();
+            DBusServer.start_server(this, this.metadata);
         }
 
         /*
@@ -266,6 +268,7 @@ namespace pdfpc {
         protected void add_actions() {
             add_action("next", this.next_page);
             add_action("next10", this.jump10);
+            add_action("lastOverlay", this.jump_to_last_overlay);
             add_action("nextOverlay", this.next_user_page);
             add_action("prev", this.previous_page);
             add_action("prev10", this.back10);
@@ -315,6 +318,7 @@ namespace pdfpc {
         public static string[] getActionDescriptions() {
             return {"next", "Go to next slide",
                 "next10", "Jump 10 slides forward",
+                "lastOverlay", "Jump to the last overlay of the current slide",
                 "nextOverlay", "Jump forward outside of current overlay",
                 "prev", "Go to previous slide",
                 "prev10", "Jump 10 slides back",
@@ -342,6 +346,13 @@ namespace pdfpc {
         }
 
         /**
+         * Trigger an action by name
+         */
+        public void trigger_action(string name) {
+            this.action_group.activate_action(name, null);
+        }
+
+        /**
          * Bind the (user-defined) keys
          */
         public void bind(uint keycode, uint modMask, string action_name) {
@@ -594,13 +605,19 @@ namespace pdfpc {
                 return;
 
             this.timer.start();
+            // there is a next slide
             if (this.current_slide_number < this.n_slides - 1) {
                 ++this.current_slide_number;
-                if (this.current_slide_number == this.metadata.user_slide_to_real_slide(
-                    this.current_user_slide_number + 1))
+
+                // if the next slide is also a new user slide
+                if (this.current_slide_number == this.metadata.user_slide_to_real_slide(this.current_user_slide_number + 1)) {
                     ++this.current_user_slide_number;
-                if (!this.frozen)
+                }
+
+                if (!this.frozen) {
                     this.faded_to_black = false;
+                }
+
                 this.controllables_update();
             } else if (this.black_on_end && !this.faded_to_black) {
                 this.fade_to_black();
@@ -612,26 +629,56 @@ namespace pdfpc {
          */
         public void next_user_page() {
             this.timer.start();
-            bool needs_update; // Did we change anything?
-            if (this.current_user_slide_number < this.metadata.get_user_slide_count()-1) {
+            bool needs_update = false; // Did we change anything? Default: no
+
+            // there is a next user slide
+            if (this.current_user_slide_number < this.metadata.get_user_slide_count() - 1) {
                 ++this.current_user_slide_number;
-                this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                    this.current_user_slide_number);
+                this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
                 needs_update = true;
             } else {
+                // we are at the last slide
                 if (this.current_slide_number == this.n_slides - 1) {
-                    needs_update = false;
-                    if (this.black_on_end && !this.faded_to_black)
+                    if (this.black_on_end && !this.faded_to_black) {
                         this.fade_to_black();
+                    }
                 } else {
-                    this.current_user_slide_number = this.metadata.get_user_slide_count() - 1;
+                    // move to the last slide, we are already at the last user slide
                     this.current_slide_number = this.n_slides - 1;
-                    needs_update = false;
                 }
             }
+
             if (needs_update) {
-                if (!this.frozen)
+                if (!this.frozen) {
+                    this.faded_to_black = false;
+                }
+                this.controllables_update();
+            }
+        }
+
+        /**
+         * Jump to the last overlay for the current user slide
+         */
+        public void jump_to_last_overlay() {
+            this.timer.start();
+            bool needs_update = false; // Did we change anything? Default: no
+
+            // there is a next user slide
+            if (this.current_user_slide_number < this.metadata.get_user_slide_count() - 1) {
+                // last overlay = next user slide (as real) - 1
+                this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number + 1) - 1;
+                needs_update = true;
+            } else {
+                // we are at the last user slide
+                // last overlay == last last
+                this.current_slide_number = this.n_slides - 1;
+                needs_update = true;
+            }
+
+            if (needs_update) {
+                if (!this.frozen) {
                     this.faded_to_black = false;
+                }
                 this.controllables_update();
             }
         }
@@ -641,17 +688,18 @@ namespace pdfpc {
          */
         public void previous_page() {
             this.timer.start();
+
             if (this.current_slide_number > 0) {
-                if (this.current_slide_number != this.metadata.user_slide_to_real_slide(
-                    this.current_user_slide_number)) {
-                    --this.current_slide_number;
-                } else {
+                if (this.current_slide_number == this.metadata.user_slide_to_real_slide(this.current_user_slide_number)) {
                     --this.current_user_slide_number;
-                    this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                        this.current_user_slide_number);
+                    this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
+                } else {
+                    --this.current_slide_number;
                 }
-                if (!this.frozen)
+
+                if (!this.frozen) {
                     this.faded_to_black = false;
+                }
                 this.controllables_update();
             }
         }
@@ -661,16 +709,17 @@ namespace pdfpc {
          */
         public void previous_user_page() {
             this.timer.start();
+
             if (this.current_user_slide_number > 0) {
                 --this.current_user_slide_number;
-                this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                    this.current_user_slide_number);
+                this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
             } else {
-                this.current_user_slide_number = 0;
                 this.current_slide_number = 0;
             }
-            if (!this.frozen)
+
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.controllables_update();
         }
 
@@ -679,12 +728,18 @@ namespace pdfpc {
          */
         public void goto_first() {
             this.timer.start();
-            if (this.current_slide_number != 0)
+
+            // update history if we are not already at the first slide
+            if (this.current_slide_number > 0) {
                 this.push_history();
+            }
+
             this.current_slide_number = 0;
             this.current_user_slide_number = 0;
-            if (!this.frozen)
+
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.controllables_update();
         }
 
@@ -693,13 +748,18 @@ namespace pdfpc {
          */
         public void goto_last() {
             this.timer.start();
-            if (this.current_user_slide_number != this.metadata.get_end_user_slide() - 1)
+
+            // if are not already at the last slide, update history
+            if (this.current_user_slide_number < this.metadata.get_end_user_slide()) {
                 this.push_history();
+            }
+
             this.current_user_slide_number = this.metadata.get_end_user_slide() - 1;
-            this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                this.current_user_slide_number);
-            if (!this.frozen)
+            this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
+
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.controllables_update();
         }
 
@@ -707,18 +767,18 @@ namespace pdfpc {
          * Jump 10 (user) slides forward
          */
         public void jump10() {
-            if (this.overview_shown)
+            if (this.overview_shown) {
                 return;
+            }
 
             this.timer.start();
-            this.current_user_slide_number += 10;
-            int max_user_slide = this.metadata.get_user_slide_count();
-            if (this.current_user_slide_number >= max_user_slide)
-                this.current_user_slide_number = max_user_slide - 1;
-            this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                this.current_user_slide_number);
-            if (!this.frozen)
+
+            this.current_user_slide_number = int.min(this.current_user_slide_number + 10, this.metadata.get_user_slide_count() - 1);
+            this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
+
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.controllables_update();
         }
 
@@ -726,40 +786,44 @@ namespace pdfpc {
          * Jump 10 (user) slides backward
          */
         public void back10() {
-            if (this.overview_shown)
+            if (this.overview_shown) {
                 return;
+            }
 
             this.timer.start();
-            this.current_user_slide_number -= 10;
-            if (this.current_user_slide_number < 0)
-                this.current_user_slide_number = 0;
-            this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                this.current_user_slide_number);
-            if (!this.frozen)
+
+            this.current_user_slide_number = int.max(this.current_user_slide_number - 10, 0);
+            this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
+
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.controllables_update();
         }
 
         /**
-         * Goto a slide in user page numbers
+         * Goto a slide in user page numbers. page_number is 1 indexed.
          */
         public void goto_user_page(int page_number) {
             this.timer.start();
-            if (this.current_user_slide_number != page_number - 1)
+
+            if (this.current_user_slide_number != page_number - 1) {
                 this.push_history();
+            }
 
             this.controllables_hide_overview();
             int destination = page_number - 1;
             int n_user_slides = this.metadata.get_user_slide_count();
-            if (page_number < 1)
+            if (page_number < 1) {
                 destination = 0;
-            else if (page_number >= n_user_slides)
+            } else if (page_number >= n_user_slides) {
                 destination = n_user_slides - 1;
+            }
             this.current_user_slide_number = destination;
-            this.current_slide_number = this.metadata.user_slide_to_real_slide(
-                this.current_user_slide_number);
-            if (!this.frozen)
+            this.current_slide_number = this.metadata.user_slide_to_real_slide(this.current_user_slide_number);
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.set_ignore_input_events(false);
             this.controllables_update();
         }
@@ -768,21 +832,25 @@ namespace pdfpc {
          * Go back in history
          */
         public void history_back() {
-            if (this.overview_shown)
+            if (this.overview_shown) {
                 return;
+            }
 
             int history_length = this.history.length;
             if (history_length == 0) {
                 this.goto_first();
-            } else {
-                this.current_slide_number = this.history[history_length - 1];
-                this.current_user_slide_number = this.metadata.real_slide_to_user_slide(
-                    this.current_slide_number);
-                this.history.resize(history_length - 1);
-                if (!this.frozen)
-                    this.faded_to_black = false;
-                this.controllables_update();
+
+                return;
+            }
+
+            this.current_slide_number = this.history[history_length - 1];
+            this.current_user_slide_number = this.metadata.real_slide_to_user_slide(this.current_slide_number);
+            this.history.resize(history_length - 1);
+
+            if (!this.frozen) {
+                this.faded_to_black = false;
             }
+            this.controllables_update();
         }
 
         /**
@@ -803,10 +871,11 @@ namespace pdfpc {
         }
 
         protected void toggle_overview() {
-            if (this.overview_shown)
+            if (this.overview_shown) {
                 this.controllables_hide_overview();
-            else
+            } else {
                 this.controllables_show_overview();
+            }
         }
 
         protected void controllables_show_overview() {
@@ -822,8 +891,9 @@ namespace pdfpc {
             // It may happen that in overview mode, the number of (user) slides
             // has changed due to overlay changes. We may need to correct our
             // position
-            if (this.current_user_slide_number >= this.user_n_slides)
+            if (this.current_user_slide_number >= this.user_n_slides) {
                 this.goto_last();
+            }
             this.overview_shown = false;
             this.hide_overview_request();
             this.controllables_update();
@@ -841,8 +911,9 @@ namespace pdfpc {
          * Edit note for current slide.
          */
         protected void controllables_edit_note() {
-            if (this.overview_shown)
+            if (this.overview_shown) {
                 return;
+            }
             this.edit_note_request(); // emit signal
         }
 
@@ -850,8 +921,9 @@ namespace pdfpc {
          * Ask for the page to jump to
          */
         protected void controllables_ask_goto_page() {
-            if (this.overview_shown)
+            if (this.overview_shown) {
                 return;
+            }
             this.ask_goto_page_request();
         }
 
@@ -860,8 +932,9 @@ namespace pdfpc {
          */
         protected void toggle_freeze() {
             this.frozen = !this.frozen;
-            if (!this.frozen)
+            if (!this.frozen) {
                 this.faded_to_black = false;
+            }
             this.controllables_update();
         }
 
@@ -872,8 +945,9 @@ namespace pdfpc {
             if (overview_shown) {
                 int user_selected = this.overview.current_slide;
                 int slide_number = this.metadata.user_slide_to_real_slide(user_selected);
-                if (this.metadata.toggle_skip(slide_number, user_selected) != 0)
+                if (this.metadata.toggle_skip(slide_number, user_selected) != 0) {
                     this.overview.remove_current(this.user_n_slides);
+                }
             } else {
                 this.current_user_slide_number += this.metadata.toggle_skip(
                     this.current_slide_number, this.current_user_slide_number);
--- pdf-presenter-console-4.0.2.orig/src/classes/window/fullscreen.vala
+++ pdf-presenter-console-4.0.2/src/classes/window/fullscreen.vala
@@ -70,6 +70,11 @@ namespace pdfpc.Window {
                 screen.get_monitor_geometry(current_screen, out this.screen_geometry);
             }
 
+            // We always render ouput to fit to an exact size.
+            // This also forces some tiling window managers like i3 to
+            // put the windows on the right screens.
+            this.resizable = false;
+
             if (!Options.windowed) {
                 // Move to the correct monitor
                 // This movement is done here and after mapping, to minimize flickering
@@ -91,7 +96,6 @@ namespace pdfpc.Window {
                         this.screen_geometry.width /= 2;
                         this.screen_geometry.height /= 2;
                 }
-                this.resizable = false;
             }
 
             this.add_events(Gdk.EventMask.POINTER_MOTION_MASK);
--- pdf-presenter-console-4.0.2.orig/src/pdfpc.vala
+++ pdf-presenter-console-4.0.2/src/pdfpc.vala
@@ -138,7 +138,8 @@ namespace pdfpc {
 
             var sourceCssPath = Path.build_filename(Paths.SOURCE_PATH, "rc/pdfpc.css");
             var distCssPath = Path.build_filename(Paths.ICON_PATH, "pdfpc.css");
-            var userCssDir = Path.build_filename(GLib.Environment.get_user_config_dir(), "pdfpc.css");
+            var legacyUserCssPath = Path.build_filename(GLib.Environment.get_user_config_dir(), "pdfpc.css");
+            var userCssPath = Path.build_filename(GLib.Environment.get_user_config_dir(), "pdfpc", "pdfpc.css");
 
             try {
                 // pdfpc.css in dist path or in build directory is mandatory
@@ -150,8 +151,11 @@ namespace pdfpc {
                     warning("No CSS file found");
                 }
                 // load custom user css on top
-                if (GLib.FileUtils.test(userCssDir, (GLib.FileTest.IS_REGULAR))) {
-                    userProvider.load_from_path(userCssDir);
+                if (GLib.FileUtils.test(userCssPath, (GLib.FileTest.IS_REGULAR))) {
+                    userProvider.load_from_path(userCssPath);
+                } else if (GLib.FileUtils.test(legacyUserCssPath, (GLib.FileTest.IS_REGULAR))) {
+                    userProvider.load_from_path(legacyUserCssPath);
+                    warning("Loaded pdfpc.css from legacy location. Please move your style sheet to %s", userCssPath);
                 }
             } catch (Error error) {
                 warning("Could not load styling from data: %s", error.message);
@@ -198,8 +202,16 @@ namespace pdfpc {
             ConfigFileReader configFileReader = new ConfigFileReader();
             configFileReader.readConfig(Path.build_filename(Paths.SOURCE_PATH, "rc/pdfpcrc"));
             configFileReader.readConfig(Path.build_filename(Paths.CONF_PATH, "pdfpcrc"));
-            configFileReader.readConfig(Path.build_filename(Environment.get_home_dir(),
-                ".pdfpcrc"));
+            var legacyUserConfig = Path.build_filename(Environment.get_home_dir(), ".pdfpcrc");
+            var userConfig = Path.build_filename(GLib.Environment.get_user_config_dir(), "pdfpc", "pdfpcrc");
+            if (GLib.FileUtils.test(userConfig, (GLib.FileTest.IS_REGULAR))) {
+                // first, use the xdg config directory
+                configFileReader.readConfig(userConfig);
+            } else if (GLib.FileUtils.test(legacyUserConfig, (GLib.FileTest.IS_REGULAR))) {
+                // if not found, use the legacy location
+                configFileReader.readConfig(legacyUserConfig);
+                warning("Loaded pdfpcrc from legacy location. Please move your config file to %s", userConfig);
+            }
 
 #if MOVIES
             Gst.init( ref args );
