]> git.sur5r.net Git - i3/i3/blobdiff - src/randr.c
Change workspace assignments to use the RandR output name instead of <screen>
[i3/i3] / src / randr.c
index f63b2f0cc30a931cf12b50e918742bd52298669f..d56f01f09ae97c3b6d1bb35b9d741780ee01cce7 100644 (file)
@@ -45,35 +45,30 @@ typedef xcb_randr_get_screen_resources_current_reply_t resources_reply;
 struct outputs_head outputs = TAILQ_HEAD_INITIALIZER(outputs);
 
 /*
- * Returns true if both screen objects describe the same screen (checks their
- * size and position).
+ * Get a specific output by its internal X11 id. Used by randr_query_screens
+ * to check if the output is new (only in the first scan) or if we are
+ * re-scanning.
  *
  */
-bool screens_are_equal(Output *screen1, Output *screen2) {
-        /* If one of both objects (or both) are NULL, we cannot compare them */
-        if (screen1 == NULL || screen2 == NULL)
-                return false;
-
-        /* If the pointers are equal, take the short-circuit */
-        if (screen1 == screen2)
-                return true;
-
-        /* Compare their size and position - other properties are not relevant
-         * to determine if a screen is equal to another one */
-        return (memcmp(&(screen1->rect), &(screen2->rect), sizeof(Rect)) == 0);
+static Output *get_output_by_id(xcb_randr_output_t id) {
+        Output *output;
+        TAILQ_FOREACH(output, &outputs, outputs)
+                if (output->id == id)
+                        return output;
+
+        return NULL;
 }
 
 /*
- * Get a specific output by its internal X11 id. Used by randr_query_screens
- * to check if the output is new (only in the first scan) or if we are
- * re-scanning.
+ * Returns the output with the given name if it is active (!) or NULL.
  *
  */
-static Output *get_output_by_id(xcb_randr_output_t id) {
-        Output *screen;
-        TAILQ_FOREACH(screen, &outputs, outputs)
-                if (screen->id == id)
-                        return screen;
+Output *get_output_by_name(const char *name) {
+        Output *output;
+        TAILQ_FOREACH(output, &outputs, outputs)
+                if (output->active &&
+                    strcasecmp(output->name, name) == 0)
+                        return output;
 
         return NULL;
 }