]> git.sur5r.net Git - i3/i3/commitdiff
Move aspect_ratio from Con to Window. 1880/head
authorIngo Bürk <ingo.buerk@tngtech.com>
Sun, 30 Aug 2015 21:07:25 +0000 (23:07 +0200)
committerIngo Bürk <ingo.buerk@tngtech.com>
Mon, 31 Aug 2015 19:27:13 +0000 (21:27 +0200)
relates to #665

include/data.h
src/commands.c
src/con.c
src/handlers.c
src/render.c

index d6b9924493f0251f3a8701cb45c286d372fc362e..d75622ec6f4decec97c02609f7fbe2fa9c17eb1d 100644 (file)
@@ -418,6 +418,9 @@ struct Window {
     /* minimum increment size specified for the window (in pixels) */
     int width_increment;
     int height_increment;
+
+    /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
+    double aspect_ratio;
 };
 
 /**
@@ -579,9 +582,6 @@ struct Con {
 
     double percent;
 
-    /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
-    double aspect_ratio;
-
     /* the x11 border pixel attribute */
     int border_width;
     int current_border_width;
index 4f726df9a44e7a88c448552547ceef4cf10cda1b..1740286caedbf738ac1944019affb0a45bdbd49d 100644 (file)
@@ -602,7 +602,7 @@ static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floatin
     const i3Window *window = focused_con->window;
     if (window != NULL) {
         if (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0 ||
-                strcmp(direction, "height") == 0) {
+            strcmp(direction, "height") == 0) {
             if (px < 0)
                 px = (-px < window->height_increment) ? -window->height_increment : px;
             else
index 3427013d2419c8caf52730c7310897a82c734826..b1ddf2acc3340eb4d955dcf15f0bcba336627417 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -39,15 +39,16 @@ Con *con_new_skeleton(Con *parent, i3Window *window) {
     Con *new = scalloc(1, sizeof(Con));
     new->on_remove_child = con_on_remove_child;
     TAILQ_INSERT_TAIL(&all_cons, new, all_cons);
-    new->aspect_ratio = 0.0;
     new->type = CT_CON;
     new->window = window;
     new->border_style = config.default_border;
     new->current_border_width = -1;
-    if (window)
+    if (window) {
         new->depth = window->depth;
-    else
+        new->window->aspect_ratio = 0.0;
+    } else {
         new->depth = XCB_COPY_FROM_PARENT;
+    }
     DLOG("opening window\n");
 
     TAILQ_INIT(&(new->floating_head));
index 91817bad25dd35315807b3cb5a3a8623b1c5dee1..1e7eef1e210ba414106b593b27a3ff1004c6112d 100644 (file)
@@ -999,8 +999,8 @@ static bool handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t stat
     } else
         goto render_and_return;
 
-    if (fabs(con->aspect_ratio - aspect_ratio) > DBL_EPSILON) {
-        con->aspect_ratio = aspect_ratio;
+    if (fabs(con->window->aspect_ratio - aspect_ratio) > DBL_EPSILON) {
+        con->window->aspect_ratio = aspect_ratio;
         changed = true;
     }
 
index 76dfa69c7d2f0d30e192b4caafe5d868cf457121..7ada19ebdc37d76546c4156eef839fe4a35e8919 100644 (file)
@@ -172,14 +172,14 @@ void render_con(Con *con, bool render_fullscreen) {
          * Ignoring aspect ratio during fullscreen was necessary to fix MPlayer
          * subtitle rendering, see http://bugs.i3wm.org/594 */
         if (!render_fullscreen &&
-            con->aspect_ratio > 0.0) {
+            con->window->aspect_ratio > 0.0) {
             DLOG("aspect_ratio = %f, current width/height are %d/%d\n",
-                 con->aspect_ratio, inset->width, inset->height);
+                 con->window->aspect_ratio, inset->width, inset->height);
             double new_height = inset->height + 1;
             int new_width = inset->width;
 
             while (new_height > inset->height) {
-                new_height = (1.0 / con->aspect_ratio) * new_width;
+                new_height = (1.0 / con->window->aspect_ratio) * new_width;
 
                 if (new_height > inset->height)
                     new_width--;