Mercurial > pidgin
comparison finch/libgnt/gntwm.c @ 21454:d78e440584e0
Add maximize flags for windows.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 12 Nov 2007 17:13:44 +0000 |
parents | add12afc3140 |
children | a4860971f861 |
comparison
equal
deleted
inserted
replaced
21453:93e69f29bc5f | 21454:d78e440584e0 |
---|---|
222 doupdate(); | 222 doupdate(); |
223 return TRUE; | 223 return TRUE; |
224 } | 224 } |
225 | 225 |
226 static gboolean | 226 static gboolean |
227 sanitize_position(GntWidget *widget, int *x, int *y) | 227 sanitize_position(GntWidget *widget, int *x, int *y, gboolean m) |
228 { | 228 { |
229 int X_MAX = getmaxx(stdscr); | 229 int X_MAX = getmaxx(stdscr); |
230 int Y_MAX = getmaxy(stdscr) - 1; | 230 int Y_MAX = getmaxy(stdscr) - 1; |
231 int w, h; | 231 int w, h; |
232 int nx, ny; | 232 int nx, ny; |
233 gboolean changed = FALSE; | 233 gboolean changed = FALSE; |
234 GntWindowFlags flags = GNT_IS_WINDOW(widget) ? | |
235 gnt_window_get_maximize(GNT_WINDOW(widget)) : 0; | |
234 | 236 |
235 gnt_widget_get_size(widget, &w, &h); | 237 gnt_widget_get_size(widget, &w, &h); |
236 if (x) { | 238 if (x) { |
237 if (*x + w > X_MAX) { | 239 if (m && (flags & GNT_WINDOW_MAXIMIZE_X) && *x != 0) { |
240 *x = 0; | |
241 changed = TRUE; | |
242 } else if (*x + w > X_MAX) { | |
238 nx = MAX(0, X_MAX - w); | 243 nx = MAX(0, X_MAX - w); |
239 if (nx != *x) { | 244 if (nx != *x) { |
240 *x = nx; | 245 *x = nx; |
241 changed = TRUE; | 246 changed = TRUE; |
242 } | 247 } |
243 } | 248 } |
244 } | 249 } |
245 if (y) { | 250 if (y) { |
246 if (*y + h > Y_MAX) { | 251 if (m && (flags & GNT_WINDOW_MAXIMIZE_Y) && *y != 0) { |
252 *y = 0; | |
253 changed = TRUE; | |
254 } else if (*y + h > Y_MAX) { | |
247 ny = MAX(0, Y_MAX - h); | 255 ny = MAX(0, Y_MAX - h); |
248 if (ny != *y) { | 256 if (ny != *y) { |
249 *y = ny; | 257 *y = ny; |
250 changed = TRUE; | 258 changed = TRUE; |
251 } | 259 } |
253 } | 261 } |
254 return changed; | 262 return changed; |
255 } | 263 } |
256 | 264 |
257 static void | 265 static void |
258 refresh_node(GntWidget *widget, GntNode *node, gpointer null) | 266 refresh_node(GntWidget *widget, GntNode *node, gpointer m) |
259 { | 267 { |
260 int x, y, w, h; | 268 int x, y, w, h; |
261 int nw, nh; | 269 int nw, nh; |
262 | 270 |
263 int X_MAX = getmaxx(stdscr); | 271 int X_MAX = getmaxx(stdscr); |
264 int Y_MAX = getmaxy(stdscr) - 1; | 272 int Y_MAX = getmaxy(stdscr) - 1; |
265 | 273 |
274 GntWindowFlags flags = 0; | |
275 | |
276 if (m && GNT_IS_WINDOW(widget)) { | |
277 flags = gnt_window_get_maximize(GNT_WINDOW(widget)); | |
278 } | |
279 | |
266 gnt_widget_get_position(widget, &x, &y); | 280 gnt_widget_get_position(widget, &x, &y); |
267 gnt_widget_get_size(widget, &w, &h); | 281 gnt_widget_get_size(widget, &w, &h); |
268 | 282 |
269 if (sanitize_position(widget, &x, &y)) | 283 if (sanitize_position(widget, &x, &y, !!m)) |
270 gnt_screen_move_widget(widget, x, y); | 284 gnt_screen_move_widget(widget, x, y); |
271 | 285 |
272 nw = MIN(w, X_MAX); | 286 if (flags & GNT_WINDOW_MAXIMIZE_X) |
273 nh = MIN(h, Y_MAX); | 287 nw = X_MAX; |
288 else | |
289 nw = MIN(w, X_MAX); | |
290 | |
291 if (flags & GNT_WINDOW_MAXIMIZE_Y) | |
292 nh = Y_MAX; | |
293 else | |
294 nh = MIN(h, Y_MAX); | |
295 | |
274 if (nw != w || nh != h) | 296 if (nw != w || nh != h) |
275 gnt_screen_resize_widget(widget, nw, nh); | 297 gnt_screen_resize_widget(widget, nw, nh); |
276 } | 298 } |
277 | 299 |
278 static void | 300 static void |
1605 node->me = widget; | 1627 node->me = widget; |
1606 node->scroll = 0; | 1628 node->scroll = 0; |
1607 | 1629 |
1608 g_hash_table_replace(wm->nodes, widget, node); | 1630 g_hash_table_replace(wm->nodes, widget, node); |
1609 | 1631 |
1610 refresh_node(widget, node, NULL); | 1632 refresh_node(widget, node, GINT_TO_POINTER(TRUE)); |
1611 | 1633 |
1612 transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT); | 1634 transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT); |
1613 | 1635 |
1614 #if 1 | 1636 #if 1 |
1615 { | 1637 { |
1680 | 1702 |
1681 if (GNT_IS_BOX(widget)) { | 1703 if (GNT_IS_BOX(widget)) { |
1682 const char *title = GNT_BOX(widget)->title; | 1704 const char *title = GNT_BOX(widget)->title; |
1683 GntPosition *p = NULL; | 1705 GntPosition *p = NULL; |
1684 if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) { | 1706 if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) { |
1685 sanitize_position(widget, &p->x, &p->y); | 1707 sanitize_position(widget, &p->x, &p->y, TRUE); |
1686 gnt_widget_set_position(widget, p->x, p->y); | 1708 gnt_widget_set_position(widget, p->x, p->y); |
1687 mvwin(widget->window, p->y, p->x); | 1709 mvwin(widget->window, p->y, p->x); |
1688 } | 1710 } |
1689 } | 1711 } |
1690 | 1712 |