about summary refs log tree commit diff stats
path: root/tile.c
diff options
context:
space:
mode:
Diffstat (limited to 'tile.c')
-rw-r--r--tile.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tile.c b/tile.c
index 6a58282..8269676 100644
--- a/tile.c
+++ b/tile.c
@@ -26,7 +26,7 @@ setmfact(const char *arg) {
 
 void
 tile(void) {
-	int y, h;
+	int x, y, h, w;
 	unsigned int i, n;
 	Client *c;
 
@@ -46,16 +46,18 @@ tile(void) {
 		return;
 
 	/* tile stack */
+	x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
 	y = ty;
+	w = (tx > c->x + c->w) ? wx + ww - x : tw;
 	h = th / n;
 	if(h < bh)
 		h = th;
 
 	for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
 		if(i + 1 == n) /* remainder */
-			tileresize(c, tx, y, tw - 2 * c->bw, (ty + th) - y - 2 * c->bw);
+			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
 		else
-			tileresize(c, tx, y, tw - 2 * c->bw, h - 2 * c->bw);
+			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
 		if(h != th)
 			y = c->y + c->h + 2 * c->bw;
 	}
gt; 2013-12-18 23:06:43 +0000 Replaced old mock_xmpp' href='/danisanti/profani-tty/commit/tests/test_cmd_rooms.c?id=b27c5d0f5baa7161231642b14106db2e96065f95'>b27c5d0f ^
8685e78c ^
2490f5b4 ^
71577c1f ^
447d2358 ^
71577c1f ^
3e3786eb ^
5c65599e ^
7db1bcee ^

d56f6dc3 ^
5c65599e ^
2215a379 ^
447d2358 ^
































5c65599e ^
c4412fe8 ^



b6536ddf ^
c4412fe8 ^









447d2358 ^
7db1bcee ^



00a475cf ^
7db1bcee ^
5c65599e ^
2215a379 ^
71577c1f ^
3e3786eb ^
71577c1f ^



bf347ab9 ^
447d2358 ^

5c65599e ^
447d2358 ^
7db1bcee ^
00a475cf ^
7db1bcee ^
5c65599e ^
2215a379 ^
447d2358 ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104




                   
                   
                 

                      
 
                  
                       
 
                            
                             
 
                                                                    
 
                                                    
 

                                                      
                                                         
 
                                                   
































                                                             
                             



                                                       
                                  









                                                         
 



                                                                
 
                                                                              
 
                                                   
 
                        



               
                                                 

                                                    
                                          
 
                                                                
 
                                                                          
 
                                                   




                        
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#include "xmpp/xmpp.h"

#include "ui/ui.h"
#include "ui/stub_ui.h"

#include "config/accounts.h"
#include "command/commands.h"

static void test_with_connection_status(jabber_conn_status_t status)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));

    will_return(jabber_get_connection_status, status);

    expect_cons_show("You are not currently connected.");

    gboolean result = cmd_rooms(NULL, NULL, *help);
    assert_true(result);

    free(help);
}

void cmd_rooms_shows_message_when_disconnected(void **state)
{
    test_with_connection_status(JABBER_DISCONNECTED);
}

void cmd_rooms_shows_message_when_disconnecting(void **state)
{
    test_with_connection_status(JABBER_DISCONNECTING);
}

void cmd_rooms_shows_message_when_connecting(void **state)
{
    test_with_connection_status(JABBER_CONNECTING);
}

void cmd_rooms_shows_message_when_started(void **state)
{
    test_with_connection_status(JABBER_STARTED);
}

void cmd_rooms_shows_message_when_undefined(void **state)
{
    test_with_connection_status(JABBER_UNDEFINED);
}

void cmd_rooms_uses_account_default_when_no_arg(void **state)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { NULL };
    ProfAccount *account = malloc(sizeof(ProfAccount));
    account->name = NULL;
    account->jid = NULL;
    account->password = NULL;
    account->eval_password = NULL;
    account->resource = NULL;
    account->server = NULL;
    account->last_presence = NULL;
    account->login_presence = NULL;
    account->muc_nick = NULL;
    account->otr_policy = NULL;
    account->otr_manual = NULL;
    account->otr_opportunistic = NULL;
    account->otr_always = NULL;
    account->muc_service = strdup("default_conf_server");

    will_return(jabber_get_connection_status, JABBER_CONNECTED);
    will_return(jabber_get_account_name, "account_name");
    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_string(iq_room_list_request, conferencejid, "default_conf_server");

    gboolean result = cmd_rooms(NULL, args, *help);

    assert_true(result);

    free(help);
}

void cmd_rooms_arg_used_when_passed(void **state)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "conf_server_arg" };

    will_return(jabber_get_connection_status, JABBER_CONNECTED);

    expect_string(iq_room_list_request, conferencejid, "conf_server_arg");

    gboolean result = cmd_rooms(NULL, args, *help);

    assert_true(result);

    free(help);
}