| File: | tests/ctkoffscreenbox.c |
| Warning: | line 603, column 7 Value stored to 'start_y' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * ctkoffscreenbox.c |
| 3 | */ |
| 4 | |
| 5 | #include "config.h" |
| 6 | |
| 7 | #include <math.h> |
| 8 | #include <ctk/ctk.h> |
| 9 | |
| 10 | #include "ctkoffscreenbox.h" |
| 11 | |
| 12 | static void ctk_offscreen_box_realize (CtkWidget *widget); |
| 13 | static void ctk_offscreen_box_unrealize (CtkWidget *widget); |
| 14 | static void ctk_offscreen_box_get_preferred_width (CtkWidget *widget, |
| 15 | gint *minimum, |
| 16 | gint *natural); |
| 17 | static void ctk_offscreen_box_get_preferred_height (CtkWidget *widget, |
| 18 | gint *minimum, |
| 19 | gint *natural); |
| 20 | static void ctk_offscreen_box_size_allocate (CtkWidget *widget, |
| 21 | CtkAllocation *allocation); |
| 22 | static gboolean ctk_offscreen_box_damage (CtkWidget *widget, |
| 23 | CdkEventExpose *event); |
| 24 | static gboolean ctk_offscreen_box_draw (CtkWidget *widget, |
| 25 | cairo_t *cr); |
| 26 | |
| 27 | static void ctk_offscreen_box_add (CtkContainer *container, |
| 28 | CtkWidget *child); |
| 29 | static void ctk_offscreen_box_remove (CtkContainer *container, |
| 30 | CtkWidget *widget); |
| 31 | static void ctk_offscreen_box_forall (CtkContainer *container, |
| 32 | gboolean include_internals, |
| 33 | CtkCallback callback, |
| 34 | gpointer callback_data); |
| 35 | static GType ctk_offscreen_box_child_type (CtkContainer *container); |
| 36 | |
| 37 | #define CHILD1_SIZE_SCALE1.0 1.0 |
| 38 | #define CHILD2_SIZE_SCALE1.0 1.0 |
| 39 | |
| 40 | G_DEFINE_TYPE (CtkOffscreenBox, ctk_offscreen_box, CTK_TYPE_CONTAINER)static void ctk_offscreen_box_init (CtkOffscreenBox *self); static void ctk_offscreen_box_class_init (CtkOffscreenBoxClass *klass ); static GType ctk_offscreen_box_get_type_once (void); static gpointer ctk_offscreen_box_parent_class = ((void*)0); static gint CtkOffscreenBox_private_offset; static void ctk_offscreen_box_class_intern_init (gpointer klass) { ctk_offscreen_box_parent_class = g_type_class_peek_parent (klass); if (CtkOffscreenBox_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkOffscreenBox_private_offset); ctk_offscreen_box_class_init ((CtkOffscreenBoxClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_offscreen_box_get_instance_private (CtkOffscreenBox *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkOffscreenBox_private_offset)))); } GType ctk_offscreen_box_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_offscreen_box_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_offscreen_box_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkOffscreenBox" ), sizeof (CtkOffscreenBoxClass), (GClassInitFunc)(void (*)(void )) ctk_offscreen_box_class_intern_init, sizeof (CtkOffscreenBox ), (GInstanceInitFunc)(void (*)(void)) ctk_offscreen_box_init , (GTypeFlags) 0); { {{};} } return g_define_type_id; }; |
| 41 | |
| 42 | static void |
| 43 | to_child_2 (CtkOffscreenBox *offscreen_box, |
| 44 | double widget_x, double widget_y, |
| 45 | double *x_out, double *y_out) |
| 46 | { |
| 47 | CtkAllocation child_area; |
| 48 | double x, y, xr, yr; |
| 49 | double cos_angle, sin_angle; |
| 50 | |
| 51 | x = widget_x; |
| 52 | y = widget_y; |
| 53 | |
| 54 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 55 | { |
| 56 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
| 57 | y -= child_area.height; |
| 58 | } |
| 59 | |
| 60 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
| 61 | |
| 62 | x -= child_area.width / 2; |
| 63 | y -= child_area.height / 2; |
| 64 | |
| 65 | cos_angle = cos (-offscreen_box->angle); |
| 66 | sin_angle = sin (-offscreen_box->angle); |
| 67 | |
| 68 | xr = x * cos_angle - y * sin_angle; |
| 69 | yr = x * sin_angle + y * cos_angle; |
| 70 | x = xr; |
| 71 | y = yr; |
| 72 | |
| 73 | x += child_area.width / 2; |
| 74 | y += child_area.height / 2; |
| 75 | |
| 76 | *x_out = x; |
| 77 | *y_out = y; |
| 78 | } |
| 79 | |
| 80 | static void |
| 81 | to_parent_2 (CtkOffscreenBox *offscreen_box, |
| 82 | double offscreen_x, double offscreen_y, |
| 83 | double *x_out, double *y_out) |
| 84 | { |
| 85 | CtkAllocation child_area; |
| 86 | double x, y, xr, yr; |
| 87 | double cos_angle, sin_angle; |
| 88 | |
| 89 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
| 90 | |
| 91 | x = offscreen_x; |
| 92 | y = offscreen_y; |
| 93 | |
| 94 | x -= child_area.width / 2; |
| 95 | y -= child_area.height / 2; |
| 96 | |
| 97 | cos_angle = cos (offscreen_box->angle); |
| 98 | sin_angle = sin (offscreen_box->angle); |
| 99 | |
| 100 | xr = x * cos_angle - y * sin_angle; |
| 101 | yr = x * sin_angle + y * cos_angle; |
| 102 | x = xr; |
| 103 | y = yr; |
| 104 | |
| 105 | x += child_area.width / 2; |
| 106 | y += child_area.height / 2; |
| 107 | |
| 108 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 109 | { |
| 110 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
| 111 | y += child_area.height; |
| 112 | } |
| 113 | |
| 114 | *x_out = x; |
| 115 | *y_out = y; |
| 116 | } |
| 117 | |
| 118 | static void |
| 119 | ctk_offscreen_box_class_init (CtkOffscreenBoxClass *klass) |
| 120 | { |
| 121 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); |
| 122 | CtkContainerClass *container_class = CTK_CONTAINER_CLASS (klass)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_container_get_type ())))))); |
| 123 | |
| 124 | widget_class->realize = ctk_offscreen_box_realize; |
| 125 | widget_class->unrealize = ctk_offscreen_box_unrealize; |
| 126 | widget_class->get_preferred_width = ctk_offscreen_box_get_preferred_width; |
| 127 | widget_class->get_preferred_height = ctk_offscreen_box_get_preferred_height; |
| 128 | widget_class->size_allocate = ctk_offscreen_box_size_allocate; |
| 129 | widget_class->draw = ctk_offscreen_box_draw; |
| 130 | |
| 131 | g_signal_override_class_closure (g_signal_lookup ("damage-event", CTK_TYPE_WIDGET(ctk_widget_get_type ())), |
| 132 | CTK_TYPE_OFFSCREEN_BOX(ctk_offscreen_box_get_type ()), |
| 133 | g_cclosure_new (G_CALLBACK (ctk_offscreen_box_damage)((GCallback) (ctk_offscreen_box_damage)), |
| 134 | NULL((void*)0), NULL((void*)0))); |
| 135 | |
| 136 | container_class->add = ctk_offscreen_box_add; |
| 137 | container_class->remove = ctk_offscreen_box_remove; |
| 138 | container_class->forall = ctk_offscreen_box_forall; |
| 139 | container_class->child_type = ctk_offscreen_box_child_type; |
| 140 | } |
| 141 | |
| 142 | static void |
| 143 | ctk_offscreen_box_init (CtkOffscreenBox *offscreen_box) |
| 144 | { |
| 145 | ctk_widget_set_has_window (CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ())))))), TRUE(!(0))); |
| 146 | } |
| 147 | |
| 148 | CtkWidget * |
| 149 | ctk_offscreen_box_new (void) |
| 150 | { |
| 151 | return g_object_new (CTK_TYPE_OFFSCREEN_BOX(ctk_offscreen_box_get_type ()), NULL((void*)0)); |
| 152 | } |
| 153 | |
| 154 | static CdkWindow * |
| 155 | pick_offscreen_child (CdkWindow *offscreen_window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 156 | double widget_x, |
| 157 | double widget_y, |
| 158 | CtkOffscreenBox *offscreen_box) |
| 159 | { |
| 160 | CtkAllocation child_area; |
| 161 | double x, y; |
| 162 | |
| 163 | /* First check for child 2 */ |
| 164 | if (offscreen_box->child2 && |
| 165 | ctk_widget_get_visible (offscreen_box->child2)) |
| 166 | { |
| 167 | to_child_2 (offscreen_box, |
| 168 | widget_x, widget_y, |
| 169 | &x, &y); |
| 170 | |
| 171 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
| 172 | |
| 173 | if (x >= 0 && x < child_area.width && |
| 174 | y >= 0 && y < child_area.height) |
| 175 | return offscreen_box->offscreen_window2; |
| 176 | } |
| 177 | |
| 178 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 179 | { |
| 180 | x = widget_x; |
| 181 | y = widget_y; |
| 182 | |
| 183 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
| 184 | |
| 185 | if (x >= 0 && x < child_area.width && |
| 186 | y >= 0 && y < child_area.height) |
| 187 | return offscreen_box->offscreen_window1; |
| 188 | } |
| 189 | |
| 190 | return NULL((void*)0); |
| 191 | } |
| 192 | |
| 193 | static void |
| 194 | offscreen_window_to_parent1 (CdkWindow *offscreen_window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 195 | double offscreen_x, |
| 196 | double offscreen_y, |
| 197 | double *parent_x, |
| 198 | double *parent_y, |
| 199 | CtkOffscreenBox *offscreen_box G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 200 | { |
| 201 | *parent_x = offscreen_x; |
| 202 | *parent_y = offscreen_y; |
| 203 | } |
| 204 | |
| 205 | static void |
| 206 | offscreen_window_from_parent1 (CdkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 207 | double parent_x, |
| 208 | double parent_y, |
| 209 | double *offscreen_x, |
| 210 | double *offscreen_y, |
| 211 | CtkOffscreenBox *offscreen_box G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 212 | { |
| 213 | *offscreen_x = parent_x; |
| 214 | *offscreen_y = parent_y; |
| 215 | } |
| 216 | |
| 217 | static void |
| 218 | offscreen_window_to_parent2 (CdkWindow *offscreen_window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 219 | double offscreen_x, |
| 220 | double offscreen_y, |
| 221 | double *parent_x, |
| 222 | double *parent_y, |
| 223 | CtkOffscreenBox *offscreen_box) |
| 224 | { |
| 225 | to_parent_2 (offscreen_box, |
| 226 | offscreen_x, offscreen_y, |
| 227 | parent_x, parent_y); |
| 228 | } |
| 229 | |
| 230 | static void |
| 231 | offscreen_window_from_parent2 (CdkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 232 | double parent_x, |
| 233 | double parent_y, |
| 234 | double *offscreen_x, |
| 235 | double *offscreen_y, |
| 236 | CtkOffscreenBox *offscreen_box) |
| 237 | { |
| 238 | to_child_2 (offscreen_box, |
| 239 | parent_x, parent_y, |
| 240 | offscreen_x, offscreen_y); |
| 241 | } |
| 242 | |
| 243 | static cairo_surface_t * |
| 244 | cdk_offscreen_box_create_alpha_image_surface (CdkWindow *offscreen G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 245 | gint width, |
| 246 | gint height) |
| 247 | { |
| 248 | return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); |
| 249 | } |
| 250 | |
| 251 | static void |
| 252 | ctk_offscreen_box_realize (CtkWidget *widget) |
| 253 | { |
| 254 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
| 255 | CtkAllocation allocation, child_area; |
| 256 | CdkWindow *window; |
| 257 | CdkWindowAttr attributes; |
| 258 | gint attributes_mask; |
| 259 | guint border_width; |
| 260 | CtkRequisition child_requisition; |
| 261 | int start_y = 0; |
| 262 | |
| 263 | ctk_widget_set_realized (widget, TRUE(!(0))); |
| 264 | |
| 265 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
| 266 | |
| 267 | ctk_widget_get_allocation (widget, &allocation); |
| 268 | |
| 269 | attributes.x = allocation.x + border_width; |
| 270 | attributes.y = allocation.y + border_width; |
| 271 | attributes.width = allocation.width - 2 * border_width; |
| 272 | attributes.height = allocation.height - 2 * border_width; |
| 273 | attributes.window_type = CDK_WINDOW_CHILD; |
| 274 | attributes.event_mask = ctk_widget_get_events (widget) |
| 275 | | CDK_EXPOSURE_MASK |
| 276 | | CDK_POINTER_MOTION_MASK |
| 277 | | CDK_BUTTON_PRESS_MASK |
| 278 | | CDK_BUTTON_RELEASE_MASK |
| 279 | | CDK_SCROLL_MASK |
| 280 | | CDK_ENTER_NOTIFY_MASK |
| 281 | | CDK_LEAVE_NOTIFY_MASK; |
| 282 | |
| 283 | attributes.visual = ctk_widget_get_visual (widget); |
| 284 | attributes.wclass = CDK_INPUT_OUTPUT; |
| 285 | |
| 286 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; |
| 287 | |
| 288 | window = cdk_window_new (ctk_widget_get_parent_window (widget), |
| 289 | &attributes, attributes_mask); |
| 290 | ctk_widget_set_window (widget, window); |
| 291 | cdk_window_set_user_data (window, widget); |
| 292 | |
| 293 | g_signal_connect (window, "pick-embedded-child",g_signal_connect_data ((window), ("pick-embedded-child"), ((( GCallback) (pick_offscreen_child))), (offscreen_box), ((void* )0), (GConnectFlags) 0) |
| 294 | G_CALLBACK (pick_offscreen_child), offscreen_box)g_signal_connect_data ((window), ("pick-embedded-child"), ((( GCallback) (pick_offscreen_child))), (offscreen_box), ((void* )0), (GConnectFlags) 0); |
| 295 | |
| 296 | attributes.window_type = CDK_WINDOW_OFFSCREEN; |
| 297 | |
| 298 | /* Child 1 */ |
| 299 | attributes.x = attributes.y = 0; |
| 300 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 301 | { |
| 302 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
| 303 | |
| 304 | attributes.width = child_area.width; |
| 305 | attributes.height = child_area.height; |
| 306 | start_y += child_area.height; |
| 307 | } |
| 308 | offscreen_box->offscreen_window1 = cdk_window_new (cdk_screen_get_root_window (ctk_widget_get_screen (widget)), |
| 309 | &attributes, attributes_mask); |
| 310 | cdk_window_set_user_data (offscreen_box->offscreen_window1, widget); |
| 311 | if (offscreen_box->child1) |
| 312 | ctk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1); |
| 313 | |
| 314 | cdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1, |
| 315 | window); |
| 316 | |
| 317 | g_signal_connect (offscreen_box->offscreen_window1, "to-embedder",g_signal_connect_data ((offscreen_box->offscreen_window1), ("to-embedder"), (((GCallback) (offscreen_window_to_parent1) )), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
| 318 | G_CALLBACK (offscreen_window_to_parent1), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window1), ("to-embedder"), (((GCallback) (offscreen_window_to_parent1) )), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
| 319 | g_signal_connect (offscreen_box->offscreen_window1, "from-embedder",g_signal_connect_data ((offscreen_box->offscreen_window1), ("from-embedder"), (((GCallback) (offscreen_window_from_parent1 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
| 320 | G_CALLBACK (offscreen_window_from_parent1), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window1), ("from-embedder"), (((GCallback) (offscreen_window_from_parent1 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
| 321 | |
| 322 | /* Child 2 */ |
| 323 | attributes.y = start_y; |
| 324 | child_requisition.width = child_requisition.height = 0; |
| 325 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
| 326 | { |
| 327 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
| 328 | |
| 329 | attributes.width = child_area.width; |
| 330 | attributes.height = child_area.height; |
| 331 | } |
| 332 | offscreen_box->offscreen_window2 = cdk_window_new (cdk_screen_get_root_window (ctk_widget_get_screen (widget)), |
| 333 | &attributes, attributes_mask); |
| 334 | cdk_window_set_user_data (offscreen_box->offscreen_window2, widget); |
| 335 | if (offscreen_box->child2) |
| 336 | ctk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2); |
| 337 | cdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2, |
| 338 | window); |
| 339 | |
| 340 | g_signal_connect (offscreen_box->offscreen_window2, "create-surface",g_signal_connect_data ((offscreen_box->offscreen_window2), ("create-surface"), (((GCallback) (cdk_offscreen_box_create_alpha_image_surface ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
| 341 | G_CALLBACK (cdk_offscreen_box_create_alpha_image_surface),g_signal_connect_data ((offscreen_box->offscreen_window2), ("create-surface"), (((GCallback) (cdk_offscreen_box_create_alpha_image_surface ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
| 342 | offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window2), ("create-surface"), (((GCallback) (cdk_offscreen_box_create_alpha_image_surface ))), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
| 343 | g_signal_connect (offscreen_box->offscreen_window2, "to-embedder",g_signal_connect_data ((offscreen_box->offscreen_window2), ("to-embedder"), (((GCallback) (offscreen_window_to_parent2) )), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
| 344 | G_CALLBACK (offscreen_window_to_parent2), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window2), ("to-embedder"), (((GCallback) (offscreen_window_to_parent2) )), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
| 345 | g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",g_signal_connect_data ((offscreen_box->offscreen_window2), ("from-embedder"), (((GCallback) (offscreen_window_from_parent2 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
| 346 | G_CALLBACK (offscreen_window_from_parent2), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window2), ("from-embedder"), (((GCallback) (offscreen_window_from_parent2 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
| 347 | |
| 348 | cdk_window_show (offscreen_box->offscreen_window1); |
| 349 | cdk_window_show (offscreen_box->offscreen_window2); |
| 350 | } |
| 351 | |
| 352 | static void |
| 353 | ctk_offscreen_box_unrealize (CtkWidget *widget) |
| 354 | { |
| 355 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
| 356 | |
| 357 | cdk_window_set_user_data (offscreen_box->offscreen_window1, NULL((void*)0)); |
| 358 | cdk_window_destroy (offscreen_box->offscreen_window1); |
| 359 | offscreen_box->offscreen_window1 = NULL((void*)0); |
| 360 | |
| 361 | cdk_window_set_user_data (offscreen_box->offscreen_window2, NULL((void*)0)); |
| 362 | cdk_window_destroy (offscreen_box->offscreen_window2); |
| 363 | offscreen_box->offscreen_window2 = NULL((void*)0); |
| 364 | |
| 365 | CTK_WIDGET_CLASS (ctk_offscreen_box_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_offscreen_box_parent_class)), ((ctk_widget_get_type ( )))))))->unrealize (widget); |
| 366 | } |
| 367 | |
| 368 | static GType |
| 369 | ctk_offscreen_box_child_type (CtkContainer *container) |
| 370 | { |
| 371 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
| 372 | |
| 373 | if (offscreen_box->child1 && offscreen_box->child2) |
| 374 | return G_TYPE_NONE((GType) ((1) << (2))); |
| 375 | |
| 376 | return CTK_TYPE_WIDGET(ctk_widget_get_type ()); |
| 377 | } |
| 378 | |
| 379 | static void |
| 380 | ctk_offscreen_box_add (CtkContainer *container, |
| 381 | CtkWidget *widget) |
| 382 | { |
| 383 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
| 384 | |
| 385 | if (!offscreen_box->child1) |
| 386 | ctk_offscreen_box_add1 (offscreen_box, widget); |
| 387 | else if (!offscreen_box->child2) |
| 388 | ctk_offscreen_box_add2 (offscreen_box, widget); |
| 389 | else |
| 390 | g_warning ("CtkOffscreenBox cannot have more than 2 children"); |
| 391 | } |
| 392 | |
| 393 | void |
| 394 | ctk_offscreen_box_add1 (CtkOffscreenBox *offscreen_box, |
| 395 | CtkWidget *child) |
| 396 | { |
| 397 | g_return_if_fail (CTK_IS_OFFSCREEN_BOX (offscreen_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((offscreen_box)); GType __t = ((ctk_offscreen_box_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_OFFSCREEN_BOX (offscreen_box)" ); return; } } while (0); |
| 398 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (child)"); return; } } while (0 ); |
| 399 | |
| 400 | if (offscreen_box->child1 == NULL((void*)0)) |
| 401 | { |
| 402 | ctk_widget_set_parent_window (child, offscreen_box->offscreen_window1); |
| 403 | ctk_widget_set_parent (child, CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ()))))))); |
| 404 | offscreen_box->child1 = child; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | void |
| 409 | ctk_offscreen_box_add2 (CtkOffscreenBox *offscreen_box, |
| 410 | CtkWidget *child) |
| 411 | { |
| 412 | g_return_if_fail (CTK_IS_OFFSCREEN_BOX (offscreen_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((offscreen_box)); GType __t = ((ctk_offscreen_box_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_OFFSCREEN_BOX (offscreen_box)" ); return; } } while (0); |
| 413 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (child)"); return; } } while (0 ); |
| 414 | |
| 415 | if (offscreen_box->child2 == NULL((void*)0)) |
| 416 | { |
| 417 | ctk_widget_set_parent_window (child, offscreen_box->offscreen_window2); |
| 418 | ctk_widget_set_parent (child, CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ()))))))); |
| 419 | offscreen_box->child2 = child; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | static void |
| 424 | ctk_offscreen_box_remove (CtkContainer *container, |
| 425 | CtkWidget *widget) |
| 426 | { |
| 427 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
| 428 | gboolean was_visible; |
| 429 | |
| 430 | was_visible = ctk_widget_get_visible (widget); |
| 431 | |
| 432 | if (offscreen_box->child1 == widget) |
| 433 | { |
| 434 | ctk_widget_unparent (widget); |
| 435 | |
| 436 | offscreen_box->child1 = NULL((void*)0); |
| 437 | |
| 438 | if (was_visible && ctk_widget_get_visible (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) |
| 439 | ctk_widget_queue_resize (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))); |
| 440 | } |
| 441 | else if (offscreen_box->child2 == widget) |
| 442 | { |
| 443 | ctk_widget_unparent (widget); |
| 444 | |
| 445 | offscreen_box->child2 = NULL((void*)0); |
| 446 | |
| 447 | if (was_visible && ctk_widget_get_visible (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) |
| 448 | ctk_widget_queue_resize (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | static void |
| 453 | ctk_offscreen_box_forall (CtkContainer *container, |
| 454 | gboolean include_internals G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 455 | CtkCallback callback, |
| 456 | gpointer callback_data) |
| 457 | { |
| 458 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
| 459 | |
| 460 | g_return_if_fail (callback != NULL)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "callback != NULL" ); return; } } while (0); |
| 461 | |
| 462 | if (offscreen_box->child1) |
| 463 | (*callback) (offscreen_box->child1, callback_data); |
| 464 | if (offscreen_box->child2) |
| 465 | (*callback) (offscreen_box->child2, callback_data); |
| 466 | } |
| 467 | |
| 468 | void |
| 469 | ctk_offscreen_box_set_angle (CtkOffscreenBox *offscreen_box, |
| 470 | gdouble angle) |
| 471 | { |
| 472 | g_return_if_fail (CTK_IS_OFFSCREEN_BOX (offscreen_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((offscreen_box)); GType __t = ((ctk_offscreen_box_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_OFFSCREEN_BOX (offscreen_box)" ); return; } } while (0); |
| 473 | |
| 474 | offscreen_box->angle = angle; |
| 475 | ctk_widget_queue_draw (CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ()))))))); |
| 476 | |
| 477 | /* TODO: Really needs to resent pointer events if over the rotated window */ |
| 478 | } |
| 479 | |
| 480 | |
| 481 | static void |
| 482 | ctk_offscreen_box_size_request (CtkWidget *widget, |
| 483 | CtkRequisition *requisition) |
| 484 | { |
| 485 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
| 486 | int w, h; |
| 487 | guint border_width; |
| 488 | |
| 489 | w = 0; |
| 490 | h = 0; |
| 491 | |
| 492 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 493 | { |
| 494 | CtkRequisition child_requisition; |
| 495 | |
| 496 | ctk_widget_get_preferred_size ( (offscreen_box->child1), |
| 497 | &child_requisition, NULL((void*)0)); |
| 498 | |
| 499 | w = MAX (w, CHILD1_SIZE_SCALE * child_requisition.width)(((w) > (1.0 * child_requisition.width)) ? (w) : (1.0 * child_requisition .width)); |
| 500 | h += CHILD1_SIZE_SCALE1.0 * child_requisition.height; |
| 501 | } |
| 502 | |
| 503 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
| 504 | { |
| 505 | CtkRequisition child_requisition; |
| 506 | |
| 507 | ctk_widget_get_preferred_size ( (offscreen_box->child2), |
| 508 | &child_requisition, NULL((void*)0)); |
| 509 | |
| 510 | w = MAX (w, CHILD2_SIZE_SCALE * child_requisition.width)(((w) > (1.0 * child_requisition.width)) ? (w) : (1.0 * child_requisition .width)); |
| 511 | h += CHILD2_SIZE_SCALE1.0 * child_requisition.height; |
| 512 | } |
| 513 | |
| 514 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
| 515 | requisition->width = border_width * 2 + w; |
| 516 | requisition->height = border_width * 2 + h; |
| 517 | } |
| 518 | |
| 519 | static void |
| 520 | ctk_offscreen_box_get_preferred_width (CtkWidget *widget, |
| 521 | gint *minimum, |
| 522 | gint *natural) |
| 523 | { |
| 524 | CtkRequisition requisition; |
| 525 | |
| 526 | ctk_offscreen_box_size_request (widget, &requisition); |
| 527 | |
| 528 | *minimum = *natural = requisition.width; |
| 529 | } |
| 530 | |
| 531 | static void |
| 532 | ctk_offscreen_box_get_preferred_height (CtkWidget *widget, |
| 533 | gint *minimum, |
| 534 | gint *natural) |
| 535 | { |
| 536 | CtkRequisition requisition; |
| 537 | |
| 538 | ctk_offscreen_box_size_request (widget, &requisition); |
| 539 | |
| 540 | *minimum = *natural = requisition.height; |
| 541 | } |
| 542 | |
| 543 | static void |
| 544 | ctk_offscreen_box_size_allocate (CtkWidget *widget, |
| 545 | CtkAllocation *allocation) |
| 546 | { |
| 547 | CtkOffscreenBox *offscreen_box; |
| 548 | gint start_y; |
| 549 | guint border_width; |
| 550 | |
| 551 | offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
| 552 | |
| 553 | ctk_widget_set_allocation (widget, allocation); |
| 554 | |
| 555 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
| 556 | |
| 557 | if (ctk_widget_get_realized (widget)) |
| 558 | cdk_window_move_resize (ctk_widget_get_window (widget), |
| 559 | allocation->x + border_width, |
| 560 | allocation->y + border_width, |
| 561 | allocation->width - border_width * 2, |
| 562 | allocation->height - border_width * 2); |
| 563 | |
| 564 | start_y = 0; |
| 565 | |
| 566 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 567 | { |
| 568 | CtkRequisition child_requisition; |
| 569 | CtkAllocation child_allocation; |
| 570 | |
| 571 | ctk_widget_get_preferred_size (offscreen_box->child1, |
| 572 | &child_requisition, NULL((void*)0)); |
| 573 | child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE1.0 - 1.0) / 2; |
| 574 | child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE1.0 - 1.0) / 2; |
| 575 | child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width)(((1) > ((gint) allocation->width - 2 * border_width)) ? (1) : ((gint) allocation->width - 2 * border_width)); |
| 576 | child_allocation.height = child_requisition.height; |
| 577 | |
| 578 | start_y += CHILD1_SIZE_SCALE1.0 * child_requisition.height; |
| 579 | |
| 580 | if (ctk_widget_get_realized (widget)) |
| 581 | cdk_window_move_resize (offscreen_box->offscreen_window1, |
| 582 | child_allocation.x, |
| 583 | child_allocation.y, |
| 584 | child_allocation.width, |
| 585 | child_allocation.height); |
| 586 | |
| 587 | child_allocation.x = child_allocation.y = 0; |
| 588 | ctk_widget_size_allocate (offscreen_box->child1, &child_allocation); |
| 589 | } |
| 590 | |
| 591 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
| 592 | { |
| 593 | CtkRequisition child_requisition; |
| 594 | CtkAllocation child_allocation; |
| 595 | |
| 596 | ctk_widget_get_preferred_size (offscreen_box->child2, |
| 597 | &child_requisition, NULL((void*)0)); |
| 598 | child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE1.0 - 1.0) / 2; |
| 599 | child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE1.0 - 1.0) / 2; |
| 600 | child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width)(((1) > ((gint) allocation->width - 2 * border_width)) ? (1) : ((gint) allocation->width - 2 * border_width)); |
| 601 | child_allocation.height = child_requisition.height; |
| 602 | |
| 603 | start_y += CHILD2_SIZE_SCALE1.0 * child_requisition.height; |
Value stored to 'start_y' is never read | |
| 604 | |
| 605 | if (ctk_widget_get_realized (widget)) |
| 606 | cdk_window_move_resize (offscreen_box->offscreen_window2, |
| 607 | child_allocation.x, |
| 608 | child_allocation.y, |
| 609 | child_allocation.width, |
| 610 | child_allocation.height); |
| 611 | |
| 612 | child_allocation.x = child_allocation.y = 0; |
| 613 | ctk_widget_size_allocate (offscreen_box->child2, &child_allocation); |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | static gboolean |
| 618 | ctk_offscreen_box_damage (CtkWidget *widget, |
| 619 | CdkEventExpose *event G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 620 | { |
| 621 | cdk_window_invalidate_rect (ctk_widget_get_window (widget), |
| 622 | NULL((void*)0), FALSE(0)); |
| 623 | |
| 624 | return TRUE(!(0)); |
| 625 | } |
| 626 | |
| 627 | static gboolean |
| 628 | ctk_offscreen_box_draw (CtkWidget *widget, |
| 629 | cairo_t *cr) |
| 630 | { |
| 631 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
| 632 | CdkWindow *window; |
| 633 | |
| 634 | window = ctk_widget_get_window (widget); |
| 635 | if (ctk_cairo_should_draw_window (cr, window)) |
| 636 | { |
| 637 | cairo_surface_t *surface; |
| 638 | CtkAllocation child_area; |
| 639 | |
| 640 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
| 641 | { |
| 642 | surface = cdk_offscreen_window_get_surface (offscreen_box->offscreen_window1); |
| 643 | |
| 644 | cairo_set_source_surface (cr, surface, 0, 0); |
| 645 | cairo_paint (cr); |
| 646 | |
| 647 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
| 648 | cairo_translate (cr, 0, child_area.height); |
| 649 | } |
| 650 | |
| 651 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
| 652 | { |
| 653 | surface = cdk_offscreen_window_get_surface (offscreen_box->offscreen_window2); |
| 654 | |
| 655 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
| 656 | |
| 657 | /* transform */ |
| 658 | cairo_translate (cr, child_area.width / 2, child_area.height / 2); |
| 659 | cairo_rotate (cr, offscreen_box->angle); |
| 660 | cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); |
| 661 | |
| 662 | /* paint */ |
| 663 | cairo_set_source_surface (cr, surface, 0, 0); |
| 664 | cairo_paint (cr); |
| 665 | } |
| 666 | } |
| 667 | else if (ctk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1)) |
| 668 | { |
| 669 | ctk_render_background (ctk_widget_get_style_context (widget), cr, |
| 670 | 0, 0, |
| 671 | |
| 672 | cdk_window_get_width (offscreen_box->offscreen_window1), |
| 673 | cdk_window_get_height (offscreen_box->offscreen_window1)); |
| 674 | |
| 675 | if (offscreen_box->child1) |
| 676 | ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), |
| 677 | offscreen_box->child1, |
| 678 | cr); |
| 679 | } |
| 680 | else if (ctk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2)) |
| 681 | { |
| 682 | ctk_render_background (ctk_widget_get_style_context (widget), cr, |
| 683 | 0, 0, |
| 684 | cdk_window_get_width (offscreen_box->offscreen_window2), |
| 685 | cdk_window_get_height (offscreen_box->offscreen_window2)); |
| 686 | |
| 687 | if (offscreen_box->child2) |
| 688 | ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), |
| 689 | offscreen_box->child2, |
| 690 | cr); |
| 691 | } |
| 692 | |
| 693 | return FALSE(0); |
| 694 | } |