$OpenBSD: patch-src_scratchpad_c,v 1.1 2013/01/27 18:33:20 dcoppa Exp $

From 7be5ece6636f7a4c800ab0c5dd6289b38db7b435 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Fri, 25 Jan 2013 14:47:43 +0000
Subject: Bugfix: fix coordinates of scratchpad windows on output changes (Thanks badboy)

--- src/scratchpad.c.orig	Wed Dec 12 00:08:17 2012
+++ src/scratchpad.c	Sun Jan 27 19:12:12 2013
@@ -218,8 +218,24 @@ void scratchpad_fix_resolution(void) {
             new_height = _lcm(new_height, output->rect.height);
         }
     }
+
+    Rect old_rect = __i3_output->rect;
+
     DLOG("new width = %d, new height = %d\n",
          new_width, new_height);
     __i3_output->rect.width = new_width;
     __i3_output->rect.height = new_height;
+
+    Rect new_rect = __i3_output->rect;
+
+    if (memcmp(&old_rect, &new_rect, sizeof(Rect)) == 0) {
+        DLOG("Scratchpad size unchanged.\n");
+        return;
+    }
+
+    DLOG("Fixing coordinates of scratchpad windows\n");
+    Con *con;
+    TAILQ_FOREACH(con, &(__i3_scratch->floating_head), floating_windows) {
+        floating_fix_coordinates(con, &old_rect, &new_rect);
+    }
 }
