]> git.sur5r.net Git - i3/i3/commitdiff
Use c99
authorMichael Stapelberg <michael+git@stapelberg.de>
Sun, 15 Feb 2009 01:30:18 +0000 (02:30 +0100)
committerMichael Stapelberg <michael+git@stapelberg.de>
Sun, 15 Feb 2009 01:30:18 +0000 (02:30 +0100)
Makefile
src/commands.c
src/layout.c
src/table.c
src/xinerama.c

index 3a88cd966cd53dda7b42558de570c5a5b0af26e3..28b7a6369ac5b191ed5006c46b4234d975321078 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 UNAME=$(shell uname)
 DEBUG=1
 
+CFLAGS += -std=c99
 CFLAGS += -Wall
 CFLAGS += -Iinclude
 CFLAGS += -I/usr/local/include
index deaa8868eae3044af845f3b26d14a03a42df8233..6c9ba500bea1d25610a81d8fe61e7be936f5b8ad 100644 (file)
@@ -182,7 +182,6 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
         printf("snapping container to direction %d\n", direction);
 
         Container *container = CUR_CELL;
-        int i;
 
         assert(container != NULL);
 
@@ -202,7 +201,7 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
 
                         /* Check if there are other cells with rowspan, which are in our way.
                          * If so, reduce their rowspan. */
-                        for (i = container->row-1; i >= 0; i--) {
+                        for (int i = container->row-1; i >= 0; i--) {
                                 printf("we got cell %d, %d with rowspan %d\n",
                                                 container->col+1, i, CUR_TABLE[container->col+1][i]->rowspan);
                                 while ((CUR_TABLE[container->col+1][i]->rowspan-1) >= (container->row - i))
@@ -224,7 +223,7 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
                                 return;
                         }
 
-                        for (i = container->col-1; i >= 0; i--) {
+                        for (int i = container->col-1; i >= 0; i--) {
                                 printf("we got cell %d, %d with colspan %d\n",
                                                 i, container->row+1, CUR_TABLE[i][container->row+1]->colspan);
                                 while ((CUR_TABLE[i][container->row+1]->colspan-1) >= (container->col - i))
@@ -241,7 +240,6 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
 }
 
 static void show_workspace(xcb_connection_t *conn, int workspace) {
-        int cols, rows;
         Client *client;
         xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
         /* t_ws (to workspace) is just a convenience pointer to the workspace we’re switching to */
@@ -286,11 +284,10 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
         //xcb_grab_server(conn);
 
         /* Unmap all clients of the current workspace */
-        for (cols = 0; cols < c_ws->cols; cols++)
-                for (rows = 0; rows < c_ws->rows; rows++) {
+        for (int cols = 0; cols < c_ws->cols; cols++)
+                for (int rows = 0; rows < c_ws->rows; rows++)
                         CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients)
                                 xcb_unmap_window(conn, client->frame);
-                }
 
         c_ws = &workspaces[workspace-1];
         current_row = c_ws->current_row;
@@ -298,11 +295,10 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
         printf("new current row = %d, current col = %d\n", current_row, current_col);
 
         /* Map all clients on the new workspace */
-        for (cols = 0; cols < c_ws->cols; cols++)
-                for (rows = 0; rows < c_ws->rows; rows++) {
+        for (int cols = 0; cols < c_ws->cols; cols++)
+                for (int rows = 0; rows < c_ws->rows; rows++)
                         CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients)
                                 xcb_map_window(conn, client->frame);
-                }
 
         /* Restore focus on the new workspace */
         if (CUR_CELL->currently_focused != NULL)
index 75b66c8080d85e45aaf4f9ea99dba5b9bc8385e8..e88a54e62e9d45b3bda237261f1f9c17320ad028 100644 (file)
@@ -159,8 +159,8 @@ static void render_container(xcb_connection_t *connection, Container *container)
 }
 
 void render_layout(xcb_connection_t *connection) {
-        int cols, rows;
         i3Screen *screen;
+
         TAILQ_FOREACH(screen, &virtual_screens, screens) {
                 /* r_ws (rendering workspace) is just a shortcut to the Workspace being currently rendered */
                 Workspace *r_ws = &(workspaces[screen->current_workspace]);
@@ -177,8 +177,8 @@ void render_layout(xcb_connection_t *connection) {
                                 width / r_ws->cols, height / r_ws->rows);
 
                 /* Go through the whole table and render what’s necessary */
-                for (cols = 0; cols < r_ws->cols; cols++)
-                        for (rows = 0; rows < r_ws->rows; rows++) {
+                for (int cols = 0; cols < r_ws->cols; cols++)
+                        for (int rows = 0; rows < r_ws->rows; rows++) {
                                 Container *container = r_ws->table[cols][rows];
                                 printf("container has %d colspan, %d rowspan\n",
                                                 container->colspan, container->rowspan);
index c3f8bea7dc15685182b7b84fe4cda83da3f2d733..41efde0bcd75cb1f3e35a12976a260f5007044db 100644 (file)
@@ -36,10 +36,9 @@ int current_row = 0;
  *
  */
 void init_table() {
-        int i;
         memset(workspaces, 0, sizeof(workspaces));
 
-        for (i = 0; i < 10; i++) {
+        for (int i = 0; i < 10; i++) {
                 workspaces[i].screen = NULL;
                 expand_table_cols(&(workspaces[i]));
                 expand_table_rows(&(workspaces[i]));
@@ -60,11 +59,9 @@ static void new_container(Workspace *workspace, Container **container) {
  *
  */
 void expand_table_rows(Workspace *workspace) {
-        int c;
-
         workspace->rows++;
 
-        for (c = 0; c < workspace->cols; c++) {
+        for (int c = 0; c < workspace->cols; c++) {
                 workspace->table[c] = realloc(workspace->table[c], sizeof(Container*) * workspace->rows);
                 new_container(workspace, &(workspace->table[c][workspace->rows-1]));
         }
@@ -75,13 +72,11 @@ void expand_table_rows(Workspace *workspace) {
  *
  */
 void expand_table_cols(Workspace *workspace) {
-        int c;
-
         workspace->cols++;
 
         workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
         workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1);
-        for (c = 0; c < workspace->rows; c++)
+        for (int c = 0; c < workspace->rows; c++)
                 new_container(workspace, &(workspace->table[workspace->cols-1][c]));
 }
 
index b69d3806a36cf252f35bd61fc14de8bd6a4bbe66..4c8ffa88a48552cffd321cbe8d8847b0726f554b 100644 (file)
@@ -78,7 +78,6 @@ static void disable_xinerama(xcb_connection_t *connection) {
 void initialize_xinerama(xcb_connection_t *conn) {
         xcb_xinerama_query_screens_reply_t *reply;
         xcb_xinerama_screen_info_t *screen_info;
-        int screen;
 
         if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
                 printf("Xinerama extension not found, disabling.\n");
@@ -101,7 +100,7 @@ void initialize_xinerama(xcb_connection_t *conn) {
         num_screens = xcb_xinerama_query_screens_screen_info_length(reply);
 
         /* Just go through each workspace and associate as many screens as we can. */
-        for (screen = 0; screen < num_screens; screen++) {
+        for (int screen = 0; screen < num_screens; screen++) {
                 i3Screen *s = get_screen_at(screen_info[screen].x_org, screen_info[screen].y_org);
                 if (s!= NULL) {
                         /* This screen already exists. We use the littlest screen so that the user