about summary refs log tree commit diff stats
path: root/src/ui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c73
1 files changed, 19 insertions, 54 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index a8f9ec63..4cbe25f4 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -52,6 +52,7 @@
 #include "config/preferences.h"
 #include "ui/ui.h"
 #include "ui/window.h"
+#include "ui/screen.h"
 #include "xmpp/xmpp.h"
 #include "xmpp/roster_list.h"
 
@@ -604,9 +605,10 @@ win_resize(ProfWin *window)
 void
 win_update_virtual(ProfWin *window)
 {
-    int rows, cols;
-    getmaxyx(stdscr, rows, cols);
+    int cols = getmaxx(stdscr);
 
+    int row_start = screen_mainwin_row_start();
+    int row_end = screen_mainwin_row_end();
     if (window->layout->type == LAYOUT_SPLIT) {
         ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
         if (layout->subwin) {
@@ -616,83 +618,46 @@ win_update_virtual(ProfWin *window)
             } else {
                 subwin_cols = win_roster_cols();
             }
-            char *pos = prefs_get_string(PREF_INPUTWIN);
-            if (g_strcmp0(pos, "top") == 0) {
-                pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1);
-                pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1);
-            } else {
-                pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
-                pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
-            }
-            prefs_free_string(pos);
+            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1);
+            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1);
         } else {
-            char *pos = prefs_get_string(PREF_INPUTWIN);
-            if (g_strcmp0(pos, "top") == 0) {
-                pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, cols-1);
-            } else {
-                pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, cols-1);
-            }
-            prefs_free_string(pos);
+            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols-1);
         }
     } else {
-        char *pos = prefs_get_string(PREF_INPUTWIN);
-        if (g_strcmp0(pos, "top") == 0) {
-            pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 2, 0, rows-2, cols-1);
-        } else {
-            pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1);
-        }
-        prefs_free_string(pos);
+        pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1);
     }
 }
 
 void
 win_refresh_without_subwin(ProfWin *window)
 {
-    int rows, cols;
-    getmaxyx(stdscr, rows, cols);
+    int cols = getmaxx(stdscr);
 
     if ((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) {
-        char *pos = prefs_get_string(PREF_INPUTWIN);
-        if (g_strcmp0(pos, "top") == 0) {
-            pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 2, 0, rows-2, cols-1);
-        } else {
-            pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1);
-        }
-        prefs_free_string(pos);
+        int row_start = screen_mainwin_row_start();
+        int row_end = screen_mainwin_row_end();
+        pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1);
     }
 }
 
 void
 win_refresh_with_subwin(ProfWin *window)
 {
-    int rows, cols;
-    getmaxyx(stdscr, rows, cols);
+    int cols = getmaxx(stdscr);
     int subwin_cols = 0;
 
+    int row_start = screen_mainwin_row_start();
+    int row_end = screen_mainwin_row_end();
     if (window->type == WIN_MUC) {
         ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
         subwin_cols = win_occpuants_cols();
-        char *pos = prefs_get_string(PREF_INPUTWIN);
-        if (g_strcmp0(pos, "top") == 0) {
-            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1);
-            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1);
-        } else {
-            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
-            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
-        }
-        prefs_free_string(pos);
+        pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1);
+        pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1);
     } else if (window->type == WIN_CONSOLE) {
         ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
         subwin_cols = win_roster_cols();
-        char *pos = prefs_get_string(PREF_INPUTWIN);
-        if (g_strcmp0(pos, "top") == 0) {
-            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1);
-            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1);
-        } else {
-            pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
-            pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
-        }
-        prefs_free_string(pos);
+        pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1);
+        pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1);
     }
 }