--- shutter.original	2017-06-30 02:11:09.000000000 +0200
+++ shutter.klabs	2022-01-01 12:27:18.341638321 +0100
@@ -21,6 +21,22 @@
 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #
 ###################################################
+#
+# PATCHES
+#
+# 2022-01-01 lorenzo@kubiclabs.com #KU003
+# - fix: $wm_name can be undefined
+#
+# 2022-01-01 lorenzo@kubiclabs.com #KU002
+# - removed annoying error popup if a file monitor cannot be activated
+#   ie because the wm don't support it; replaced with a print
+#
+# 2018-10-18 lorenzo@kubiclabs.com #KU001
+# - when checking for handle, if you use "exists" you can have false positives:
+#   in perl an indirect hash element can exist but still have an undefined value,
+#   the right way is use "defined" instead of "exists"
+#
+###################################################
 
 #perl -x -S perltidy -l=0 -b "%f"
 
@@ -4309,7 +4325,9 @@
         #show error dialog when installing the file
         #monitor failed
         unless ( $result eq 'ok' ) {
-            $sd->dlg_error_message( Gnome2::VFS->result_to_string($result), $d->get("Error while adding the file monitor.") );
+            print( "WARNING: ", sprintf( $d->get("adding file monitor: %s"),	# KU002 patch
+            	Gnome2::VFS->result_to_string($result) ), "\n" ); 		# KU002 patch
+            #$sd->dlg_error_message( Gnome2::VFS->result_to_string($result), $d->get("Error while adding the file monitor.") );
             return FALSE;
         }
 
@@ -5439,7 +5457,7 @@
         my $key = shift;
 
         #cancel handle
-        if ( exists $session_screens{$key}->{'handle'} ) {
+        if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
             $session_screens{$key}->{'handle'}->cancel;
         }
 
@@ -5640,8 +5658,7 @@
                 return FALSE;
             }
 
-            if ( exists $session_screens{$key}->{'handle'} ) {
-
+            if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                 #cancel handle
                 $session_screens{$key}->{'handle'}->cancel;
             }
@@ -5681,8 +5698,7 @@
                         my $key = $session_start_screen{'first_page'}->{'model'}->get_value( $iter, 2 );
                         $notebook->remove_page( $notebook->page_num( $session_screens{$key}->{'tab_child'} ) );
 
-                        if ( exists $session_screens{$key}->{'handle'} ) {
-
+                        if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                             #cancel handle
                             $session_screens{$key}->{'handle'}->cancel;
                         }
@@ -5877,7 +5893,7 @@
             if ($last_version) {
 
                 #cancel handle
-                if ( exists $session_screens{$key}->{'handle'} ) {
+                if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                     $session_screens{$key}->{'handle'}->cancel;
                 }
 
@@ -5925,7 +5941,7 @@
             if ($last_version) {
 
                 #cancel handle
-                if ( exists $session_screens{$key}->{'handle'} ) {
+                if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                     $session_screens{$key}->{'handle'}->cancel;
                 }
 
@@ -7187,7 +7203,7 @@
 
             #cancel handle, because file gets manipulated
             #multiple times
-            if ( exists $session_screens{$key}->{'handle'} ) {
+            if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                 $session_screens{$key}->{'handle'}->cancel;
             }
 
@@ -8490,6 +8506,7 @@
         for ( my $wcount = 0 ; $wcount < $wnck_screen->get_workspace_count ; $wcount++ ) {
             push( @workspaces, $wnck_screen->get_workspace($wcount) );
         }
+	$wm_name = "(undef)"	if (!defined $wm_name);	# KU003 patch
 
         foreach my $space (@workspaces) {
             next unless defined $space;
@@ -9585,8 +9602,7 @@
                             #ok => rename it
 
                             #cancel handle
-                            if ( exists $session_screens{$key}->{'handle'} ) {
-
+                            if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                                 $session_screens{$key}->{'handle'}->cancel;
                             }
 
@@ -9628,8 +9644,7 @@
                                 #ok => rename it
 
                                 #cancel handle
-                                if ( exists $session_screens{$key}->{'handle'} ) {
-
+                                if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                                     $session_screens{$key}->{'handle'}->cancel;
                                 }
 
@@ -9659,8 +9674,7 @@
                                     if ( $session_screens{$searchkey}->{'long'} eq $new_name ) {
 
                                         #cancel handle
-                                        if ( exists $session_screens{$searchkey}->{'handle'} ) {
-
+                                        if ( defined $session_screens{$searchkey}->{'handle'} ) { #KU001 patch
                                             $session_screens{$searchkey}->{'handle'}->cancel;
                                         }
 
@@ -10036,8 +10050,7 @@
                         {
 
                             #cancel handle
-                            if ( exists $session_screens{$key}->{'handle'} ) {
-
+                            if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                                 $session_screens{$key}->{'handle'}->cancel;
                             }
                             if ( &fct_update_tab( $key, undef, Gnome2::VFS::URI->new($filename), FALSE, 'clear' ) ) {
@@ -10100,8 +10113,7 @@
                             {
 
                                 #cancel handle
-                                if ( exists $session_screens{$key}->{'handle'} ) {
-
+                                if ( defined $session_screens{$key}->{'handle'} ) { #KU001 patch
                                     $session_screens{$key}->{'handle'}->cancel;
                                 }
 
