3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 xfwm4 - (c) 2002-2007 Olivier Fourdan
18 based on a patch from Joshua Blanton <jblanton@irg.cs.ohiou.edu>
29 #include <libxfce4util/libxfce4util.h>
36 poswinCreate (GdkScreen
*gscr
)
41 poswin
= g_new (Poswin
, 1);
43 poswin
->window
= gtk_window_new (GTK_WINDOW_POPUP
);
44 gtk_window_set_screen (GTK_WINDOW (poswin
->window
), gscr
);
45 gtk_container_set_border_width (GTK_CONTAINER (poswin
->window
), 0);
46 gtk_window_set_resizable (GTK_WINDOW (poswin
->window
), TRUE
);
48 frame
= gtk_frame_new (NULL
);
49 gtk_frame_set_shadow_type (GTK_FRAME (frame
), GTK_SHADOW_OUT
);
50 gtk_container_set_border_width (GTK_CONTAINER (frame
), 0);
51 gtk_container_add (GTK_CONTAINER (poswin
->window
), frame
);
53 poswin
->label
= gtk_label_new ("");
54 gtk_misc_set_alignment (GTK_MISC (poswin
->label
), 0.5, 0.5);
55 gtk_misc_set_padding (GTK_MISC (poswin
->label
), 3, 3);
56 gtk_widget_show (poswin
->label
);
57 gtk_container_add(GTK_CONTAINER(frame
), poswin
->label
);
58 gtk_widget_show_all (frame
);
64 poswinSetPosition (Poswin
* poswin
, Client
*c
)
66 /* 32 is enough for (NNNNNxNNNNN) @ (-NNNNN,-NNNNN) */
68 gint x
, y
, px
, py
, pw
, ph
;
71 g_return_if_fail (poswin
!= NULL
);
72 g_return_if_fail (c
!= NULL
);
73 g_return_if_fail (c
->size
->width_inc
!= 0);
74 g_return_if_fail (c
->size
->height_inc
!= 0);
79 wsize
= (c
->width
- c
->size
->base_width
) / c
->size
->width_inc
;
80 hsize
= (c
->height
- c
->size
->base_height
) / c
->size
->height_inc
;
92 g_snprintf (label
, 32, "(%dx%d) @ (%i,%i)", wsize
, hsize
, x
, y
);
94 g_snprintf (label
, 32, "(%dx%d)", wsize
, hsize
);
96 gtk_label_set_text (GTK_LABEL (poswin
->label
), label
);
97 gtk_widget_queue_draw (poswin
->window
);
98 gtk_window_get_size (GTK_WINDOW (poswin
->window
), &pw
, &ph
);
99 px
= x
+ (frameWidth (c
) - pw
) / 2;
100 py
= y
+ (frameHeight (c
) - ph
) / 2;
101 if (GTK_WIDGET_REALIZED (poswin
->window
))
103 gdk_window_move_resize (poswin
->window
->window
, px
, py
, pw
, ph
);
107 gtk_window_move (GTK_WINDOW (poswin
->window
), px
, py
);
112 poswinDestroy (Poswin
* poswin
)
114 g_return_if_fail (poswin
!= NULL
);
116 gtk_widget_destroy (poswin
->window
);
120 poswinShow (Poswin
* poswin
)
122 g_return_if_fail (poswin
!= NULL
);
124 gtk_widget_show (poswin
->window
);
128 poswinHide(Poswin
* poswin
)
130 g_return_if_fail (poswin
!= NULL
);
132 gtk_widget_hide (poswin
->window
);