| File: | ctk/ctkwindow.c |
| Warning: | line 6733, column 16 Assigned value is uninitialized |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* CTK - The GIMP Toolkit | |||
| 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald | |||
| 3 | * | |||
| 4 | * This library is free software; you can redistribute it and/or | |||
| 5 | * modify it under the terms of the GNU Lesser General Public | |||
| 6 | * License as published by the Free Software Foundation; either | |||
| 7 | * version 2 of the License, or (at your option) any later version. | |||
| 8 | * | |||
| 9 | * This library is distributed in the hope that it will be useful, | |||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
| 12 | * Lesser General Public License for more details. | |||
| 13 | * | |||
| 14 | * You should have received a copy of the GNU Lesser General Public | |||
| 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 16 | */ | |||
| 17 | ||||
| 18 | /* | |||
| 19 | * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS | |||
| 20 | * file for a list of people on the CTK+ Team. See the ChangeLog | |||
| 21 | * files for a list of changes. These files are distributed with | |||
| 22 | * CTK+ at ftp://ftp.ctk.org/pub/ctk/. | |||
| 23 | */ | |||
| 24 | ||||
| 25 | #include "config.h" | |||
| 26 | ||||
| 27 | #include "ctkwindow.h" | |||
| 28 | ||||
| 29 | #include <string.h> | |||
| 30 | #include <stdlib.h> | |||
| 31 | #include <errno(*__errno_location ()).h> | |||
| 32 | #include <limits.h> | |||
| 33 | ||||
| 34 | #include "ctkprivate.h" | |||
| 35 | #include "ctkwindowprivate.h" | |||
| 36 | #include "ctkaccelgroupprivate.h" | |||
| 37 | #include "ctkbindings.h" | |||
| 38 | #include "ctkcsscornervalueprivate.h" | |||
| 39 | #include "ctkcssiconthemevalueprivate.h" | |||
| 40 | #include "ctkcssrgbavalueprivate.h" | |||
| 41 | #include "ctkcssshadowsvalueprivate.h" | |||
| 42 | #include "ctkkeyhash.h" | |||
| 43 | #include "ctkmain.h" | |||
| 44 | #include "ctkmnemonichash.h" | |||
| 45 | #include "ctkmenubar.h" | |||
| 46 | #include "ctkmenushellprivate.h" | |||
| 47 | #include "ctkicontheme.h" | |||
| 48 | #include "ctkmarshalers.h" | |||
| 49 | #include "ctkplug.h" | |||
| 50 | #include "ctkbuildable.h" | |||
| 51 | #include "ctkbuilderprivate.h" | |||
| 52 | #include "ctkwidgetprivate.h" | |||
| 53 | #include "ctkcontainerprivate.h" | |||
| 54 | #include "ctkintl.h" | |||
| 55 | #include "ctkstylecontextprivate.h" | |||
| 56 | #include "ctktypebuiltins.h" | |||
| 57 | #include "ctkbox.h" | |||
| 58 | #include "ctkbutton.h" | |||
| 59 | #include "ctkheaderbar.h" | |||
| 60 | #include "ctkheaderbarprivate.h" | |||
| 61 | #include "ctkpopoverprivate.h" | |||
| 62 | #include "a11y/ctkwindowaccessible.h" | |||
| 63 | #include "a11y/ctkcontaineraccessibleprivate.h" | |||
| 64 | #include "ctkapplicationprivate.h" | |||
| 65 | #include "ctkgestureprivate.h" | |||
| 66 | #include "inspector/init.h" | |||
| 67 | #include "inspector/window.h" | |||
| 68 | #include "ctkcssstylepropertyprivate.h" | |||
| 69 | ||||
| 70 | #include "cdk/cdk-private.h" | |||
| 71 | ||||
| 72 | #ifdef CDK_WINDOWING_X11 | |||
| 73 | #include "x11/cdkx.h" | |||
| 74 | #endif | |||
| 75 | ||||
| 76 | #ifdef CDK_WINDOWING_WIN32 | |||
| 77 | #include "win32/cdkwin32.h" | |||
| 78 | #endif | |||
| 79 | ||||
| 80 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 81 | #include "wayland/cdkwayland.h" | |||
| 82 | #endif | |||
| 83 | ||||
| 84 | #ifdef CDK_WINDOWING_BROADWAY | |||
| 85 | #include "broadway/cdkbroadway.h" | |||
| 86 | #endif | |||
| 87 | ||||
| 88 | /** | |||
| 89 | * SECTION:ctkwindow | |||
| 90 | * @title: CtkWindow | |||
| 91 | * @short_description: Toplevel which can contain other widgets | |||
| 92 | * | |||
| 93 | * A CtkWindow is a toplevel window which can contain other widgets. | |||
| 94 | * Windows normally have decorations that are under the control | |||
| 95 | * of the windowing system and allow the user to manipulate the window | |||
| 96 | * (resize it, move it, close it,...). | |||
| 97 | * | |||
| 98 | * # CtkWindow as CtkBuildable | |||
| 99 | * | |||
| 100 | * The CtkWindow implementation of the #CtkBuildable interface supports a | |||
| 101 | * custom <accel-groups> element, which supports any number of <group> | |||
| 102 | * elements representing the #CtkAccelGroup objects you want to add to | |||
| 103 | * your window (synonymous with ctk_window_add_accel_group(). | |||
| 104 | * | |||
| 105 | * It also supports the <initial-focus> element, whose name property names | |||
| 106 | * the widget to receive the focus when the window is mapped. | |||
| 107 | * | |||
| 108 | * An example of a UI definition fragment with accel groups: | |||
| 109 | * |[ | |||
| 110 | * <object class="CtkWindow"> | |||
| 111 | * <accel-groups> | |||
| 112 | * <group name="accelgroup1"/> | |||
| 113 | * </accel-groups> | |||
| 114 | * <initial-focus name="thunderclap"/> | |||
| 115 | * </object> | |||
| 116 | * | |||
| 117 | * ... | |||
| 118 | * | |||
| 119 | * <object class="CtkAccelGroup" id="accelgroup1"/> | |||
| 120 | * ]| | |||
| 121 | * | |||
| 122 | * The CtkWindow implementation of the #CtkBuildable interface supports | |||
| 123 | * setting a child as the titlebar by specifying “titlebar” as the “type” | |||
| 124 | * attribute of a <child> element. | |||
| 125 | * | |||
| 126 | * # CSS nodes | |||
| 127 | * | |||
| 128 | * |[<!-- language="plain" --> | |||
| 129 | * window.background | |||
| 130 | * ├── decoration | |||
| 131 | * ├── <titlebar child>.titlebar [.default-decoration] | |||
| 132 | * ╰── <child> | |||
| 133 | * ]| | |||
| 134 | * | |||
| 135 | * CtkWindow has a main CSS node with name window and style class .background, | |||
| 136 | * and a subnode with name decoration. | |||
| 137 | * | |||
| 138 | * Style classes that are typically used with the main CSS node are .csd (when | |||
| 139 | * client-side decorations are in use), .solid-csd (for client-side decorations | |||
| 140 | * without invisible borders), .ssd (used by mutter when rendering server-side | |||
| 141 | * decorations). CtkWindow also represents window states with the following | |||
| 142 | * style classes on the main node: .tiled, .maximized, .fullscreen. Specialized | |||
| 143 | * types of window often add their own discriminating style classes, such as | |||
| 144 | * .popup or .tooltip. | |||
| 145 | * | |||
| 146 | * CtkWindow adds the .titlebar and .default-decoration style classes to the | |||
| 147 | * widget that is added as a titlebar child. | |||
| 148 | */ | |||
| 149 | ||||
| 150 | #define MNEMONICS_DELAY300 300 /* ms */ | |||
| 151 | #define NO_CONTENT_CHILD_NAT200 200 | |||
| 152 | /* In case the content (excluding header bar and shadows) of the window | |||
| 153 | * would be empty, either because there is no visible child widget or only an | |||
| 154 | * empty container widget, we use NO_CONTENT_CHILD_NAT as natural width/height | |||
| 155 | * instead. | |||
| 156 | */ | |||
| 157 | ||||
| 158 | typedef struct _CtkWindowPopover CtkWindowPopover; | |||
| 159 | ||||
| 160 | struct _CtkWindowPopover | |||
| 161 | { | |||
| 162 | CtkWidget *widget; | |||
| 163 | CtkWidget *parent; | |||
| 164 | CdkWindow *window; | |||
| 165 | CtkPositionType pos; | |||
| 166 | cairo_rectangle_int_t rect; | |||
| 167 | gulong unmap_id; | |||
| 168 | guint clamp_allocation : 1; | |||
| 169 | }; | |||
| 170 | ||||
| 171 | struct _CtkWindowPrivate | |||
| 172 | { | |||
| 173 | CtkMnemonicHash *mnemonic_hash; | |||
| 174 | ||||
| 175 | CtkWidget *attach_widget; | |||
| 176 | CtkWidget *default_widget; | |||
| 177 | CtkWidget *initial_focus; | |||
| 178 | CtkWidget *focus_widget; | |||
| 179 | CtkWindow *transient_parent; | |||
| 180 | CtkWindowGeometryInfo *geometry_info; | |||
| 181 | CtkWindowGroup *group; | |||
| 182 | CdkScreen *screen; | |||
| 183 | CdkDisplay *display; | |||
| 184 | CtkApplication *application; | |||
| 185 | ||||
| 186 | GList *popovers; | |||
| 187 | ||||
| 188 | CdkModifierType mnemonic_modifier; | |||
| 189 | ||||
| 190 | gchar *startup_id; | |||
| 191 | gchar *title; | |||
| 192 | gchar *wmclass_class; | |||
| 193 | gchar *wmclass_name; | |||
| 194 | gchar *wm_role; | |||
| 195 | ||||
| 196 | guint keys_changed_handler; | |||
| 197 | guint delete_event_handler; | |||
| 198 | ||||
| 199 | guint32 initial_timestamp; | |||
| 200 | ||||
| 201 | guint16 configure_request_count; | |||
| 202 | ||||
| 203 | guint mnemonics_display_timeout_id; | |||
| 204 | ||||
| 205 | gint scale; | |||
| 206 | ||||
| 207 | gint title_height; | |||
| 208 | CtkWidget *title_box; | |||
| 209 | CtkWidget *titlebar; | |||
| 210 | CtkWidget *popup_menu; | |||
| 211 | ||||
| 212 | CdkWindow *border_window[8]; | |||
| 213 | gint initial_fullscreen_monitor; | |||
| 214 | guint edge_constraints; | |||
| 215 | ||||
| 216 | /* The following flags are initially TRUE (before a window is mapped). | |||
| 217 | * They cause us to compute a configure request that involves | |||
| 218 | * default-only parameters. Once mapped, we set them to FALSE. | |||
| 219 | * Then we set them to TRUE again on unmap (for position) | |||
| 220 | * and on unrealize (for size). | |||
| 221 | */ | |||
| 222 | guint need_default_position : 1; | |||
| 223 | guint need_default_size : 1; | |||
| 224 | ||||
| 225 | guint above_initially : 1; | |||
| 226 | guint accept_focus : 1; | |||
| 227 | guint below_initially : 1; | |||
| 228 | guint builder_visible : 1; | |||
| 229 | guint configure_notify_received : 1; | |||
| 230 | guint decorated : 1; | |||
| 231 | guint deletable : 1; | |||
| 232 | guint destroy_with_parent : 1; | |||
| 233 | guint focus_on_map : 1; | |||
| 234 | guint fullscreen_initially : 1; | |||
| 235 | guint has_focus : 1; | |||
| 236 | guint has_user_ref_count : 1; | |||
| 237 | guint has_toplevel_focus : 1; | |||
| 238 | guint hide_titlebar_when_maximized : 1; | |||
| 239 | guint iconify_initially : 1; /* ctk_window_iconify() called before realization */ | |||
| 240 | guint is_active : 1; | |||
| 241 | guint interactive_search_open : 1; | |||
| 242 | guint maximize_initially : 1; | |||
| 243 | guint mnemonics_visible : 1; | |||
| 244 | guint mnemonics_visible_set : 1; | |||
| 245 | guint focus_visible : 1; | |||
| 246 | guint modal : 1; | |||
| 247 | guint position : 3; | |||
| 248 | guint resizable : 1; | |||
| 249 | guint skips_pager : 1; | |||
| 250 | guint skips_taskbar : 1; | |||
| 251 | guint stick_initially : 1; | |||
| 252 | guint transient_parent_group : 1; | |||
| 253 | guint type : 4; /* CtkWindowType */ | |||
| 254 | guint urgent : 1; | |||
| 255 | guint gravity : 5; /* CdkGravity */ | |||
| 256 | guint csd_requested : 1; | |||
| 257 | guint client_decorated : 1; /* Decorations drawn client-side */ | |||
| 258 | guint use_client_shadow : 1; /* Decorations use client-side shadows */ | |||
| 259 | guint maximized : 1; | |||
| 260 | guint fullscreen : 1; | |||
| 261 | guint tiled : 1; | |||
| 262 | guint unlimited_guessed_size_x : 1; | |||
| 263 | guint unlimited_guessed_size_y : 1; | |||
| 264 | guint force_resize : 1; | |||
| 265 | guint fixate_size : 1; | |||
| 266 | ||||
| 267 | guint use_subsurface : 1; | |||
| 268 | ||||
| 269 | CdkWindowTypeHint type_hint; | |||
| 270 | ||||
| 271 | CtkGesture *multipress_gesture; | |||
| 272 | CtkGesture *drag_gesture; | |||
| 273 | ||||
| 274 | CdkWindow *hardcoded_window; | |||
| 275 | ||||
| 276 | CtkCssNode *decoration_node; | |||
| 277 | }; | |||
| 278 | ||||
| 279 | #ifdef CDK_WINDOWING_X11 | |||
| 280 | static const CtkTargetEntry dnd_dest_targets [] = { | |||
| 281 | { "application/x-rootwindow-drop", 0, 0 }, | |||
| 282 | }; | |||
| 283 | #endif | |||
| 284 | ||||
| 285 | enum { | |||
| 286 | SET_FOCUS, | |||
| 287 | ACTIVATE_FOCUS, | |||
| 288 | ACTIVATE_DEFAULT, | |||
| 289 | KEYS_CHANGED, | |||
| 290 | ENABLE_DEBUGGING, | |||
| 291 | LAST_SIGNAL | |||
| 292 | }; | |||
| 293 | ||||
| 294 | enum { | |||
| 295 | PROP_0, | |||
| 296 | ||||
| 297 | /* Construct */ | |||
| 298 | PROP_TYPE, | |||
| 299 | ||||
| 300 | /* Normal Props */ | |||
| 301 | PROP_TITLE, | |||
| 302 | PROP_ROLE, | |||
| 303 | PROP_RESIZABLE, | |||
| 304 | PROP_MODAL, | |||
| 305 | PROP_WIN_POS, | |||
| 306 | PROP_DEFAULT_WIDTH, | |||
| 307 | PROP_DEFAULT_HEIGHT, | |||
| 308 | PROP_DESTROY_WITH_PARENT, | |||
| 309 | PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED, | |||
| 310 | PROP_ICON, | |||
| 311 | PROP_ICON_NAME, | |||
| 312 | PROP_SCREEN, | |||
| 313 | PROP_TYPE_HINT, | |||
| 314 | PROP_SKIP_TASKBAR_HINT, | |||
| 315 | PROP_SKIP_PAGER_HINT, | |||
| 316 | PROP_URGENCY_HINT, | |||
| 317 | PROP_ACCEPT_FOCUS, | |||
| 318 | PROP_FOCUS_ON_MAP, | |||
| 319 | PROP_DECORATED, | |||
| 320 | PROP_DELETABLE, | |||
| 321 | PROP_GRAVITY, | |||
| 322 | PROP_TRANSIENT_FOR, | |||
| 323 | PROP_ATTACHED_TO, | |||
| 324 | PROP_HAS_RESIZE_GRIP, | |||
| 325 | PROP_RESIZE_GRIP_VISIBLE, | |||
| 326 | PROP_APPLICATION, | |||
| 327 | /* Readonly properties */ | |||
| 328 | PROP_IS_ACTIVE, | |||
| 329 | PROP_HAS_TOPLEVEL_FOCUS, | |||
| 330 | ||||
| 331 | /* Writeonly properties */ | |||
| 332 | PROP_STARTUP_ID, | |||
| 333 | ||||
| 334 | PROP_MNEMONICS_VISIBLE, | |||
| 335 | PROP_FOCUS_VISIBLE, | |||
| 336 | ||||
| 337 | PROP_IS_MAXIMIZED, | |||
| 338 | ||||
| 339 | LAST_ARG | |||
| 340 | }; | |||
| 341 | ||||
| 342 | static GParamSpec *window_props[LAST_ARG] = { NULL((void*)0), }; | |||
| 343 | ||||
| 344 | /* Must be kept in sync with CdkWindowEdge ! */ | |||
| 345 | typedef enum | |||
| 346 | { | |||
| 347 | CTK_WINDOW_REGION_EDGE_NW, | |||
| 348 | CTK_WINDOW_REGION_EDGE_N, | |||
| 349 | CTK_WINDOW_REGION_EDGE_NE, | |||
| 350 | CTK_WINDOW_REGION_EDGE_W, | |||
| 351 | CTK_WINDOW_REGION_EDGE_E, | |||
| 352 | CTK_WINDOW_REGION_EDGE_SW, | |||
| 353 | CTK_WINDOW_REGION_EDGE_S, | |||
| 354 | CTK_WINDOW_REGION_EDGE_SE, | |||
| 355 | CTK_WINDOW_REGION_CONTENT, | |||
| 356 | CTK_WINDOW_REGION_TITLE, | |||
| 357 | } CtkWindowRegion; | |||
| 358 | ||||
| 359 | typedef struct | |||
| 360 | { | |||
| 361 | GList *icon_list; | |||
| 362 | gchar *icon_name; | |||
| 363 | guint realized : 1; | |||
| 364 | guint using_default_icon : 1; | |||
| 365 | guint using_parent_icon : 1; | |||
| 366 | guint using_themed_icon : 1; | |||
| 367 | } CtkWindowIconInfo; | |||
| 368 | ||||
| 369 | typedef struct { | |||
| 370 | CdkGeometry geometry; /* Last set of geometry hints we set */ | |||
| 371 | CdkWindowHints flags; | |||
| 372 | CdkRectangle configure_request; | |||
| 373 | } CtkWindowLastGeometryInfo; | |||
| 374 | ||||
| 375 | struct _CtkWindowGeometryInfo | |||
| 376 | { | |||
| 377 | /* Properties that the app has set on the window | |||
| 378 | */ | |||
| 379 | CdkGeometry geometry; /* Geometry hints */ | |||
| 380 | CdkWindowHints mask; | |||
| 381 | /* from last ctk_window_resize () - if > 0, indicates that | |||
| 382 | * we should resize to this size. | |||
| 383 | */ | |||
| 384 | gint resize_width; | |||
| 385 | gint resize_height; | |||
| 386 | ||||
| 387 | /* From last ctk_window_move () prior to mapping - | |||
| 388 | * only used if initial_pos_set | |||
| 389 | */ | |||
| 390 | gint initial_x; | |||
| 391 | gint initial_y; | |||
| 392 | ||||
| 393 | /* Default size - used only the FIRST time we map a window, | |||
| 394 | * only if > 0. | |||
| 395 | */ | |||
| 396 | gint default_width; | |||
| 397 | gint default_height; | |||
| 398 | /* whether to use initial_x, initial_y */ | |||
| 399 | guint initial_pos_set : 1; | |||
| 400 | /* CENTER_ALWAYS or other position constraint changed since | |||
| 401 | * we sent the last configure request. | |||
| 402 | */ | |||
| 403 | guint position_constraints_changed : 1; | |||
| 404 | ||||
| 405 | /* if true, default_width, height should be multiplied by the | |||
| 406 | * increments and affect the geometry widget only | |||
| 407 | */ | |||
| 408 | guint default_is_geometry : 1; | |||
| 409 | ||||
| 410 | CtkWindowLastGeometryInfo last; | |||
| 411 | }; | |||
| 412 | ||||
| 413 | ||||
| 414 | static void ctk_window_constructed (GObject *object); | |||
| 415 | static void ctk_window_dispose (GObject *object); | |||
| 416 | static void ctk_window_finalize (GObject *object); | |||
| 417 | static void ctk_window_destroy (CtkWidget *widget); | |||
| 418 | static void ctk_window_show (CtkWidget *widget); | |||
| 419 | static void ctk_window_hide (CtkWidget *widget); | |||
| 420 | static void ctk_window_map (CtkWidget *widget); | |||
| 421 | static void ctk_window_unmap (CtkWidget *widget); | |||
| 422 | static void ctk_window_realize (CtkWidget *widget); | |||
| 423 | static void ctk_window_unrealize (CtkWidget *widget); | |||
| 424 | static void ctk_window_size_allocate (CtkWidget *widget, | |||
| 425 | CtkAllocation *allocation); | |||
| 426 | static gboolean ctk_window_map_event (CtkWidget *widget, | |||
| 427 | CdkEventAny *event); | |||
| 428 | static gint ctk_window_configure_event (CtkWidget *widget, | |||
| 429 | CdkEventConfigure *event); | |||
| 430 | static gboolean ctk_window_event (CtkWidget *widget, | |||
| 431 | CdkEvent *event); | |||
| 432 | static gint ctk_window_key_press_event (CtkWidget *widget, | |||
| 433 | CdkEventKey *event); | |||
| 434 | static gint ctk_window_key_release_event (CtkWidget *widget, | |||
| 435 | CdkEventKey *event); | |||
| 436 | static gint ctk_window_focus_in_event (CtkWidget *widget, | |||
| 437 | CdkEventFocus *event); | |||
| 438 | static gint ctk_window_focus_out_event (CtkWidget *widget, | |||
| 439 | CdkEventFocus *event); | |||
| 440 | static gboolean ctk_window_state_event (CtkWidget *widget, | |||
| 441 | CdkEventWindowState *event); | |||
| 442 | static void ctk_window_remove (CtkContainer *container, | |||
| 443 | CtkWidget *widget); | |||
| 444 | static void ctk_window_check_resize (CtkContainer *container); | |||
| 445 | static void ctk_window_forall (CtkContainer *container, | |||
| 446 | gboolean include_internals, | |||
| 447 | CtkCallback callback, | |||
| 448 | gpointer callback_data); | |||
| 449 | static gint ctk_window_focus (CtkWidget *widget, | |||
| 450 | CtkDirectionType direction); | |||
| 451 | static void ctk_window_move_focus (CtkWidget *widget, | |||
| 452 | CtkDirectionType dir); | |||
| 453 | static void ctk_window_real_set_focus (CtkWindow *window, | |||
| 454 | CtkWidget *focus); | |||
| 455 | ||||
| 456 | static void ctk_window_real_activate_default (CtkWindow *window); | |||
| 457 | static void ctk_window_real_activate_focus (CtkWindow *window); | |||
| 458 | static void ctk_window_keys_changed (CtkWindow *window); | |||
| 459 | static gboolean ctk_window_enable_debugging (CtkWindow *window, | |||
| 460 | gboolean toggle); | |||
| 461 | static gint ctk_window_draw (CtkWidget *widget, | |||
| 462 | cairo_t *cr); | |||
| 463 | static void ctk_window_unset_transient_for (CtkWindow *window); | |||
| 464 | static void ctk_window_transient_parent_realized (CtkWidget *parent, | |||
| 465 | CtkWidget *window); | |||
| 466 | static void ctk_window_transient_parent_unrealized (CtkWidget *parent, | |||
| 467 | CtkWidget *window); | |||
| 468 | ||||
| 469 | static CdkScreen *ctk_window_check_screen (CtkWindow *window); | |||
| 470 | ||||
| 471 | static CtkWindowGeometryInfo* ctk_window_get_geometry_info (CtkWindow *window, | |||
| 472 | gboolean create); | |||
| 473 | ||||
| 474 | static gboolean ctk_window_compare_hints (CdkGeometry *geometry_a, | |||
| 475 | guint flags_a, | |||
| 476 | CdkGeometry *geometry_b, | |||
| 477 | guint flags_b); | |||
| 478 | static void ctk_window_constrain_size (CtkWindow *window, | |||
| 479 | CdkGeometry *geometry, | |||
| 480 | guint flags, | |||
| 481 | gint width, | |||
| 482 | gint height, | |||
| 483 | gint *new_width, | |||
| 484 | gint *new_height); | |||
| 485 | static void ctk_window_constrain_position (CtkWindow *window, | |||
| 486 | gint new_width, | |||
| 487 | gint new_height, | |||
| 488 | gint *x, | |||
| 489 | gint *y); | |||
| 490 | static void ctk_window_update_fixed_size (CtkWindow *window, | |||
| 491 | CdkGeometry *new_geometry, | |||
| 492 | gint new_width, | |||
| 493 | gint new_height); | |||
| 494 | static void ctk_window_compute_hints (CtkWindow *window, | |||
| 495 | CdkGeometry *new_geometry, | |||
| 496 | guint *new_flags); | |||
| 497 | static void ctk_window_compute_configure_request (CtkWindow *window, | |||
| 498 | CdkRectangle *request, | |||
| 499 | CdkGeometry *geometry, | |||
| 500 | guint *flags); | |||
| 501 | ||||
| 502 | static void ctk_window_set_default_size_internal (CtkWindow *window, | |||
| 503 | gboolean change_width, | |||
| 504 | gint width, | |||
| 505 | gboolean change_height, | |||
| 506 | gint height, | |||
| 507 | gboolean is_geometry); | |||
| 508 | ||||
| 509 | static void update_themed_icon (CtkWindow *window); | |||
| 510 | static GList *icon_list_from_theme (CtkWindow *window, | |||
| 511 | const gchar *name); | |||
| 512 | static void ctk_window_realize_icon (CtkWindow *window); | |||
| 513 | static void ctk_window_unrealize_icon (CtkWindow *window); | |||
| 514 | static void update_window_buttons (CtkWindow *window); | |||
| 515 | static void get_shadow_width (CtkWindow *window, | |||
| 516 | CtkBorder *shadow_width); | |||
| 517 | ||||
| 518 | static CtkKeyHash *ctk_window_get_key_hash (CtkWindow *window); | |||
| 519 | static void ctk_window_free_key_hash (CtkWindow *window); | |||
| 520 | static void ctk_window_on_composited_changed (CdkScreen *screen, | |||
| 521 | CtkWindow *window); | |||
| 522 | #ifdef CDK_WINDOWING_X11 | |||
| 523 | static void ctk_window_on_theme_variant_changed (CtkSettings *settings, | |||
| 524 | GParamSpec *pspec, | |||
| 525 | CtkWindow *window); | |||
| 526 | #endif | |||
| 527 | static void ctk_window_set_theme_variant (CtkWindow *window); | |||
| 528 | ||||
| 529 | static void ctk_window_do_popup (CtkWindow *window, | |||
| 530 | CdkEventButton *event); | |||
| 531 | ||||
| 532 | static void ctk_window_get_preferred_width (CtkWidget *widget, | |||
| 533 | gint *minimum_size, | |||
| 534 | gint *natural_size); | |||
| 535 | static void ctk_window_get_preferred_width_for_height (CtkWidget *widget, | |||
| 536 | gint height, | |||
| 537 | gint *minimum_size, | |||
| 538 | gint *natural_size); | |||
| 539 | ||||
| 540 | static void ctk_window_get_preferred_height (CtkWidget *widget, | |||
| 541 | gint *minimum_size, | |||
| 542 | gint *natural_size); | |||
| 543 | static void ctk_window_get_preferred_height_for_width (CtkWidget *widget, | |||
| 544 | gint width, | |||
| 545 | gint *minimum_size, | |||
| 546 | gint *natural_size); | |||
| 547 | static void ctk_window_style_updated (CtkWidget *widget); | |||
| 548 | static void ctk_window_state_flags_changed (CtkWidget *widget, | |||
| 549 | CtkStateFlags previous_state); | |||
| 550 | ||||
| 551 | static void ctk_window_get_remembered_size (CtkWindow *window, | |||
| 552 | int *width, | |||
| 553 | int *height); | |||
| 554 | ||||
| 555 | static GSList *toplevel_list = NULL((void*)0); | |||
| 556 | static guint window_signals[LAST_SIGNAL] = { 0 }; | |||
| 557 | static GList *default_icon_list = NULL((void*)0); | |||
| 558 | static gchar *default_icon_name = NULL((void*)0); | |||
| 559 | static guint default_icon_serial = 0; | |||
| 560 | static gboolean disable_startup_notification = FALSE(0); | |||
| 561 | ||||
| 562 | static GQuark quark_ctk_embedded = 0; | |||
| 563 | static GQuark quark_ctk_window_key_hash = 0; | |||
| 564 | static GQuark quark_ctk_window_icon_info = 0; | |||
| 565 | static GQuark quark_ctk_buildable_accels = 0; | |||
| 566 | ||||
| 567 | static CtkBuildableIface *parent_buildable_iface; | |||
| 568 | ||||
| 569 | static void ctk_window_set_property (GObject *object, | |||
| 570 | guint prop_id, | |||
| 571 | const GValue *value, | |||
| 572 | GParamSpec *pspec); | |||
| 573 | static void ctk_window_get_property (GObject *object, | |||
| 574 | guint prop_id, | |||
| 575 | GValue *value, | |||
| 576 | GParamSpec *pspec); | |||
| 577 | ||||
| 578 | /* CtkBuildable */ | |||
| 579 | static void ctk_window_buildable_interface_init (CtkBuildableIface *iface); | |||
| 580 | static void ctk_window_buildable_add_child (CtkBuildable *buildable, | |||
| 581 | CtkBuilder *builder, | |||
| 582 | GObject *child, | |||
| 583 | const gchar *type); | |||
| 584 | static void ctk_window_buildable_set_buildable_property (CtkBuildable *buildable, | |||
| 585 | CtkBuilder *builder, | |||
| 586 | const gchar *name, | |||
| 587 | const GValue *value); | |||
| 588 | static void ctk_window_buildable_parser_finished (CtkBuildable *buildable, | |||
| 589 | CtkBuilder *builder); | |||
| 590 | static gboolean ctk_window_buildable_custom_tag_start (CtkBuildable *buildable, | |||
| 591 | CtkBuilder *builder, | |||
| 592 | GObject *child, | |||
| 593 | const gchar *tagname, | |||
| 594 | GMarkupParser *parser, | |||
| 595 | gpointer *data); | |||
| 596 | static void ctk_window_buildable_custom_finished (CtkBuildable *buildable, | |||
| 597 | CtkBuilder *builder, | |||
| 598 | GObject *child, | |||
| 599 | const gchar *tagname, | |||
| 600 | gpointer user_data); | |||
| 601 | ||||
| 602 | static void ensure_state_flag_backdrop (CtkWidget *widget); | |||
| 603 | static void unset_titlebar (CtkWindow *window); | |||
| 604 | static void on_titlebar_title_notify (CtkHeaderBar *titlebar, | |||
| 605 | GParamSpec *pspec, | |||
| 606 | CtkWindow *self); | |||
| 607 | static CtkWindowRegion get_active_region_type (CtkWindow *window, | |||
| 608 | CdkEventAny *event, | |||
| 609 | gint x, | |||
| 610 | gint y); | |||
| 611 | ||||
| 612 | static void ctk_window_update_debugging (void); | |||
| 613 | ||||
| 614 | G_DEFINE_TYPE_WITH_CODE (CtkWindow, ctk_window, CTK_TYPE_BIN,static void ctk_window_init (CtkWindow *self); static void ctk_window_class_init (CtkWindowClass *klass); static GType ctk_window_get_type_once (void); __attribute__ ((__unused__)) static gpointer ctk_window_parent_class = ((void*)0); static gint CtkWindow_private_offset; static void ctk_window_class_intern_init (gpointer klass) { ctk_window_parent_class = g_type_class_peek_parent (klass); if (CtkWindow_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkWindow_private_offset ); ctk_window_class_init ((CtkWindowClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_window_get_instance_private (CtkWindow *self) { return (((gpointer) ((guint8*) (self) + ( glong) (CtkWindow_private_offset)))); } GType ctk_window_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_window_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_window_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_bin_get_type ()), g_intern_static_string ("CtkWindow"), sizeof (CtkWindowClass ), (GClassInitFunc)(void (*)(void)) ctk_window_class_intern_init , sizeof (CtkWindow), (GInstanceInitFunc)(void (*)(void)) ctk_window_init , (GTypeFlags) 0); { {{ CtkWindow_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkWindowPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_window_buildable_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } | |||
| 615 | G_ADD_PRIVATE (CtkWindow)static void ctk_window_init (CtkWindow *self); static void ctk_window_class_init (CtkWindowClass *klass); static GType ctk_window_get_type_once (void); __attribute__ ((__unused__)) static gpointer ctk_window_parent_class = ((void*)0); static gint CtkWindow_private_offset; static void ctk_window_class_intern_init (gpointer klass) { ctk_window_parent_class = g_type_class_peek_parent (klass); if (CtkWindow_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkWindow_private_offset ); ctk_window_class_init ((CtkWindowClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_window_get_instance_private (CtkWindow *self) { return (((gpointer) ((guint8*) (self) + ( glong) (CtkWindow_private_offset)))); } GType ctk_window_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_window_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_window_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_bin_get_type ()), g_intern_static_string ("CtkWindow"), sizeof (CtkWindowClass ), (GClassInitFunc)(void (*)(void)) ctk_window_class_intern_init , sizeof (CtkWindow), (GInstanceInitFunc)(void (*)(void)) ctk_window_init , (GTypeFlags) 0); { {{ CtkWindow_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkWindowPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_window_buildable_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } | |||
| 616 | G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE,static void ctk_window_init (CtkWindow *self); static void ctk_window_class_init (CtkWindowClass *klass); static GType ctk_window_get_type_once (void); __attribute__ ((__unused__)) static gpointer ctk_window_parent_class = ((void*)0); static gint CtkWindow_private_offset; static void ctk_window_class_intern_init (gpointer klass) { ctk_window_parent_class = g_type_class_peek_parent (klass); if (CtkWindow_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkWindow_private_offset ); ctk_window_class_init ((CtkWindowClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_window_get_instance_private (CtkWindow *self) { return (((gpointer) ((guint8*) (self) + ( glong) (CtkWindow_private_offset)))); } GType ctk_window_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_window_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_window_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_bin_get_type ()), g_intern_static_string ("CtkWindow"), sizeof (CtkWindowClass ), (GClassInitFunc)(void (*)(void)) ctk_window_class_intern_init , sizeof (CtkWindow), (GInstanceInitFunc)(void (*)(void)) ctk_window_init , (GTypeFlags) 0); { {{ CtkWindow_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkWindowPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_window_buildable_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } | |||
| 617 | ctk_window_buildable_interface_init))static void ctk_window_init (CtkWindow *self); static void ctk_window_class_init (CtkWindowClass *klass); static GType ctk_window_get_type_once (void); __attribute__ ((__unused__)) static gpointer ctk_window_parent_class = ((void*)0); static gint CtkWindow_private_offset; static void ctk_window_class_intern_init (gpointer klass) { ctk_window_parent_class = g_type_class_peek_parent (klass); if (CtkWindow_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkWindow_private_offset ); ctk_window_class_init ((CtkWindowClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_window_get_instance_private (CtkWindow *self) { return (((gpointer) ((guint8*) (self) + ( glong) (CtkWindow_private_offset)))); } GType ctk_window_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_window_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_window_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_bin_get_type ()), g_intern_static_string ("CtkWindow"), sizeof (CtkWindowClass ), (GClassInitFunc)(void (*)(void)) ctk_window_class_intern_init , sizeof (CtkWindow), (GInstanceInitFunc)(void (*)(void)) ctk_window_init , (GTypeFlags) 0); { {{ CtkWindow_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkWindowPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_window_buildable_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } | |||
| 618 | ||||
| 619 | static void | |||
| 620 | add_tab_bindings (CtkBindingSet *binding_set, | |||
| 621 | CdkModifierType modifiers, | |||
| 622 | CtkDirectionType direction) | |||
| 623 | { | |||
| 624 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Tab0xff09, modifiers, | |||
| 625 | "move-focus", 1, | |||
| 626 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); | |||
| 627 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Tab0xff89, modifiers, | |||
| 628 | "move-focus", 1, | |||
| 629 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); | |||
| 630 | } | |||
| 631 | ||||
| 632 | static void | |||
| 633 | add_arrow_bindings (CtkBindingSet *binding_set, | |||
| 634 | guint keysym, | |||
| 635 | CtkDirectionType direction) | |||
| 636 | { | |||
| 637 | guint keypad_keysym = keysym - CDK_KEY_Left0xff51 + CDK_KEY_KP_Left0xff96; | |||
| 638 | ||||
| 639 | ctk_binding_entry_add_signal (binding_set, keysym, 0, | |||
| 640 | "move-focus", 1, | |||
| 641 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); | |||
| 642 | ctk_binding_entry_add_signal (binding_set, keysym, CDK_CONTROL_MASK, | |||
| 643 | "move-focus", 1, | |||
| 644 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); | |||
| 645 | ctk_binding_entry_add_signal (binding_set, keypad_keysym, 0, | |||
| 646 | "move-focus", 1, | |||
| 647 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); | |||
| 648 | ctk_binding_entry_add_signal (binding_set, keypad_keysym, CDK_CONTROL_MASK, | |||
| 649 | "move-focus", 1, | |||
| 650 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); | |||
| 651 | } | |||
| 652 | ||||
| 653 | static guint32 | |||
| 654 | extract_time_from_startup_id (const gchar* startup_id) | |||
| 655 | { | |||
| 656 | gchar *timestr = g_strrstr (startup_id, "_TIME"); | |||
| 657 | guint32 retval = CDK_CURRENT_TIME0L; | |||
| 658 | ||||
| 659 | if (timestr) | |||
| 660 | { | |||
| 661 | gchar *end; | |||
| 662 | guint32 timestamp; | |||
| 663 | ||||
| 664 | /* Skip past the "_TIME" part */ | |||
| 665 | timestr += 5; | |||
| 666 | ||||
| 667 | end = NULL((void*)0); | |||
| 668 | errno(*__errno_location ()) = 0; | |||
| 669 | timestamp = g_ascii_strtoull (timestr, &end, 0); | |||
| 670 | if (errno(*__errno_location ()) == 0 && end != timestr) | |||
| 671 | retval = timestamp; | |||
| 672 | } | |||
| 673 | ||||
| 674 | return retval; | |||
| 675 | } | |||
| 676 | ||||
| 677 | static gboolean | |||
| 678 | startup_id_is_fake (const gchar* startup_id) | |||
| 679 | { | |||
| 680 | return strncmp (startup_id, "_TIME", 5) == 0; | |||
| 681 | } | |||
| 682 | ||||
| 683 | static void | |||
| 684 | ctk_window_class_init (CtkWindowClass *klass) | |||
| 685 | { | |||
| 686 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
| 687 | CtkWidgetClass *widget_class; | |||
| 688 | CtkContainerClass *container_class; | |||
| 689 | CtkBindingSet *binding_set; | |||
| 690 | ||||
| 691 | widget_class = (CtkWidgetClass*) klass; | |||
| 692 | container_class = (CtkContainerClass*) klass; | |||
| 693 | ||||
| 694 | quark_ctk_embedded = g_quark_from_static_string ("ctk-embedded"); | |||
| 695 | quark_ctk_window_key_hash = g_quark_from_static_string ("ctk-window-key-hash"); | |||
| 696 | quark_ctk_window_icon_info = g_quark_from_static_string ("ctk-window-icon-info"); | |||
| 697 | quark_ctk_buildable_accels = g_quark_from_static_string ("ctk-window-buildable-accels"); | |||
| 698 | ||||
| 699 | gobject_class->constructed = ctk_window_constructed; | |||
| 700 | gobject_class->dispose = ctk_window_dispose; | |||
| 701 | gobject_class->finalize = ctk_window_finalize; | |||
| 702 | ||||
| 703 | gobject_class->set_property = ctk_window_set_property; | |||
| 704 | gobject_class->get_property = ctk_window_get_property; | |||
| 705 | ||||
| 706 | widget_class->destroy = ctk_window_destroy; | |||
| 707 | widget_class->show = ctk_window_show; | |||
| 708 | widget_class->hide = ctk_window_hide; | |||
| 709 | widget_class->map = ctk_window_map; | |||
| 710 | widget_class->map_event = ctk_window_map_event; | |||
| 711 | widget_class->unmap = ctk_window_unmap; | |||
| 712 | widget_class->realize = ctk_window_realize; | |||
| 713 | widget_class->unrealize = ctk_window_unrealize; | |||
| 714 | widget_class->size_allocate = ctk_window_size_allocate; | |||
| 715 | widget_class->configure_event = ctk_window_configure_event; | |||
| 716 | widget_class->event = ctk_window_event; | |||
| 717 | widget_class->key_press_event = ctk_window_key_press_event; | |||
| 718 | widget_class->key_release_event = ctk_window_key_release_event; | |||
| 719 | widget_class->focus_in_event = ctk_window_focus_in_event; | |||
| 720 | widget_class->focus_out_event = ctk_window_focus_out_event; | |||
| 721 | widget_class->focus = ctk_window_focus; | |||
| 722 | widget_class->move_focus = ctk_window_move_focus; | |||
| 723 | widget_class->draw = ctk_window_draw; | |||
| 724 | widget_class->window_state_event = ctk_window_state_event; | |||
| 725 | widget_class->get_preferred_width = ctk_window_get_preferred_width; | |||
| 726 | widget_class->get_preferred_width_for_height = ctk_window_get_preferred_width_for_height; | |||
| 727 | widget_class->get_preferred_height = ctk_window_get_preferred_height; | |||
| 728 | widget_class->get_preferred_height_for_width = ctk_window_get_preferred_height_for_width; | |||
| 729 | widget_class->state_flags_changed = ctk_window_state_flags_changed; | |||
| 730 | widget_class->style_updated = ctk_window_style_updated; | |||
| 731 | ||||
| 732 | container_class->remove = ctk_window_remove; | |||
| 733 | container_class->check_resize = ctk_window_check_resize; | |||
| 734 | container_class->forall = ctk_window_forall; | |||
| 735 | ||||
| 736 | klass->set_focus = ctk_window_real_set_focus; | |||
| 737 | ||||
| 738 | klass->activate_default = ctk_window_real_activate_default; | |||
| 739 | klass->activate_focus = ctk_window_real_activate_focus; | |||
| 740 | klass->keys_changed = ctk_window_keys_changed; | |||
| 741 | klass->enable_debugging = ctk_window_enable_debugging; | |||
| 742 | ||||
| 743 | window_props[PROP_TYPE] = | |||
| 744 | g_param_spec_enum ("type", | |||
| 745 | P_("Window Type")g_dgettext("ctk30" "-properties","Window Type"), | |||
| 746 | P_("The type of the window")g_dgettext("ctk30" "-properties","The type of the window"), | |||
| 747 | CTK_TYPE_WINDOW_TYPE(ctk_window_type_get_type ()), | |||
| 748 | CTK_WINDOW_TOPLEVEL, | |||
| 749 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY); | |||
| 750 | ||||
| 751 | window_props[PROP_TITLE] = | |||
| 752 | g_param_spec_string ("title", | |||
| 753 | P_("Window Title")g_dgettext("ctk30" "-properties","Window Title"), | |||
| 754 | P_("The title of the window")g_dgettext("ctk30" "-properties","The title of the window"), | |||
| 755 | NULL((void*)0), | |||
| 756 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); | |||
| 757 | ||||
| 758 | window_props[PROP_ROLE] = | |||
| 759 | g_param_spec_string ("role", | |||
| 760 | P_("Window Role")g_dgettext("ctk30" "-properties","Window Role"), | |||
| 761 | P_("Unique identifier for the window to be used when restoring a session")g_dgettext("ctk30" "-properties","Unique identifier for the window to be used when restoring a session" ), | |||
| 762 | NULL((void*)0), | |||
| 763 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); | |||
| 764 | ||||
| 765 | /** | |||
| 766 | * CtkWindow:startup-id: | |||
| 767 | * | |||
| 768 | * The :startup-id is a write-only property for setting window's | |||
| 769 | * startup notification identifier. See ctk_window_set_startup_id() | |||
| 770 | * for more details. | |||
| 771 | * | |||
| 772 | * Since: 2.12 | |||
| 773 | */ | |||
| 774 | window_props[PROP_STARTUP_ID] = | |||
| 775 | g_param_spec_string ("startup-id", | |||
| 776 | P_("Startup ID")g_dgettext("ctk30" "-properties","Startup ID"), | |||
| 777 | P_("Unique startup identifier for the window used by startup-notification")g_dgettext("ctk30" "-properties","Unique startup identifier for the window used by startup-notification" ), | |||
| 778 | NULL((void*)0), | |||
| 779 | CTK_PARAM_WRITABLEG_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); | |||
| 780 | ||||
| 781 | window_props[PROP_RESIZABLE] = | |||
| 782 | g_param_spec_boolean ("resizable", | |||
| 783 | P_("Resizable")g_dgettext("ctk30" "-properties","Resizable"), | |||
| 784 | P_("If TRUE, users can resize the window")g_dgettext("ctk30" "-properties","If TRUE, users can resize the window" ), | |||
| 785 | TRUE(!(0)), | |||
| 786 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 787 | ||||
| 788 | window_props[PROP_MODAL] = | |||
| 789 | g_param_spec_boolean ("modal", | |||
| 790 | P_("Modal")g_dgettext("ctk30" "-properties","Modal"), | |||
| 791 | P_("If TRUE, the window is modal (other windows are not usable while this one is up)")g_dgettext("ctk30" "-properties","If TRUE, the window is modal (other windows are not usable while this one is up)" ), | |||
| 792 | FALSE(0), | |||
| 793 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 794 | ||||
| 795 | window_props[PROP_WIN_POS] = | |||
| 796 | g_param_spec_enum ("window-position", | |||
| 797 | P_("Window Position")g_dgettext("ctk30" "-properties","Window Position"), | |||
| 798 | P_("The initial position of the window")g_dgettext("ctk30" "-properties","The initial position of the window" ), | |||
| 799 | CTK_TYPE_WINDOW_POSITION(ctk_window_position_get_type ()), | |||
| 800 | CTK_WIN_POS_NONE, | |||
| 801 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 802 | ||||
| 803 | window_props[PROP_DEFAULT_WIDTH] = | |||
| 804 | g_param_spec_int ("default-width", | |||
| 805 | P_("Default Width")g_dgettext("ctk30" "-properties","Default Width"), | |||
| 806 | P_("The default width of the window, used when initially showing the window")g_dgettext("ctk30" "-properties","The default width of the window, used when initially showing the window" ), | |||
| 807 | -1, G_MAXINT2147483647, | |||
| 808 | -1, | |||
| 809 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 810 | ||||
| 811 | window_props[PROP_DEFAULT_HEIGHT] = | |||
| 812 | g_param_spec_int ("default-height", | |||
| 813 | P_("Default Height")g_dgettext("ctk30" "-properties","Default Height"), | |||
| 814 | P_("The default height of the window, used when initially showing the window")g_dgettext("ctk30" "-properties","The default height of the window, used when initially showing the window" ), | |||
| 815 | -1, G_MAXINT2147483647, | |||
| 816 | -1, | |||
| 817 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 818 | ||||
| 819 | window_props[PROP_DESTROY_WITH_PARENT] = | |||
| 820 | g_param_spec_boolean ("destroy-with-parent", | |||
| 821 | P_("Destroy with Parent")g_dgettext("ctk30" "-properties","Destroy with Parent"), | |||
| 822 | P_("If this window should be destroyed when the parent is destroyed")g_dgettext("ctk30" "-properties","If this window should be destroyed when the parent is destroyed" ), | |||
| 823 | FALSE(0), | |||
| 824 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 825 | ||||
| 826 | /** | |||
| 827 | * CtkWindow:hide-titlebar-when-maximized: | |||
| 828 | * | |||
| 829 | * Whether the titlebar should be hidden during maximization. | |||
| 830 | * | |||
| 831 | * Since: 3.4 | |||
| 832 | */ | |||
| 833 | window_props[PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED] = | |||
| 834 | g_param_spec_boolean ("hide-titlebar-when-maximized", | |||
| 835 | P_("Hide the titlebar during maximization")g_dgettext("ctk30" "-properties","Hide the titlebar during maximization" ), | |||
| 836 | P_("If this window's titlebar should be hidden when the window is maximized")g_dgettext("ctk30" "-properties","If this window's titlebar should be hidden when the window is maximized" ), | |||
| 837 | FALSE(0), | |||
| 838 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 839 | ||||
| 840 | window_props[PROP_ICON] = | |||
| 841 | g_param_spec_object ("icon", | |||
| 842 | P_("Icon")g_dgettext("ctk30" "-properties","Icon"), | |||
| 843 | P_("Icon for this window")g_dgettext("ctk30" "-properties","Icon for this window"), | |||
| 844 | CDK_TYPE_PIXBUF(cdk_pixbuf_get_type ()), | |||
| 845 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 846 | ||||
| 847 | /** | |||
| 848 | * CtkWindow:mnemonics-visible: | |||
| 849 | * | |||
| 850 | * Whether mnemonics are currently visible in this window. | |||
| 851 | * | |||
| 852 | * This property is maintained by CTK+ based on user input, | |||
| 853 | * and should not be set by applications. | |||
| 854 | * | |||
| 855 | * Since: 2.20 | |||
| 856 | */ | |||
| 857 | window_props[PROP_MNEMONICS_VISIBLE] = | |||
| 858 | g_param_spec_boolean ("mnemonics-visible", | |||
| 859 | P_("Mnemonics Visible")g_dgettext("ctk30" "-properties","Mnemonics Visible"), | |||
| 860 | P_("Whether mnemonics are currently visible in this window")g_dgettext("ctk30" "-properties","Whether mnemonics are currently visible in this window" ), | |||
| 861 | TRUE(!(0)), | |||
| 862 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 863 | ||||
| 864 | /** | |||
| 865 | * CtkWindow:focus-visible: | |||
| 866 | * | |||
| 867 | * Whether 'focus rectangles' are currently visible in this window. | |||
| 868 | * | |||
| 869 | * This property is maintained by CTK+ based on user input | |||
| 870 | * and should not be set by applications. | |||
| 871 | * | |||
| 872 | * Since: 2.20 | |||
| 873 | */ | |||
| 874 | window_props[PROP_FOCUS_VISIBLE] = | |||
| 875 | g_param_spec_boolean ("focus-visible", | |||
| 876 | P_("Focus Visible")g_dgettext("ctk30" "-properties","Focus Visible"), | |||
| 877 | P_("Whether focus rectangles are currently visible in this window")g_dgettext("ctk30" "-properties","Whether focus rectangles are currently visible in this window" ), | |||
| 878 | TRUE(!(0)), | |||
| 879 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 880 | ||||
| 881 | /** | |||
| 882 | * CtkWindow:icon-name: | |||
| 883 | * | |||
| 884 | * The :icon-name property specifies the name of the themed icon to | |||
| 885 | * use as the window icon. See #CtkIconTheme for more details. | |||
| 886 | * | |||
| 887 | * Since: 2.6 | |||
| 888 | */ | |||
| 889 | window_props[PROP_ICON_NAME] = | |||
| 890 | g_param_spec_string ("icon-name", | |||
| 891 | P_("Icon Name")g_dgettext("ctk30" "-properties","Icon Name"), | |||
| 892 | P_("Name of the themed icon for this window")g_dgettext("ctk30" "-properties","Name of the themed icon for this window" ), | |||
| 893 | NULL((void*)0), | |||
| 894 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 895 | ||||
| 896 | window_props[PROP_SCREEN] = | |||
| 897 | g_param_spec_object ("screen", | |||
| 898 | P_("Screen")g_dgettext("ctk30" "-properties","Screen"), | |||
| 899 | P_("The screen where this window will be displayed")g_dgettext("ctk30" "-properties","The screen where this window will be displayed" ), | |||
| 900 | CDK_TYPE_SCREEN(cdk_screen_get_type ()), | |||
| 901 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 902 | ||||
| 903 | window_props[PROP_IS_ACTIVE] = | |||
| 904 | g_param_spec_boolean ("is-active", | |||
| 905 | P_("Is Active")g_dgettext("ctk30" "-properties","Is Active"), | |||
| 906 | P_("Whether the toplevel is the current active window")g_dgettext("ctk30" "-properties","Whether the toplevel is the current active window" ), | |||
| 907 | FALSE(0), | |||
| 908 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); | |||
| 909 | ||||
| 910 | window_props[PROP_HAS_TOPLEVEL_FOCUS] = | |||
| 911 | g_param_spec_boolean ("has-toplevel-focus", | |||
| 912 | P_("Focus in Toplevel")g_dgettext("ctk30" "-properties","Focus in Toplevel"), | |||
| 913 | P_("Whether the input focus is within this CtkWindow")g_dgettext("ctk30" "-properties","Whether the input focus is within this CtkWindow" ), | |||
| 914 | FALSE(0), | |||
| 915 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); | |||
| 916 | ||||
| 917 | window_props[PROP_TYPE_HINT] = | |||
| 918 | g_param_spec_enum ("type-hint", | |||
| 919 | P_("Type hint")g_dgettext("ctk30" "-properties","Type hint"), | |||
| 920 | P_("Hint to help the desktop environment understand what kind of window this is and how to treat it.")g_dgettext("ctk30" "-properties","Hint to help the desktop environment understand what kind of window this is and how to treat it." ), | |||
| 921 | CDK_TYPE_WINDOW_TYPE_HINT(cdk_window_type_hint_get_type ()), | |||
| 922 | CDK_WINDOW_TYPE_HINT_NORMAL, | |||
| 923 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 924 | ||||
| 925 | window_props[PROP_SKIP_TASKBAR_HINT] = | |||
| 926 | g_param_spec_boolean ("skip-taskbar-hint", | |||
| 927 | P_("Skip taskbar")g_dgettext("ctk30" "-properties","Skip taskbar"), | |||
| 928 | P_("TRUE if the window should not be in the task bar.")g_dgettext("ctk30" "-properties","TRUE if the window should not be in the task bar." ), | |||
| 929 | FALSE(0), | |||
| 930 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 931 | ||||
| 932 | window_props[PROP_SKIP_PAGER_HINT] = | |||
| 933 | g_param_spec_boolean ("skip-pager-hint", | |||
| 934 | P_("Skip pager")g_dgettext("ctk30" "-properties","Skip pager"), | |||
| 935 | P_("TRUE if the window should not be in the pager.")g_dgettext("ctk30" "-properties","TRUE if the window should not be in the pager." ), | |||
| 936 | FALSE(0), | |||
| 937 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 938 | ||||
| 939 | window_props[PROP_URGENCY_HINT] = | |||
| 940 | g_param_spec_boolean ("urgency-hint", | |||
| 941 | P_("Urgent")g_dgettext("ctk30" "-properties","Urgent"), | |||
| 942 | P_("TRUE if the window should be brought to the user's attention.")g_dgettext("ctk30" "-properties","TRUE if the window should be brought to the user's attention." ), | |||
| 943 | FALSE(0), | |||
| 944 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 945 | ||||
| 946 | /** | |||
| 947 | * CtkWindow:accept-focus: | |||
| 948 | * | |||
| 949 | * Whether the window should receive the input focus. | |||
| 950 | * | |||
| 951 | * Since: 2.4 | |||
| 952 | */ | |||
| 953 | window_props[PROP_ACCEPT_FOCUS] = | |||
| 954 | g_param_spec_boolean ("accept-focus", | |||
| 955 | P_("Accept focus")g_dgettext("ctk30" "-properties","Accept focus"), | |||
| 956 | P_("TRUE if the window should receive the input focus.")g_dgettext("ctk30" "-properties","TRUE if the window should receive the input focus." ), | |||
| 957 | TRUE(!(0)), | |||
| 958 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 959 | ||||
| 960 | /** | |||
| 961 | * CtkWindow:focus-on-map: | |||
| 962 | * | |||
| 963 | * Whether the window should receive the input focus when mapped. | |||
| 964 | * | |||
| 965 | * Since: 2.6 | |||
| 966 | */ | |||
| 967 | window_props[PROP_FOCUS_ON_MAP] = | |||
| 968 | g_param_spec_boolean ("focus-on-map", | |||
| 969 | P_("Focus on map")g_dgettext("ctk30" "-properties","Focus on map"), | |||
| 970 | P_("TRUE if the window should receive the input focus when mapped.")g_dgettext("ctk30" "-properties","TRUE if the window should receive the input focus when mapped." ), | |||
| 971 | TRUE(!(0)), | |||
| 972 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 973 | ||||
| 974 | /** | |||
| 975 | * CtkWindow:decorated: | |||
| 976 | * | |||
| 977 | * Whether the window should be decorated by the window manager. | |||
| 978 | * | |||
| 979 | * Since: 2.4 | |||
| 980 | */ | |||
| 981 | window_props[PROP_DECORATED] = | |||
| 982 | g_param_spec_boolean ("decorated", | |||
| 983 | P_("Decorated")g_dgettext("ctk30" "-properties","Decorated"), | |||
| 984 | P_("Whether the window should be decorated by the window manager")g_dgettext("ctk30" "-properties","Whether the window should be decorated by the window manager" ), | |||
| 985 | TRUE(!(0)), | |||
| 986 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 987 | ||||
| 988 | /** | |||
| 989 | * CtkWindow:deletable: | |||
| 990 | * | |||
| 991 | * Whether the window frame should have a close button. | |||
| 992 | * | |||
| 993 | * Since: 2.10 | |||
| 994 | */ | |||
| 995 | window_props[PROP_DELETABLE] = | |||
| 996 | g_param_spec_boolean ("deletable", | |||
| 997 | P_("Deletable")g_dgettext("ctk30" "-properties","Deletable"), | |||
| 998 | P_("Whether the window frame should have a close button")g_dgettext("ctk30" "-properties","Whether the window frame should have a close button" ), | |||
| 999 | TRUE(!(0)), | |||
| 1000 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 1001 | ||||
| 1002 | /** | |||
| 1003 | * CtkWindow:has-resize-grip: | |||
| 1004 | * | |||
| 1005 | * Whether the window has a corner resize grip. | |||
| 1006 | * | |||
| 1007 | * Note that the resize grip is only shown if the window is | |||
| 1008 | * actually resizable and not maximized. Use | |||
| 1009 | * #CtkWindow:resize-grip-visible to find out if the resize | |||
| 1010 | * grip is currently shown. | |||
| 1011 | * | |||
| 1012 | * Deprecated: 3.14: Resize grips have been removed. | |||
| 1013 | * | |||
| 1014 | * Since: 3.0 | |||
| 1015 | */ | |||
| 1016 | window_props[PROP_HAS_RESIZE_GRIP] = | |||
| 1017 | g_param_spec_boolean ("has-resize-grip", | |||
| 1018 | P_("Resize grip")g_dgettext("ctk30" "-properties","Resize grip"), | |||
| 1019 | P_("Specifies whether the window should have a resize grip")g_dgettext("ctk30" "-properties","Specifies whether the window should have a resize grip" ), | |||
| 1020 | FALSE(0), | |||
| 1021 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED); | |||
| 1022 | ||||
| 1023 | /** | |||
| 1024 | * CtkWindow:resize-grip-visible: | |||
| 1025 | * | |||
| 1026 | * Whether a corner resize grip is currently shown. | |||
| 1027 | * | |||
| 1028 | * Deprecated: 3.14: Resize grips have been removed. | |||
| 1029 | * | |||
| 1030 | * Since: 3.0 | |||
| 1031 | */ | |||
| 1032 | window_props[PROP_RESIZE_GRIP_VISIBLE] = | |||
| 1033 | g_param_spec_boolean ("resize-grip-visible", | |||
| 1034 | P_("Resize grip is visible")g_dgettext("ctk30" "-properties","Resize grip is visible"), | |||
| 1035 | P_("Specifies whether the window's resize grip is visible.")g_dgettext("ctk30" "-properties","Specifies whether the window's resize grip is visible." ), | |||
| 1036 | FALSE(0), | |||
| 1037 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED); | |||
| 1038 | ||||
| 1039 | /** | |||
| 1040 | * CtkWindow:gravity: | |||
| 1041 | * | |||
| 1042 | * The window gravity of the window. See ctk_window_move() and #CdkGravity for | |||
| 1043 | * more details about window gravity. | |||
| 1044 | * | |||
| 1045 | * Since: 2.4 | |||
| 1046 | */ | |||
| 1047 | window_props[PROP_GRAVITY] = | |||
| 1048 | g_param_spec_enum ("gravity", | |||
| 1049 | P_("Gravity")g_dgettext("ctk30" "-properties","Gravity"), | |||
| 1050 | P_("The window gravity of the window")g_dgettext("ctk30" "-properties","The window gravity of the window" ), | |||
| 1051 | CDK_TYPE_GRAVITY(cdk_gravity_get_type ()), | |||
| 1052 | CDK_GRAVITY_NORTH_WEST, | |||
| 1053 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); | |||
| 1054 | ||||
| 1055 | /** | |||
| 1056 | * CtkWindow:transient-for: | |||
| 1057 | * | |||
| 1058 | * The transient parent of the window. See ctk_window_set_transient_for() for | |||
| 1059 | * more details about transient windows. | |||
| 1060 | * | |||
| 1061 | * Since: 2.10 | |||
| 1062 | */ | |||
| 1063 | window_props[PROP_TRANSIENT_FOR] = | |||
| 1064 | g_param_spec_object ("transient-for", | |||
| 1065 | P_("Transient for Window")g_dgettext("ctk30" "-properties","Transient for Window"), | |||
| 1066 | P_("The transient parent of the dialog")g_dgettext("ctk30" "-properties","The transient parent of the dialog" ), | |||
| 1067 | CTK_TYPE_WINDOW(ctk_window_get_type ()), | |||
| 1068 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY); | |||
| 1069 | ||||
| 1070 | /** | |||
| 1071 | * CtkWindow:attached-to: | |||
| 1072 | * | |||
| 1073 | * The widget to which this window is attached. | |||
| 1074 | * See ctk_window_set_attached_to(). | |||
| 1075 | * | |||
| 1076 | * Examples of places where specifying this relation is useful are | |||
| 1077 | * for instance a #CtkMenu created by a #CtkComboBox, a completion | |||
| 1078 | * popup window created by #CtkEntry or a typeahead search entry | |||
| 1079 | * created by #CtkTreeView. | |||
| 1080 | * | |||
| 1081 | * Since: 3.4 | |||
| 1082 | */ | |||
| 1083 | window_props[PROP_ATTACHED_TO] = | |||
| 1084 | g_param_spec_object ("attached-to", | |||
| 1085 | P_("Attached to Widget")g_dgettext("ctk30" "-properties","Attached to Widget"), | |||
| 1086 | P_("The widget where the window is attached")g_dgettext("ctk30" "-properties","The widget where the window is attached" ), | |||
| 1087 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), | |||
| 1088 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY); | |||
| 1089 | ||||
| 1090 | window_props[PROP_IS_MAXIMIZED] = | |||
| 1091 | g_param_spec_boolean ("is-maximized", | |||
| 1092 | P_("Is maximized")g_dgettext("ctk30" "-properties","Is maximized"), | |||
| 1093 | P_("Whether the window is maximized")g_dgettext("ctk30" "-properties","Whether the window is maximized" ), | |||
| 1094 | FALSE(0), | |||
| 1095 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB); | |||
| 1096 | ||||
| 1097 | /** | |||
| 1098 | * CtkWindow:application: | |||
| 1099 | * | |||
| 1100 | * The #CtkApplication associated with the window. | |||
| 1101 | * | |||
| 1102 | * The application will be kept alive for at least as long as it | |||
| 1103 | * has any windows associated with it (see g_application_hold() | |||
| 1104 | * for a way to keep it alive without windows). | |||
| 1105 | * | |||
| 1106 | * Normally, the connection between the application and the window | |||
| 1107 | * will remain until the window is destroyed, but you can explicitly | |||
| 1108 | * remove it by setting the :application property to %NULL. | |||
| 1109 | * | |||
| 1110 | * Since: 3.0 | |||
| 1111 | */ | |||
| 1112 | window_props[PROP_APPLICATION] = | |||
| 1113 | g_param_spec_object ("application", | |||
| 1114 | P_("CtkApplication")g_dgettext("ctk30" "-properties","CtkApplication"), | |||
| 1115 | P_("The CtkApplication for the window")g_dgettext("ctk30" "-properties","The CtkApplication for the window" ), | |||
| 1116 | CTK_TYPE_APPLICATION(ctk_application_get_type ()), | |||
| 1117 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB )|G_PARAM_EXPLICIT_NOTIFY); | |||
| 1118 | ||||
| 1119 | g_object_class_install_properties (gobject_class, LAST_ARG, window_props); | |||
| 1120 | ||||
| 1121 | /* Style properties. | |||
| 1122 | */ | |||
| 1123 | ctk_widget_class_install_style_property (widget_class, | |||
| 1124 | g_param_spec_string ("decoration-button-layout", | |||
| 1125 | P_("Decorated button layout")g_dgettext("ctk30" "-properties","Decorated button layout"), | |||
| 1126 | P_("Decorated button layout")g_dgettext("ctk30" "-properties","Decorated button layout"), | |||
| 1127 | "menu:close", | |||
| 1128 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED)); | |||
| 1129 | ||||
| 1130 | ctk_widget_class_install_style_property (widget_class, | |||
| 1131 | g_param_spec_int ("decoration-resize-handle", | |||
| 1132 | P_("Decoration resize handle size")g_dgettext("ctk30" "-properties","Decoration resize handle size" ), | |||
| 1133 | P_("Decoration resize handle size")g_dgettext("ctk30" "-properties","Decoration resize handle size" ), | |||
| 1134 | 0, G_MAXINT2147483647, | |||
| 1135 | 20, CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 1136 | ||||
| 1137 | /** | |||
| 1138 | * CtkWindow::set-focus: | |||
| 1139 | * @window: the window which received the signal | |||
| 1140 | * @widget: (nullable): the newly focused widget (or %NULL for no focus) | |||
| 1141 | * | |||
| 1142 | * This signal is emitted whenever the currently focused widget in | |||
| 1143 | * this window changes. | |||
| 1144 | * | |||
| 1145 | * Since: 2.24 | |||
| 1146 | */ | |||
| 1147 | window_signals[SET_FOCUS] = | |||
| 1148 | g_signal_new (I_("set-focus")g_intern_static_string ("set-focus"), | |||
| 1149 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
| 1150 | G_SIGNAL_RUN_LAST, | |||
| 1151 | G_STRUCT_OFFSET (CtkWindowClass, set_focus)((glong) __builtin_offsetof(CtkWindowClass, set_focus)), | |||
| 1152 | NULL((void*)0), NULL((void*)0), | |||
| 1153 | NULL((void*)0), | |||
| 1154 | G_TYPE_NONE((GType) ((1) << (2))), 1, | |||
| 1155 | CTK_TYPE_WIDGET(ctk_widget_get_type ())); | |||
| 1156 | ||||
| 1157 | /** | |||
| 1158 | * CtkWindow::activate-focus: | |||
| 1159 | * @window: the window which received the signal | |||
| 1160 | * | |||
| 1161 | * The ::activate-focus signal is a | |||
| 1162 | * [keybinding signal][CtkBindingSignal] | |||
| 1163 | * which gets emitted when the user activates the currently | |||
| 1164 | * focused widget of @window. | |||
| 1165 | */ | |||
| 1166 | window_signals[ACTIVATE_FOCUS] = | |||
| 1167 | g_signal_new (I_("activate-focus")g_intern_static_string ("activate-focus"), | |||
| 1168 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
| 1169 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
| 1170 | G_STRUCT_OFFSET (CtkWindowClass, activate_focus)((glong) __builtin_offsetof(CtkWindowClass, activate_focus)), | |||
| 1171 | NULL((void*)0), NULL((void*)0), | |||
| 1172 | NULL((void*)0), | |||
| 1173 | G_TYPE_NONE((GType) ((1) << (2))), | |||
| 1174 | 0); | |||
| 1175 | ||||
| 1176 | /** | |||
| 1177 | * CtkWindow::activate-default: | |||
| 1178 | * @window: the window which received the signal | |||
| 1179 | * | |||
| 1180 | * The ::activate-default signal is a | |||
| 1181 | * [keybinding signal][CtkBindingSignal] | |||
| 1182 | * which gets emitted when the user activates the default widget | |||
| 1183 | * of @window. | |||
| 1184 | */ | |||
| 1185 | window_signals[ACTIVATE_DEFAULT] = | |||
| 1186 | g_signal_new (I_("activate-default")g_intern_static_string ("activate-default"), | |||
| 1187 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
| 1188 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
| 1189 | G_STRUCT_OFFSET (CtkWindowClass, activate_default)((glong) __builtin_offsetof(CtkWindowClass, activate_default) ), | |||
| 1190 | NULL((void*)0), NULL((void*)0), | |||
| 1191 | NULL((void*)0), | |||
| 1192 | G_TYPE_NONE((GType) ((1) << (2))), | |||
| 1193 | 0); | |||
| 1194 | ||||
| 1195 | /** | |||
| 1196 | * CtkWindow::keys-changed: | |||
| 1197 | * @window: the window which received the signal | |||
| 1198 | * | |||
| 1199 | * The ::keys-changed signal gets emitted when the set of accelerators | |||
| 1200 | * or mnemonics that are associated with @window changes. | |||
| 1201 | */ | |||
| 1202 | window_signals[KEYS_CHANGED] = | |||
| 1203 | g_signal_new (I_("keys-changed")g_intern_static_string ("keys-changed"), | |||
| 1204 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
| 1205 | G_SIGNAL_RUN_FIRST, | |||
| 1206 | G_STRUCT_OFFSET (CtkWindowClass, keys_changed)((glong) __builtin_offsetof(CtkWindowClass, keys_changed)), | |||
| 1207 | NULL((void*)0), NULL((void*)0), | |||
| 1208 | NULL((void*)0), | |||
| 1209 | G_TYPE_NONE((GType) ((1) << (2))), | |||
| 1210 | 0); | |||
| 1211 | ||||
| 1212 | /** | |||
| 1213 | * CtkWindow::enable-debugging: | |||
| 1214 | * @window: the window on which the signal is emitted | |||
| 1215 | * @toggle: toggle the debugger | |||
| 1216 | * | |||
| 1217 | * The ::enable-debugging signal is a [keybinding signal][CtkBindingSignal] | |||
| 1218 | * which gets emitted when the user enables or disables interactive | |||
| 1219 | * debugging. When @toggle is %TRUE, interactive debugging is toggled | |||
| 1220 | * on or off, when it is %FALSE, the debugger will be pointed at the | |||
| 1221 | * widget under the pointer. | |||
| 1222 | * | |||
| 1223 | * The default bindings for this signal are Ctrl-Shift-I | |||
| 1224 | * and Ctrl-Shift-D. | |||
| 1225 | * | |||
| 1226 | * Return: %TRUE if the key binding was handled | |||
| 1227 | */ | |||
| 1228 | window_signals[ENABLE_DEBUGGING] = | |||
| 1229 | g_signal_new (I_("enable-debugging")g_intern_static_string ("enable-debugging"), | |||
| 1230 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
| 1231 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
| 1232 | G_STRUCT_OFFSET (CtkWindowClass, enable_debugging)((glong) __builtin_offsetof(CtkWindowClass, enable_debugging) ), | |||
| 1233 | NULL((void*)0), NULL((void*)0), | |||
| 1234 | _ctk_marshal_BOOLEAN__BOOLEAN, | |||
| 1235 | G_TYPE_BOOLEAN((GType) ((5) << (2))), | |||
| 1236 | 1, G_TYPE_BOOLEAN((GType) ((5) << (2)))); | |||
| 1237 | ||||
| 1238 | /* | |||
| 1239 | * Key bindings | |||
| 1240 | */ | |||
| 1241 | ||||
| 1242 | binding_set = ctk_binding_set_by_class (klass); | |||
| 1243 | ||||
| 1244 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_space0x020, 0, | |||
| 1245 | "activate-focus", 0); | |||
| 1246 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Space0xff80, 0, | |||
| 1247 | "activate-focus", 0); | |||
| 1248 | ||||
| 1249 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Return0xff0d, 0, | |||
| 1250 | "activate-default", 0); | |||
| 1251 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_ISO_Enter0xfe34, 0, | |||
| 1252 | "activate-default", 0); | |||
| 1253 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Enter0xff8d, 0, | |||
| 1254 | "activate-default", 0); | |||
| 1255 | ||||
| 1256 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_I0x049, CDK_CONTROL_MASK|CDK_SHIFT_MASK, | |||
| 1257 | "enable-debugging", 1, | |||
| 1258 | G_TYPE_BOOLEAN((GType) ((5) << (2))), FALSE(0)); | |||
| 1259 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_D0x044, CDK_CONTROL_MASK|CDK_SHIFT_MASK, | |||
| 1260 | "enable-debugging", 1, | |||
| 1261 | G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0))); | |||
| 1262 | ||||
| 1263 | add_arrow_bindings (binding_set, CDK_KEY_Up0xff52, CTK_DIR_UP); | |||
| 1264 | add_arrow_bindings (binding_set, CDK_KEY_Down0xff54, CTK_DIR_DOWN); | |||
| 1265 | add_arrow_bindings (binding_set, CDK_KEY_Left0xff51, CTK_DIR_LEFT); | |||
| 1266 | add_arrow_bindings (binding_set, CDK_KEY_Right0xff53, CTK_DIR_RIGHT); | |||
| 1267 | ||||
| 1268 | add_tab_bindings (binding_set, 0, CTK_DIR_TAB_FORWARD); | |||
| 1269 | add_tab_bindings (binding_set, CDK_CONTROL_MASK, CTK_DIR_TAB_FORWARD); | |||
| 1270 | add_tab_bindings (binding_set, CDK_SHIFT_MASK, CTK_DIR_TAB_BACKWARD); | |||
| 1271 | add_tab_bindings (binding_set, CDK_CONTROL_MASK | CDK_SHIFT_MASK, CTK_DIR_TAB_BACKWARD); | |||
| 1272 | ||||
| 1273 | ctk_widget_class_set_accessible_type (widget_class, CTK_TYPE_WINDOW_ACCESSIBLE(ctk_window_accessible_get_type ())); | |||
| 1274 | ctk_widget_class_set_css_name (widget_class, "window"); | |||
| 1275 | } | |||
| 1276 | ||||
| 1277 | /** | |||
| 1278 | * ctk_window_is_maximized: | |||
| 1279 | * @window: a #CtkWindow | |||
| 1280 | * | |||
| 1281 | * Retrieves the current maximized state of @window. | |||
| 1282 | * | |||
| 1283 | * Note that since maximization is ultimately handled by the window | |||
| 1284 | * manager and happens asynchronously to an application request, you | |||
| 1285 | * shouldn’t assume the return value of this function changing | |||
| 1286 | * immediately (or at all), as an effect of calling | |||
| 1287 | * ctk_window_maximize() or ctk_window_unmaximize(). | |||
| 1288 | * | |||
| 1289 | * Returns: whether the window has a maximized state. | |||
| 1290 | * | |||
| 1291 | * Since: 3.12 | |||
| 1292 | */ | |||
| 1293 | gboolean | |||
| 1294 | ctk_window_is_maximized (CtkWindow *window) | |||
| 1295 | { | |||
| 1296 | CtkWindowPrivate *priv = window->priv; | |||
| 1297 | ||||
| 1298 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 1299 | ||||
| 1300 | return priv->maximized; | |||
| 1301 | } | |||
| 1302 | ||||
| 1303 | void | |||
| 1304 | _ctk_window_toggle_maximized (CtkWindow *window) | |||
| 1305 | { | |||
| 1306 | CtkWindowPrivate *priv = window->priv; | |||
| 1307 | ||||
| 1308 | if (priv->maximized) | |||
| 1309 | ctk_window_unmaximize (window); | |||
| 1310 | else | |||
| 1311 | ctk_window_maximize (window); | |||
| 1312 | } | |||
| 1313 | ||||
| 1314 | static gboolean | |||
| 1315 | send_delete_event (gpointer data) | |||
| 1316 | { | |||
| 1317 | CtkWidget *window = data; | |||
| 1318 | CtkWindowPrivate *priv = CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))->priv; | |||
| 1319 | CdkWindow *cdk_window; | |||
| 1320 | ||||
| 1321 | priv->delete_event_handler = 0; | |||
| 1322 | ||||
| 1323 | cdk_window = _ctk_widget_get_window (window); | |||
| 1324 | if (cdk_window) | |||
| 1325 | { | |||
| 1326 | CdkEvent *event; | |||
| 1327 | ||||
| 1328 | event = cdk_event_new (CDK_DELETE); | |||
| 1329 | event->any.window = g_object_ref (cdk_window)((__typeof__ (cdk_window)) (g_object_ref) (cdk_window)); | |||
| 1330 | event->any.send_event = TRUE(!(0)); | |||
| 1331 | ||||
| 1332 | ctk_main_do_event (event); | |||
| 1333 | ||||
| 1334 | cdk_event_free (event); | |||
| 1335 | } | |||
| 1336 | ||||
| 1337 | return G_SOURCE_REMOVE(0); | |||
| 1338 | } | |||
| 1339 | ||||
| 1340 | /** | |||
| 1341 | * ctk_window_close: | |||
| 1342 | * @window: a #CtkWindow | |||
| 1343 | * | |||
| 1344 | * Requests that the window is closed, similar to what happens | |||
| 1345 | * when a window manager close button is clicked. | |||
| 1346 | * | |||
| 1347 | * This function can be used with close buttons in custom | |||
| 1348 | * titlebars. | |||
| 1349 | * | |||
| 1350 | * Since: 3.10 | |||
| 1351 | */ | |||
| 1352 | void | |||
| 1353 | ctk_window_close (CtkWindow *window) | |||
| 1354 | { | |||
| 1355 | if (!_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 1356 | return; | |||
| 1357 | ||||
| 1358 | window->priv->delete_event_handler = cdk_threads_add_idle_full (G_PRIORITY_DEFAULT0, send_delete_event, window, NULL((void*)0)); | |||
| 1359 | g_source_set_name_by_id (window->priv->delete_event_handler, "[ctk+] send_delete_event"); | |||
| 1360 | } | |||
| 1361 | ||||
| 1362 | static void | |||
| 1363 | popover_destroy (CtkWindowPopover *popover) | |||
| 1364 | { | |||
| 1365 | if (popover->unmap_id) | |||
| 1366 | { | |||
| 1367 | g_signal_handler_disconnect (popover->widget, popover->unmap_id); | |||
| 1368 | popover->unmap_id = 0; | |||
| 1369 | } | |||
| 1370 | ||||
| 1371 | if (popover->widget && _ctk_widget_get_parent (popover->widget)) | |||
| 1372 | ctk_widget_unparent (popover->widget); | |||
| 1373 | ||||
| 1374 | if (popover->window) | |||
| 1375 | cdk_window_destroy (popover->window); | |||
| 1376 | ||||
| 1377 | g_free (popover)(__builtin_object_size ((popover), 0) != ((size_t) - 1)) ? g_free_sized (popover, __builtin_object_size ((popover), 0)) : (g_free) ( popover); | |||
| 1378 | } | |||
| 1379 | ||||
| 1380 | static gboolean | |||
| 1381 | ctk_window_titlebar_action (CtkWindow *window, | |||
| 1382 | const CdkEvent *event, | |||
| 1383 | guint button, | |||
| 1384 | gint n_press) | |||
| 1385 | { | |||
| 1386 | CtkSettings *settings; | |||
| 1387 | gchar *action = NULL((void*)0); | |||
| 1388 | gboolean retval = TRUE(!(0)); | |||
| 1389 | ||||
| 1390 | settings = ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 1391 | switch (button) | |||
| 1392 | { | |||
| 1393 | case CDK_BUTTON_PRIMARY(1): | |||
| 1394 | if (n_press == 2) | |||
| 1395 | g_object_get (settings, "ctk-titlebar-double-click", &action, NULL((void*)0)); | |||
| 1396 | break; | |||
| 1397 | case CDK_BUTTON_MIDDLE(2): | |||
| 1398 | g_object_get (settings, "ctk-titlebar-middle-click", &action, NULL((void*)0)); | |||
| 1399 | break; | |||
| 1400 | case CDK_BUTTON_SECONDARY(3): | |||
| 1401 | g_object_get (settings, "ctk-titlebar-right-click", &action, NULL((void*)0)); | |||
| 1402 | break; | |||
| 1403 | } | |||
| 1404 | ||||
| 1405 | if (action == NULL((void*)0)) | |||
| 1406 | retval = FALSE(0); | |||
| 1407 | else if (g_str_equal (action, "none")(strcmp ((const char *) (action), (const char *) ("none")) == 0)) | |||
| 1408 | retval = FALSE(0); | |||
| 1409 | /* treat all maximization variants the same */ | |||
| 1410 | else if (g_str_has_prefix (action, "toggle-maximize")(__builtin_constant_p ("toggle-maximize")? __extension__ ({ const char * const _str = (action); const char * const _prefix = ( "toggle-maximize"); gboolean _result = (0); if (_str == ((void *)0) || _prefix == ((void*)0)) _result = (g_str_has_prefix) ( _str, _prefix); else { const size_t _str_len = strlen (((_str ) + !(_str))); const size_t _prefix_len = strlen (((_prefix) + !(_prefix))); if (_str_len >= _prefix_len) _result = memcmp (((_str) + !(_str)), ((_prefix) + !(_prefix)), _prefix_len) == 0; } _result; }) : (g_str_has_prefix) (action, "toggle-maximize" ) )) | |||
| 1411 | { | |||
| 1412 | /* | |||
| 1413 | * ctk header bar won't show the maximize button if the following | |||
| 1414 | * properties are not met, apply the same to title bar actions for | |||
| 1415 | * consistency. | |||
| 1416 | */ | |||
| 1417 | if (ctk_window_get_resizable (window) && | |||
| 1418 | ctk_window_get_type_hint (window) == CDK_WINDOW_TYPE_HINT_NORMAL) | |||
| 1419 | _ctk_window_toggle_maximized (window); | |||
| 1420 | } | |||
| 1421 | else if (g_str_equal (action, "lower")(strcmp ((const char *) (action), (const char *) ("lower")) == 0)) | |||
| 1422 | cdk_window_lower (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
| 1423 | else if (g_str_equal (action, "minimize")(strcmp ((const char *) (action), (const char *) ("minimize") ) == 0)) | |||
| 1424 | cdk_window_iconify (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
| 1425 | else if (g_str_equal (action, "menu")(strcmp ((const char *) (action), (const char *) ("menu")) == 0)) | |||
| 1426 | ctk_window_do_popup (window, (CdkEventButton*) event); | |||
| 1427 | else | |||
| 1428 | { | |||
| 1429 | g_warning ("Unsupported titlebar action %s", action); | |||
| 1430 | retval = FALSE(0); | |||
| 1431 | } | |||
| 1432 | ||||
| 1433 | g_free (action)(__builtin_object_size ((action), 0) != ((size_t) - 1)) ? g_free_sized (action, __builtin_object_size ((action), 0)) : (g_free) (action ); | |||
| 1434 | ||||
| 1435 | return retval; | |||
| 1436 | } | |||
| 1437 | ||||
| 1438 | static void | |||
| 1439 | multipress_gesture_pressed_cb (CtkGestureMultiPress *gesture, | |||
| 1440 | gint n_press, | |||
| 1441 | gdouble x, | |||
| 1442 | gdouble y, | |||
| 1443 | CtkWindow *window) | |||
| 1444 | { | |||
| 1445 | CtkWidget *event_widget, *widget; | |||
| 1446 | CdkEventSequence *sequence; | |||
| 1447 | CtkWindowRegion region; | |||
| 1448 | CtkWindowPrivate *priv; | |||
| 1449 | const CdkEvent *event; | |||
| 1450 | guint button; | |||
| 1451 | gboolean window_drag = FALSE(0); | |||
| 1452 | ||||
| 1453 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 1454 | priv = ctk_window_get_instance_private (window); | |||
| 1455 | sequence = ctk_gesture_single_get_current_sequence (CTK_GESTURE_SINGLE (gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((gesture)), ((ctk_gesture_single_get_type () ))))))); | |||
| 1456 | button = ctk_gesture_single_get_current_button (CTK_GESTURE_SINGLE (gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((gesture)), ((ctk_gesture_single_get_type () ))))))); | |||
| 1457 | event = ctk_gesture_get_last_event (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), sequence); | |||
| 1458 | ||||
| 1459 | if (!event) | |||
| 1460 | return; | |||
| 1461 | ||||
| 1462 | if (n_press > 1) | |||
| 1463 | ctk_gesture_set_state (priv->drag_gesture, CTK_EVENT_SEQUENCE_DENIED); | |||
| 1464 | ||||
| 1465 | region = get_active_region_type (window, (CdkEventAny*) event, x, y); | |||
| 1466 | ||||
| 1467 | if (cdk_display_device_is_grabbed (ctk_widget_get_display (widget), | |||
| 1468 | ctk_gesture_get_device (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ()))))))))) | |||
| 1469 | { | |||
| 1470 | ctk_gesture_set_state (priv->drag_gesture, CTK_EVENT_SEQUENCE_DENIED); | |||
| 1471 | return; | |||
| 1472 | } | |||
| 1473 | ||||
| 1474 | if (button == CDK_BUTTON_SECONDARY(3) && region == CTK_WINDOW_REGION_TITLE) | |||
| 1475 | { | |||
| 1476 | if (ctk_window_titlebar_action (window, event, button, n_press)) | |||
| 1477 | ctk_gesture_set_sequence_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), | |||
| 1478 | sequence, CTK_EVENT_SEQUENCE_CLAIMED); | |||
| 1479 | ||||
| 1480 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 1481 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (priv->drag_gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((priv->drag_gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 1482 | return; | |||
| 1483 | } | |||
| 1484 | else if (button == CDK_BUTTON_MIDDLE(2) && region == CTK_WINDOW_REGION_TITLE) | |||
| 1485 | { | |||
| 1486 | if (ctk_window_titlebar_action (window, event, button, n_press)) | |||
| 1487 | ctk_gesture_set_sequence_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), | |||
| 1488 | sequence, CTK_EVENT_SEQUENCE_CLAIMED); | |||
| 1489 | return; | |||
| 1490 | } | |||
| 1491 | else if (button != CDK_BUTTON_PRIMARY(1)) | |||
| 1492 | return; | |||
| 1493 | ||||
| 1494 | event_widget = ctk_get_event_widget ((CdkEvent *) event); | |||
| 1495 | ||||
| 1496 | if (region == CTK_WINDOW_REGION_TITLE) | |||
| 1497 | cdk_window_raise (_ctk_widget_get_window (widget)); | |||
| 1498 | ||||
| 1499 | switch (region) | |||
| 1500 | { | |||
| 1501 | case CTK_WINDOW_REGION_CONTENT: | |||
| 1502 | if (event_widget != widget) | |||
| 1503 | ctk_widget_style_get (event_widget, "window-dragging", &window_drag, NULL((void*)0)); | |||
| 1504 | ||||
| 1505 | if (!window_drag) | |||
| 1506 | { | |||
| 1507 | ctk_gesture_set_sequence_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), | |||
| 1508 | sequence, CTK_EVENT_SEQUENCE_DENIED); | |||
| 1509 | return; | |||
| 1510 | } | |||
| 1511 | /* fall through */ | |||
| 1512 | ||||
| 1513 | case CTK_WINDOW_REGION_TITLE: | |||
| 1514 | if (n_press == 2) | |||
| 1515 | ctk_window_titlebar_action (window, event, button, n_press); | |||
| 1516 | ||||
| 1517 | if (ctk_widget_has_grab (widget)) | |||
| 1518 | ctk_gesture_set_sequence_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), | |||
| 1519 | sequence, CTK_EVENT_SEQUENCE_CLAIMED); | |||
| 1520 | break; | |||
| 1521 | default: | |||
| 1522 | if (!priv->maximized) | |||
| 1523 | { | |||
| 1524 | gdouble x_root, y_root; | |||
| 1525 | ||||
| 1526 | ctk_gesture_set_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), CTK_EVENT_SEQUENCE_CLAIMED); | |||
| 1527 | ||||
| 1528 | cdk_event_get_root_coords (event, &x_root, &y_root); | |||
| 1529 | cdk_window_begin_resize_drag_for_device (_ctk_widget_get_window (widget), | |||
| 1530 | (CdkWindowEdge) region, | |||
| 1531 | cdk_event_get_device ((CdkEvent *) event), | |||
| 1532 | CDK_BUTTON_PRIMARY(1), | |||
| 1533 | x_root, y_root, | |||
| 1534 | cdk_event_get_time (event)); | |||
| 1535 | ||||
| 1536 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 1537 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (priv->drag_gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((priv->drag_gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 1538 | } | |||
| 1539 | ||||
| 1540 | break; | |||
| 1541 | } | |||
| 1542 | } | |||
| 1543 | ||||
| 1544 | static void | |||
| 1545 | drag_gesture_begin_cb (CtkGestureDrag *gesture, | |||
| 1546 | gdouble x, | |||
| 1547 | gdouble y, | |||
| 1548 | CtkWindow *window) | |||
| 1549 | { | |||
| 1550 | CdkEventSequence *sequence; | |||
| 1551 | CtkWindowRegion region; | |||
| 1552 | CtkWidget *event_widget; | |||
| 1553 | gboolean widget_drag; | |||
| 1554 | const CdkEvent *event; | |||
| 1555 | ||||
| 1556 | sequence = ctk_gesture_single_get_current_sequence (CTK_GESTURE_SINGLE (gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((gesture)), ((ctk_gesture_single_get_type () ))))))); | |||
| 1557 | event = ctk_gesture_get_last_event (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), sequence); | |||
| 1558 | ||||
| 1559 | if (!event) | |||
| 1560 | return; | |||
| 1561 | ||||
| 1562 | region = get_active_region_type (window, (CdkEventAny*) event, x, y); | |||
| 1563 | ||||
| 1564 | switch (region) | |||
| 1565 | { | |||
| 1566 | case CTK_WINDOW_REGION_TITLE: | |||
| 1567 | /* Claim it */ | |||
| 1568 | break; | |||
| 1569 | case CTK_WINDOW_REGION_CONTENT: | |||
| 1570 | event_widget = ctk_get_event_widget ((CdkEvent *) event); | |||
| 1571 | ||||
| 1572 | ctk_widget_style_get (event_widget, "window-dragging", &widget_drag, NULL((void*)0)); | |||
| 1573 | ||||
| 1574 | if (!widget_drag) | |||
| 1575 | ctk_gesture_set_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), CTK_EVENT_SEQUENCE_DENIED); | |||
| 1576 | ||||
| 1577 | break; | |||
| 1578 | default: | |||
| 1579 | ctk_gesture_set_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), CTK_EVENT_SEQUENCE_DENIED); | |||
| 1580 | } | |||
| 1581 | } | |||
| 1582 | ||||
| 1583 | static void | |||
| 1584 | drag_gesture_update_cb (CtkGestureDrag *gesture, | |||
| 1585 | gdouble offset_x, | |||
| 1586 | gdouble offset_y, | |||
| 1587 | CtkWindow *window) | |||
| 1588 | { | |||
| 1589 | CtkWindowPrivate *priv = window->priv; | |||
| 1590 | gint double_click_distance; | |||
| 1591 | CtkSettings *settings; | |||
| 1592 | ||||
| 1593 | settings = ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 1594 | g_object_get (settings, | |||
| 1595 | "ctk-double-click-distance", &double_click_distance, | |||
| 1596 | NULL((void*)0)); | |||
| 1597 | ||||
| 1598 | if (ABS (offset_x)(((offset_x) < 0) ? -(offset_x) : (offset_x)) > double_click_distance || | |||
| 1599 | ABS (offset_y)(((offset_y) < 0) ? -(offset_y) : (offset_y)) > double_click_distance) | |||
| 1600 | { | |||
| 1601 | CdkEventSequence *sequence; | |||
| 1602 | gdouble start_x, start_y; | |||
| 1603 | gint x_root, y_root; | |||
| 1604 | const CdkEvent *event; | |||
| 1605 | CtkWidget *event_widget; | |||
| 1606 | ||||
| 1607 | sequence = ctk_gesture_single_get_current_sequence (CTK_GESTURE_SINGLE (gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((gesture)), ((ctk_gesture_single_get_type () ))))))); | |||
| 1608 | event = ctk_gesture_get_last_event (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), sequence); | |||
| 1609 | event_widget = ctk_get_event_widget ((CdkEvent *) event); | |||
| 1610 | ||||
| 1611 | /* Check whether the target widget should be left alone at handling | |||
| 1612 | * the sequence, this is better done late to give room for gestures | |||
| 1613 | * there to go denied. | |||
| 1614 | * | |||
| 1615 | * Besides claiming gestures, we must bail out too if there's gestures | |||
| 1616 | * in the "none" state at this point, as those are still handling events | |||
| 1617 | * and can potentially go claimed, and we don't want to stop the target | |||
| 1618 | * widget from doing anything. | |||
| 1619 | */ | |||
| 1620 | if (event_widget != CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))) && | |||
| 1621 | !ctk_widget_has_grab (event_widget) && | |||
| 1622 | _ctk_widget_consumes_motion (event_widget, sequence)) | |||
| 1623 | { | |||
| 1624 | ctk_gesture_set_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), CTK_EVENT_SEQUENCE_DENIED); | |||
| 1625 | return; | |||
| 1626 | } | |||
| 1627 | ||||
| 1628 | ctk_gesture_set_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), CTK_EVENT_SEQUENCE_CLAIMED); | |||
| 1629 | ||||
| 1630 | ctk_gesture_drag_get_start_point (gesture, &start_x, &start_y); | |||
| 1631 | cdk_window_get_root_coords (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 1632 | start_x, start_y, &x_root, &y_root); | |||
| 1633 | ||||
| 1634 | cdk_window_begin_move_drag_for_device (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 1635 | ctk_gesture_get_device (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ()))))))), | |||
| 1636 | ctk_gesture_single_get_current_button (CTK_GESTURE_SINGLE (gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((gesture)), ((ctk_gesture_single_get_type () ))))))), | |||
| 1637 | x_root, y_root, | |||
| 1638 | ctk_get_current_event_time ()); | |||
| 1639 | ||||
| 1640 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 1641 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (priv->multipress_gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((priv->multipress_gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 1642 | } | |||
| 1643 | } | |||
| 1644 | ||||
| 1645 | static void | |||
| 1646 | node_style_changed_cb (CtkCssNode *node G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 1647 | CtkCssStyleChange *change, | |||
| 1648 | CtkWidget *widget) | |||
| 1649 | { | |||
| 1650 | if (ctk_css_style_change_affects (change, CTK_CSS_AFFECTS_SIZE | CTK_CSS_AFFECTS_CLIP)) | |||
| 1651 | ctk_widget_queue_resize (widget); | |||
| 1652 | else | |||
| 1653 | ctk_widget_queue_draw (widget); | |||
| 1654 | } | |||
| 1655 | ||||
| 1656 | static void | |||
| 1657 | ctk_window_init (CtkWindow *window) | |||
| 1658 | { | |||
| 1659 | CtkWindowPrivate *priv; | |||
| 1660 | CtkWidget *widget; | |||
| 1661 | CtkCssNode *widget_node; | |||
| 1662 | ||||
| 1663 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 1664 | ||||
| 1665 | window->priv = ctk_window_get_instance_private (window); | |||
| 1666 | priv = window->priv; | |||
| 1667 | ||||
| 1668 | ctk_widget_set_has_window (widget, TRUE(!(0))); | |||
| 1669 | _ctk_widget_set_is_toplevel (widget, TRUE(!(0))); | |||
| 1670 | _ctk_widget_set_anchored (widget, TRUE(!(0))); | |||
| 1671 | ||||
| 1672 | ctk_container_set_default_resize_mode (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), CTK_RESIZE_QUEUE); | |||
| 1673 | ||||
| 1674 | priv->title = NULL((void*)0); | |||
| 1675 | priv->wmclass_name = g_strdup (g_get_prgname ())g_strdup_inline (g_get_prgname ()); | |||
| 1676 | priv->wmclass_class = g_strdup (cdk_get_program_class ())g_strdup_inline (cdk_get_program_class ()); | |||
| 1677 | priv->wm_role = NULL((void*)0); | |||
| 1678 | priv->geometry_info = NULL((void*)0); | |||
| 1679 | priv->type = CTK_WINDOW_TOPLEVEL; | |||
| 1680 | priv->focus_widget = NULL((void*)0); | |||
| 1681 | priv->default_widget = NULL((void*)0); | |||
| 1682 | priv->configure_request_count = 0; | |||
| 1683 | priv->resizable = TRUE(!(0)); | |||
| 1684 | priv->configure_notify_received = FALSE(0); | |||
| 1685 | priv->position = CTK_WIN_POS_NONE; | |||
| 1686 | priv->need_default_size = TRUE(!(0)); | |||
| 1687 | priv->need_default_position = TRUE(!(0)); | |||
| 1688 | priv->modal = FALSE(0); | |||
| 1689 | priv->gravity = CDK_GRAVITY_NORTH_WEST; | |||
| 1690 | priv->decorated = TRUE(!(0)); | |||
| 1691 | priv->mnemonic_modifier = CDK_MOD1_MASK; | |||
| 1692 | priv->screen = cdk_screen_get_default (); | |||
| 1693 | ||||
| 1694 | priv->accept_focus = TRUE(!(0)); | |||
| 1695 | priv->focus_on_map = TRUE(!(0)); | |||
| 1696 | priv->deletable = TRUE(!(0)); | |||
| 1697 | priv->type_hint = CDK_WINDOW_TYPE_HINT_NORMAL; | |||
| 1698 | priv->startup_id = NULL((void*)0); | |||
| 1699 | priv->initial_timestamp = CDK_CURRENT_TIME0L; | |||
| 1700 | priv->mnemonics_visible = TRUE(!(0)); | |||
| 1701 | priv->focus_visible = TRUE(!(0)); | |||
| 1702 | priv->initial_fullscreen_monitor = -1; | |||
| 1703 | ||||
| 1704 | g_object_ref_sink (window)((__typeof__ (window)) (g_object_ref_sink) (window)); | |||
| 1705 | priv->has_user_ref_count = TRUE(!(0)); | |||
| 1706 | toplevel_list = g_slist_prepend (toplevel_list, window); | |||
| 1707 | ctk_window_update_debugging (); | |||
| 1708 | ||||
| 1709 | if (priv->screen) | |||
| 1710 | { | |||
| 1711 | g_signal_connect (priv->screen, "composited-changed",g_signal_connect_data ((priv->screen), ("composited-changed" ), (((GCallback) (ctk_window_on_composited_changed))), (window ), ((void*)0), (GConnectFlags) 0) | |||
| 1712 | G_CALLBACK (ctk_window_on_composited_changed), window)g_signal_connect_data ((priv->screen), ("composited-changed" ), (((GCallback) (ctk_window_on_composited_changed))), (window ), ((void*)0), (GConnectFlags) 0); | |||
| 1713 | ||||
| 1714 | #ifdef CDK_WINDOWING_X11 | |||
| 1715 | g_signal_connect (ctk_settings_get_for_screen (priv->screen),g_signal_connect_data ((ctk_settings_get_for_screen (priv-> screen)), ("notify::ctk-application-prefer-dark-theme"), (((GCallback ) (ctk_window_on_theme_variant_changed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
| 1716 | "notify::ctk-application-prefer-dark-theme",g_signal_connect_data ((ctk_settings_get_for_screen (priv-> screen)), ("notify::ctk-application-prefer-dark-theme"), (((GCallback ) (ctk_window_on_theme_variant_changed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
| 1717 | G_CALLBACK (ctk_window_on_theme_variant_changed), window)g_signal_connect_data ((ctk_settings_get_for_screen (priv-> screen)), ("notify::ctk-application-prefer-dark-theme"), (((GCallback ) (ctk_window_on_theme_variant_changed))), (window), ((void*) 0), (GConnectFlags) 0); | |||
| 1718 | #endif | |||
| 1719 | } | |||
| 1720 | ||||
| 1721 | widget_node = ctk_widget_get_css_node (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 1722 | priv->decoration_node = ctk_css_node_new (); | |||
| 1723 | ctk_css_node_set_name (priv->decoration_node, I_("decoration")g_intern_static_string ("decoration")); | |||
| 1724 | ctk_css_node_set_parent (priv->decoration_node, widget_node); | |||
| 1725 | ctk_css_node_set_state (priv->decoration_node, ctk_css_node_get_state (widget_node)); | |||
| 1726 | g_signal_connect_object (priv->decoration_node, "style-changed", G_CALLBACK (node_style_changed_cb)((GCallback) (node_style_changed_cb)), window, 0); | |||
| 1727 | g_object_unref (priv->decoration_node); | |||
| 1728 | ||||
| 1729 | ctk_css_node_add_class (widget_node, g_quark_from_static_string (CTK_STYLE_CLASS_BACKGROUND"background")); | |||
| 1730 | ||||
| 1731 | priv->scale = ctk_widget_get_scale_factor (widget); | |||
| 1732 | ||||
| 1733 | #ifdef CDK_WINDOWING_X11 | |||
| 1734 | ctk_drag_dest_set (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), | |||
| 1735 | CTK_DEST_DEFAULT_MOTION | CTK_DEST_DEFAULT_DROP, | |||
| 1736 | dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets)(sizeof (dnd_dest_targets) / sizeof ((dnd_dest_targets)[0])), | |||
| 1737 | CDK_ACTION_MOVE); | |||
| 1738 | #endif | |||
| 1739 | } | |||
| 1740 | ||||
| 1741 | static void | |||
| 1742 | ctk_window_constructed (GObject *object) | |||
| 1743 | { | |||
| 1744 | CtkWindow *window = CTK_WINDOW (object)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_window_get_type ())))))); | |||
| 1745 | CtkWindowPrivate *priv = window->priv; | |||
| 1746 | gboolean is_plug; | |||
| 1747 | ||||
| 1748 | G_OBJECT_CLASS (ctk_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), (((GType) ((20) << (2)) ))))))->constructed (object); | |||
| 1749 | ||||
| 1750 | #ifdef CDK_WINDOWING_X11 | |||
| 1751 | is_plug = CTK_IS_PLUG (window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (window)); GType _t = ((ctk_plug_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; })))); | |||
| 1752 | #else | |||
| 1753 | is_plug = FALSE(0); | |||
| 1754 | #endif | |||
| 1755 | ||||
| 1756 | if (priv->type == CTK_WINDOW_TOPLEVEL && !is_plug) | |||
| 1757 | { | |||
| 1758 | priv->multipress_gesture = ctk_gesture_multi_press_new (CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_widget_get_type ()))))))); | |||
| 1759 | ctk_gesture_single_set_button (CTK_GESTURE_SINGLE (priv->multipress_gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((priv->multipress_gesture)), ((ctk_gesture_single_get_type ())))))), 0); | |||
| 1760 | ctk_event_controller_set_propagation_phase (CTK_EVENT_CONTROLLER (priv->multipress_gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((priv->multipress_gesture)), ((ctk_event_controller_get_type ())))))), | |||
| 1761 | CTK_PHASE_NONE); | |||
| 1762 | g_signal_connect (priv->multipress_gesture, "pressed",g_signal_connect_data ((priv->multipress_gesture), ("pressed" ), (((GCallback) (multipress_gesture_pressed_cb))), (object), ((void*)0), (GConnectFlags) 0) | |||
| 1763 | G_CALLBACK (multipress_gesture_pressed_cb), object)g_signal_connect_data ((priv->multipress_gesture), ("pressed" ), (((GCallback) (multipress_gesture_pressed_cb))), (object), ((void*)0), (GConnectFlags) 0); | |||
| 1764 | ||||
| 1765 | priv->drag_gesture = ctk_gesture_drag_new (CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_widget_get_type ()))))))); | |||
| 1766 | ctk_event_controller_set_propagation_phase (CTK_EVENT_CONTROLLER (priv->drag_gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((priv->drag_gesture)), ((ctk_event_controller_get_type ())))))), | |||
| 1767 | CTK_PHASE_CAPTURE); | |||
| 1768 | g_signal_connect (priv->drag_gesture, "drag-begin",g_signal_connect_data ((priv->drag_gesture), ("drag-begin" ), (((GCallback) (drag_gesture_begin_cb))), (object), ((void* )0), (GConnectFlags) 0) | |||
| 1769 | G_CALLBACK (drag_gesture_begin_cb), object)g_signal_connect_data ((priv->drag_gesture), ("drag-begin" ), (((GCallback) (drag_gesture_begin_cb))), (object), ((void* )0), (GConnectFlags) 0); | |||
| 1770 | g_signal_connect (priv->drag_gesture, "drag-update",g_signal_connect_data ((priv->drag_gesture), ("drag-update" ), (((GCallback) (drag_gesture_update_cb))), (object), ((void *)0), (GConnectFlags) 0) | |||
| 1771 | G_CALLBACK (drag_gesture_update_cb), object)g_signal_connect_data ((priv->drag_gesture), ("drag-update" ), (((GCallback) (drag_gesture_update_cb))), (object), ((void *)0), (GConnectFlags) 0); | |||
| 1772 | } | |||
| 1773 | } | |||
| 1774 | ||||
| 1775 | static void | |||
| 1776 | ctk_window_set_property (GObject *object, | |||
| 1777 | guint prop_id, | |||
| 1778 | const GValue *value, | |||
| 1779 | GParamSpec *pspec) | |||
| 1780 | { | |||
| 1781 | CtkWindow *window = CTK_WINDOW (object)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_window_get_type ())))))); | |||
| 1782 | CtkWindowPrivate *priv = window->priv; | |||
| 1783 | ||||
| 1784 | switch (prop_id) | |||
| 1785 | { | |||
| 1786 | case PROP_TYPE: | |||
| 1787 | priv->type = g_value_get_enum (value); | |||
| 1788 | break; | |||
| 1789 | case PROP_TITLE: | |||
| 1790 | ctk_window_set_title (window, g_value_get_string (value)); | |||
| 1791 | break; | |||
| 1792 | case PROP_ROLE: | |||
| 1793 | ctk_window_set_role (window, g_value_get_string (value)); | |||
| 1794 | break; | |||
| 1795 | case PROP_STARTUP_ID: | |||
| 1796 | ctk_window_set_startup_id (window, g_value_get_string (value)); | |||
| 1797 | break; | |||
| 1798 | case PROP_RESIZABLE: | |||
| 1799 | ctk_window_set_resizable (window, g_value_get_boolean (value)); | |||
| 1800 | break; | |||
| 1801 | case PROP_MODAL: | |||
| 1802 | ctk_window_set_modal (window, g_value_get_boolean (value)); | |||
| 1803 | break; | |||
| 1804 | case PROP_WIN_POS: | |||
| 1805 | ctk_window_set_position (window, g_value_get_enum (value)); | |||
| 1806 | break; | |||
| 1807 | case PROP_DEFAULT_WIDTH: | |||
| 1808 | ctk_window_set_default_size_internal (window, | |||
| 1809 | TRUE(!(0)), g_value_get_int (value), | |||
| 1810 | FALSE(0), -1, FALSE(0)); | |||
| 1811 | break; | |||
| 1812 | case PROP_DEFAULT_HEIGHT: | |||
| 1813 | ctk_window_set_default_size_internal (window, | |||
| 1814 | FALSE(0), -1, | |||
| 1815 | TRUE(!(0)), g_value_get_int (value), FALSE(0)); | |||
| 1816 | break; | |||
| 1817 | case PROP_DESTROY_WITH_PARENT: | |||
| 1818 | ctk_window_set_destroy_with_parent (window, g_value_get_boolean (value)); | |||
| 1819 | break; | |||
| 1820 | case PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED: | |||
| 1821 | ctk_window_set_hide_titlebar_when_maximized (window, g_value_get_boolean (value)); | |||
| 1822 | break; | |||
| 1823 | case PROP_ICON: | |||
| 1824 | ctk_window_set_icon (window, | |||
| 1825 | g_value_get_object (value)); | |||
| 1826 | break; | |||
| 1827 | case PROP_ICON_NAME: | |||
| 1828 | ctk_window_set_icon_name (window, g_value_get_string (value)); | |||
| 1829 | break; | |||
| 1830 | case PROP_SCREEN: | |||
| 1831 | ctk_window_set_screen (window, g_value_get_object (value)); | |||
| 1832 | break; | |||
| 1833 | case PROP_TYPE_HINT: | |||
| 1834 | ctk_window_set_type_hint (window, | |||
| 1835 | g_value_get_enum (value)); | |||
| 1836 | break; | |||
| 1837 | case PROP_SKIP_TASKBAR_HINT: | |||
| 1838 | ctk_window_set_skip_taskbar_hint (window, | |||
| 1839 | g_value_get_boolean (value)); | |||
| 1840 | break; | |||
| 1841 | case PROP_SKIP_PAGER_HINT: | |||
| 1842 | ctk_window_set_skip_pager_hint (window, | |||
| 1843 | g_value_get_boolean (value)); | |||
| 1844 | break; | |||
| 1845 | case PROP_URGENCY_HINT: | |||
| 1846 | ctk_window_set_urgency_hint (window, | |||
| 1847 | g_value_get_boolean (value)); | |||
| 1848 | break; | |||
| 1849 | case PROP_ACCEPT_FOCUS: | |||
| 1850 | ctk_window_set_accept_focus (window, | |||
| 1851 | g_value_get_boolean (value)); | |||
| 1852 | break; | |||
| 1853 | case PROP_FOCUS_ON_MAP: | |||
| 1854 | ctk_window_set_focus_on_map (window, | |||
| 1855 | g_value_get_boolean (value)); | |||
| 1856 | break; | |||
| 1857 | case PROP_DECORATED: | |||
| 1858 | ctk_window_set_decorated (window, g_value_get_boolean (value)); | |||
| 1859 | break; | |||
| 1860 | case PROP_DELETABLE: | |||
| 1861 | ctk_window_set_deletable (window, g_value_get_boolean (value)); | |||
| 1862 | break; | |||
| 1863 | case PROP_GRAVITY: | |||
| 1864 | ctk_window_set_gravity (window, g_value_get_enum (value)); | |||
| 1865 | break; | |||
| 1866 | case PROP_TRANSIENT_FOR: | |||
| 1867 | ctk_window_set_transient_for (window, g_value_get_object (value)); | |||
| 1868 | break; | |||
| 1869 | case PROP_ATTACHED_TO: | |||
| 1870 | ctk_window_set_attached_to (window, g_value_get_object (value)); | |||
| 1871 | break; | |||
| 1872 | case PROP_HAS_RESIZE_GRIP: | |||
| 1873 | /* Do nothing. */ | |||
| 1874 | break; | |||
| 1875 | case PROP_APPLICATION: | |||
| 1876 | ctk_window_set_application (window, g_value_get_object (value)); | |||
| 1877 | break; | |||
| 1878 | case PROP_MNEMONICS_VISIBLE: | |||
| 1879 | ctk_window_set_mnemonics_visible (window, g_value_get_boolean (value)); | |||
| 1880 | break; | |||
| 1881 | case PROP_FOCUS_VISIBLE: | |||
| 1882 | ctk_window_set_focus_visible (window, g_value_get_boolean (value)); | |||
| 1883 | break; | |||
| 1884 | default: | |||
| 1885 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkwindow.c", 1885, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
| 1886 | break; | |||
| 1887 | } | |||
| 1888 | } | |||
| 1889 | ||||
| 1890 | static void | |||
| 1891 | ctk_window_get_property (GObject *object, | |||
| 1892 | guint prop_id, | |||
| 1893 | GValue *value, | |||
| 1894 | GParamSpec *pspec) | |||
| 1895 | { | |||
| 1896 | CtkWindow *window = CTK_WINDOW (object)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_window_get_type ())))))); | |||
| 1897 | CtkWindowPrivate *priv = window->priv; | |||
| 1898 | ||||
| 1899 | switch (prop_id) | |||
| 1900 | { | |||
| 1901 | CtkWindowGeometryInfo *info; | |||
| 1902 | case PROP_TYPE: | |||
| 1903 | g_value_set_enum (value, priv->type); | |||
| 1904 | break; | |||
| 1905 | case PROP_ROLE: | |||
| 1906 | g_value_set_string (value, priv->wm_role); | |||
| 1907 | break; | |||
| 1908 | case PROP_TITLE: | |||
| 1909 | g_value_set_string (value, priv->title); | |||
| 1910 | break; | |||
| 1911 | case PROP_RESIZABLE: | |||
| 1912 | g_value_set_boolean (value, priv->resizable); | |||
| 1913 | break; | |||
| 1914 | case PROP_MODAL: | |||
| 1915 | g_value_set_boolean (value, priv->modal); | |||
| 1916 | break; | |||
| 1917 | case PROP_WIN_POS: | |||
| 1918 | g_value_set_enum (value, priv->position); | |||
| 1919 | break; | |||
| 1920 | case PROP_DEFAULT_WIDTH: | |||
| 1921 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 1922 | if (!info) | |||
| 1923 | g_value_set_int (value, -1); | |||
| 1924 | else | |||
| 1925 | g_value_set_int (value, info->default_width); | |||
| 1926 | break; | |||
| 1927 | case PROP_DEFAULT_HEIGHT: | |||
| 1928 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 1929 | if (!info) | |||
| 1930 | g_value_set_int (value, -1); | |||
| 1931 | else | |||
| 1932 | g_value_set_int (value, info->default_height); | |||
| 1933 | break; | |||
| 1934 | case PROP_DESTROY_WITH_PARENT: | |||
| 1935 | g_value_set_boolean (value, priv->destroy_with_parent); | |||
| 1936 | break; | |||
| 1937 | case PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED: | |||
| 1938 | g_value_set_boolean (value, priv->hide_titlebar_when_maximized); | |||
| 1939 | break; | |||
| 1940 | case PROP_ICON: | |||
| 1941 | g_value_set_object (value, ctk_window_get_icon (window)); | |||
| 1942 | break; | |||
| 1943 | case PROP_ICON_NAME: | |||
| 1944 | g_value_set_string (value, ctk_window_get_icon_name (window)); | |||
| 1945 | break; | |||
| 1946 | case PROP_SCREEN: | |||
| 1947 | g_value_set_object (value, priv->screen); | |||
| 1948 | break; | |||
| 1949 | case PROP_IS_ACTIVE: | |||
| 1950 | g_value_set_boolean (value, priv->is_active); | |||
| 1951 | break; | |||
| 1952 | case PROP_HAS_TOPLEVEL_FOCUS: | |||
| 1953 | g_value_set_boolean (value, priv->has_toplevel_focus); | |||
| 1954 | break; | |||
| 1955 | case PROP_TYPE_HINT: | |||
| 1956 | g_value_set_enum (value, priv->type_hint); | |||
| 1957 | break; | |||
| 1958 | case PROP_SKIP_TASKBAR_HINT: | |||
| 1959 | g_value_set_boolean (value, | |||
| 1960 | ctk_window_get_skip_taskbar_hint (window)); | |||
| 1961 | break; | |||
| 1962 | case PROP_SKIP_PAGER_HINT: | |||
| 1963 | g_value_set_boolean (value, | |||
| 1964 | ctk_window_get_skip_pager_hint (window)); | |||
| 1965 | break; | |||
| 1966 | case PROP_URGENCY_HINT: | |||
| 1967 | g_value_set_boolean (value, | |||
| 1968 | ctk_window_get_urgency_hint (window)); | |||
| 1969 | break; | |||
| 1970 | case PROP_ACCEPT_FOCUS: | |||
| 1971 | g_value_set_boolean (value, | |||
| 1972 | ctk_window_get_accept_focus (window)); | |||
| 1973 | break; | |||
| 1974 | case PROP_FOCUS_ON_MAP: | |||
| 1975 | g_value_set_boolean (value, | |||
| 1976 | ctk_window_get_focus_on_map (window)); | |||
| 1977 | break; | |||
| 1978 | case PROP_DECORATED: | |||
| 1979 | g_value_set_boolean (value, ctk_window_get_decorated (window)); | |||
| 1980 | break; | |||
| 1981 | case PROP_DELETABLE: | |||
| 1982 | g_value_set_boolean (value, ctk_window_get_deletable (window)); | |||
| 1983 | break; | |||
| 1984 | case PROP_GRAVITY: | |||
| 1985 | g_value_set_enum (value, ctk_window_get_gravity (window)); | |||
| 1986 | break; | |||
| 1987 | case PROP_TRANSIENT_FOR: | |||
| 1988 | g_value_set_object (value, ctk_window_get_transient_for (window)); | |||
| 1989 | break; | |||
| 1990 | case PROP_ATTACHED_TO: | |||
| 1991 | g_value_set_object (value, ctk_window_get_attached_to (window)); | |||
| 1992 | break; | |||
| 1993 | case PROP_HAS_RESIZE_GRIP: | |||
| 1994 | g_value_set_boolean (value, FALSE(0)); | |||
| 1995 | break; | |||
| 1996 | case PROP_RESIZE_GRIP_VISIBLE: | |||
| 1997 | g_value_set_boolean (value, FALSE(0)); | |||
| 1998 | break; | |||
| 1999 | case PROP_APPLICATION: | |||
| 2000 | g_value_set_object (value, ctk_window_get_application (window)); | |||
| 2001 | break; | |||
| 2002 | case PROP_MNEMONICS_VISIBLE: | |||
| 2003 | g_value_set_boolean (value, priv->mnemonics_visible); | |||
| 2004 | break; | |||
| 2005 | case PROP_FOCUS_VISIBLE: | |||
| 2006 | g_value_set_boolean (value, priv->focus_visible); | |||
| 2007 | break; | |||
| 2008 | case PROP_IS_MAXIMIZED: | |||
| 2009 | g_value_set_boolean (value, ctk_window_is_maximized (window)); | |||
| 2010 | break; | |||
| 2011 | default: | |||
| 2012 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkwindow.c", 2012, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
| 2013 | break; | |||
| 2014 | } | |||
| 2015 | } | |||
| 2016 | ||||
| 2017 | static void | |||
| 2018 | ctk_window_buildable_interface_init (CtkBuildableIface *iface) | |||
| 2019 | { | |||
| 2020 | parent_buildable_iface = g_type_interface_peek_parent (iface); | |||
| 2021 | iface->set_buildable_property = ctk_window_buildable_set_buildable_property; | |||
| 2022 | iface->parser_finished = ctk_window_buildable_parser_finished; | |||
| 2023 | iface->custom_tag_start = ctk_window_buildable_custom_tag_start; | |||
| 2024 | iface->custom_finished = ctk_window_buildable_custom_finished; | |||
| 2025 | iface->add_child = ctk_window_buildable_add_child; | |||
| 2026 | } | |||
| 2027 | ||||
| 2028 | static void | |||
| 2029 | ctk_window_buildable_add_child (CtkBuildable *buildable, | |||
| 2030 | CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 2031 | GObject *child, | |||
| 2032 | const gchar *type) | |||
| 2033 | { | |||
| 2034 | if (type && strcmp (type, "titlebar") == 0) | |||
| 2035 | ctk_window_set_titlebar (CTK_WINDOW (buildable)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_window_get_type ())))))), CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); | |||
| 2036 | else if (!type) | |||
| 2037 | ctk_container_add (CTK_CONTAINER (buildable)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_container_get_type ())))))), CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); | |||
| 2038 | else | |||
| 2039 | CTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type)g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (buildable))->g_class ))->g_type))))); | |||
| 2040 | } | |||
| 2041 | ||||
| 2042 | static void | |||
| 2043 | ctk_window_buildable_set_buildable_property (CtkBuildable *buildable, | |||
| 2044 | CtkBuilder *builder, | |||
| 2045 | const gchar *name, | |||
| 2046 | const GValue *value) | |||
| 2047 | { | |||
| 2048 | CtkWindow *window = CTK_WINDOW (buildable)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_window_get_type ())))))); | |||
| 2049 | CtkWindowPrivate *priv = window->priv; | |||
| 2050 | ||||
| 2051 | if (strcmp (name, "visible") == 0 && g_value_get_boolean (value)) | |||
| 2052 | priv->builder_visible = TRUE(!(0)); | |||
| 2053 | else | |||
| 2054 | parent_buildable_iface->set_buildable_property (buildable, builder, name, value); | |||
| 2055 | } | |||
| 2056 | ||||
| 2057 | typedef struct { | |||
| 2058 | gchar *name; | |||
| 2059 | gint line; | |||
| 2060 | gint col; | |||
| 2061 | } ItemData; | |||
| 2062 | ||||
| 2063 | static void | |||
| 2064 | item_data_free (gpointer data) | |||
| 2065 | { | |||
| 2066 | ItemData *item_data = data; | |||
| 2067 | ||||
| 2068 | g_free (item_data->name)(__builtin_object_size ((item_data->name), 0) != ((size_t) - 1)) ? g_free_sized (item_data->name, __builtin_object_size ((item_data->name), 0)) : (g_free) (item_data->name); | |||
| 2069 | g_free (item_data)(__builtin_object_size ((item_data), 0) != ((size_t) - 1)) ? g_free_sized (item_data, __builtin_object_size ((item_data), 0)) : (g_free ) (item_data); | |||
| 2070 | } | |||
| 2071 | ||||
| 2072 | static void | |||
| 2073 | item_list_free (gpointer data) | |||
| 2074 | { | |||
| 2075 | GSList *list = data; | |||
| 2076 | ||||
| 2077 | g_slist_free_full (list, item_data_free); | |||
| 2078 | } | |||
| 2079 | ||||
| 2080 | static void | |||
| 2081 | ctk_window_buildable_parser_finished (CtkBuildable *buildable, | |||
| 2082 | CtkBuilder *builder) | |||
| 2083 | { | |||
| 2084 | CtkWindow *window = CTK_WINDOW (buildable)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_window_get_type ())))))); | |||
| 2085 | CtkWindowPrivate *priv = window->priv; | |||
| 2086 | GObject *object; | |||
| 2087 | GSList *accels, *l; | |||
| 2088 | ||||
| 2089 | if (priv->builder_visible) | |||
| 2090 | ctk_widget_show (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_widget_get_type ()))))))); | |||
| 2091 | ||||
| 2092 | accels = g_object_get_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))), quark_ctk_buildable_accels); | |||
| 2093 | for (l = accels; l; l = l->next) | |||
| 2094 | { | |||
| 2095 | ItemData *data = l->data; | |||
| 2096 | ||||
| 2097 | object = _ctk_builder_lookup_object (builder, data->name, data->line, data->col); | |||
| 2098 | if (!object) | |||
| 2099 | continue; | |||
| 2100 | ctk_window_add_accel_group (CTK_WINDOW (buildable)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_window_get_type ())))))), CTK_ACCEL_GROUP (object)((((CtkAccelGroup*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_accel_group_get_type ()))))))); | |||
| 2101 | } | |||
| 2102 | ||||
| 2103 | g_object_set_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))), quark_ctk_buildable_accels, NULL((void*)0)); | |||
| 2104 | ||||
| 2105 | parent_buildable_iface->parser_finished (buildable, builder); | |||
| 2106 | } | |||
| 2107 | ||||
| 2108 | typedef struct { | |||
| 2109 | GObject *object; | |||
| 2110 | CtkBuilder *builder; | |||
| 2111 | GSList *items; | |||
| 2112 | } GSListSubParserData; | |||
| 2113 | ||||
| 2114 | static void | |||
| 2115 | window_start_element (GMarkupParseContext *context, | |||
| 2116 | const gchar *element_name, | |||
| 2117 | const gchar **names, | |||
| 2118 | const gchar **values, | |||
| 2119 | gpointer user_data, | |||
| 2120 | GError **error) | |||
| 2121 | { | |||
| 2122 | GSListSubParserData *data = (GSListSubParserData*)user_data; | |||
| 2123 | ||||
| 2124 | if (strcmp (element_name, "group") == 0) | |||
| 2125 | { | |||
| 2126 | const gchar *name; | |||
| 2127 | ItemData *item_data; | |||
| 2128 | ||||
| 2129 | if (!_ctk_builder_check_parent (data->builder, context, "accel-groups", error)) | |||
| 2130 | return; | |||
| 2131 | ||||
| 2132 | if (!g_markup_collect_attributes (element_name, names, values, error, | |||
| 2133 | G_MARKUP_COLLECT_STRING, "name", &name, | |||
| 2134 | G_MARKUP_COLLECT_INVALID)) | |||
| 2135 | { | |||
| 2136 | _ctk_builder_prefix_error (data->builder, context, error); | |||
| 2137 | return; | |||
| 2138 | } | |||
| 2139 | ||||
| 2140 | item_data = g_new (ItemData, 1)((ItemData *) g_malloc_n ((1), sizeof (ItemData))); | |||
| 2141 | item_data->name = g_strdup (name)g_strdup_inline (name); | |||
| 2142 | g_markup_parse_context_get_position (context, &item_data->line, &item_data->col); | |||
| 2143 | data->items = g_slist_prepend (data->items, item_data); | |||
| 2144 | } | |||
| 2145 | else if (strcmp (element_name, "accel-groups") == 0) | |||
| 2146 | { | |||
| 2147 | if (!_ctk_builder_check_parent (data->builder, context, "object", error)) | |||
| 2148 | return; | |||
| 2149 | ||||
| 2150 | if (!g_markup_collect_attributes (element_name, names, values, error, | |||
| 2151 | G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0), | |||
| 2152 | G_MARKUP_COLLECT_INVALID)) | |||
| 2153 | _ctk_builder_prefix_error (data->builder, context, error); | |||
| 2154 | } | |||
| 2155 | else | |||
| 2156 | { | |||
| 2157 | _ctk_builder_error_unhandled_tag (data->builder, context, | |||
| 2158 | "CtkWindow", element_name, | |||
| 2159 | error); | |||
| 2160 | } | |||
| 2161 | } | |||
| 2162 | ||||
| 2163 | static const GMarkupParser window_parser = | |||
| 2164 | { | |||
| 2165 | .start_element = window_start_element | |||
| 2166 | }; | |||
| 2167 | ||||
| 2168 | typedef struct { | |||
| 2169 | GObject *object; | |||
| 2170 | CtkBuilder *builder; | |||
| 2171 | gchar *name; | |||
| 2172 | gint line; | |||
| 2173 | gint col; | |||
| 2174 | } NameSubParserData; | |||
| 2175 | ||||
| 2176 | static void | |||
| 2177 | focus_start_element (GMarkupParseContext *context, | |||
| 2178 | const gchar *element_name, | |||
| 2179 | const gchar **names, | |||
| 2180 | const gchar **values, | |||
| 2181 | gpointer user_data, | |||
| 2182 | GError **error) | |||
| 2183 | { | |||
| 2184 | NameSubParserData *data = (NameSubParserData*)user_data; | |||
| 2185 | ||||
| 2186 | if (strcmp (element_name, "initial-focus") == 0) | |||
| 2187 | { | |||
| 2188 | const gchar *name; | |||
| 2189 | ||||
| 2190 | if (!_ctk_builder_check_parent (data->builder, context, "object", error)) | |||
| 2191 | return; | |||
| 2192 | ||||
| 2193 | if (!g_markup_collect_attributes (element_name, names, values, error, | |||
| 2194 | G_MARKUP_COLLECT_STRING, "name", &name, | |||
| 2195 | G_MARKUP_COLLECT_INVALID)) | |||
| 2196 | { | |||
| 2197 | _ctk_builder_prefix_error (data->builder, context, error); | |||
| 2198 | return; | |||
| 2199 | } | |||
| 2200 | ||||
| 2201 | data->name = g_strdup (name)g_strdup_inline (name); | |||
| 2202 | g_markup_parse_context_get_position (context, &data->line, &data->col); | |||
| 2203 | } | |||
| 2204 | else | |||
| 2205 | { | |||
| 2206 | _ctk_builder_error_unhandled_tag (data->builder, context, | |||
| 2207 | "CtkWindow", element_name, | |||
| 2208 | error); | |||
| 2209 | } | |||
| 2210 | } | |||
| 2211 | ||||
| 2212 | static const GMarkupParser focus_parser = | |||
| 2213 | { | |||
| 2214 | .start_element = focus_start_element | |||
| 2215 | }; | |||
| 2216 | ||||
| 2217 | static gboolean | |||
| 2218 | ctk_window_buildable_custom_tag_start (CtkBuildable *buildable, | |||
| 2219 | CtkBuilder *builder, | |||
| 2220 | GObject *child, | |||
| 2221 | const gchar *tagname, | |||
| 2222 | GMarkupParser *parser, | |||
| 2223 | gpointer *parser_data) | |||
| 2224 | { | |||
| 2225 | if (parent_buildable_iface->custom_tag_start (buildable, builder, child, | |||
| 2226 | tagname, parser, parser_data)) | |||
| 2227 | return TRUE(!(0)); | |||
| 2228 | ||||
| 2229 | if (strcmp (tagname, "accel-groups") == 0) | |||
| 2230 | { | |||
| 2231 | GSListSubParserData *data; | |||
| 2232 | ||||
| 2233 | data = g_slice_new0 (GSListSubParserData)((GSListSubParserData*) g_slice_alloc0 ((sizeof (GSListSubParserData ) > 0 ? sizeof (GSListSubParserData) : 1))); | |||
| 2234 | data->items = NULL((void*)0); | |||
| 2235 | data->object = G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))); | |||
| 2236 | data->builder = builder; | |||
| 2237 | ||||
| 2238 | *parser = window_parser; | |||
| 2239 | *parser_data = data; | |||
| 2240 | ||||
| 2241 | return TRUE(!(0)); | |||
| 2242 | } | |||
| 2243 | ||||
| 2244 | if (strcmp (tagname, "initial-focus") == 0) | |||
| 2245 | { | |||
| 2246 | NameSubParserData *data; | |||
| 2247 | ||||
| 2248 | data = g_slice_new0 (NameSubParserData)((NameSubParserData*) g_slice_alloc0 ((sizeof (NameSubParserData ) > 0 ? sizeof (NameSubParserData) : 1))); | |||
| 2249 | data->name = NULL((void*)0); | |||
| 2250 | data->object = G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))); | |||
| 2251 | data->builder = builder; | |||
| 2252 | ||||
| 2253 | *parser = focus_parser; | |||
| 2254 | *parser_data = data; | |||
| 2255 | ||||
| 2256 | return TRUE(!(0)); | |||
| 2257 | } | |||
| 2258 | ||||
| 2259 | return FALSE(0); | |||
| 2260 | } | |||
| 2261 | ||||
| 2262 | static void | |||
| 2263 | ctk_window_buildable_custom_finished (CtkBuildable *buildable, | |||
| 2264 | CtkBuilder *builder, | |||
| 2265 | GObject *child, | |||
| 2266 | const gchar *tagname, | |||
| 2267 | gpointer user_data) | |||
| 2268 | { | |||
| 2269 | parent_buildable_iface->custom_finished (buildable, builder, child, | |||
| 2270 | tagname, user_data); | |||
| 2271 | ||||
| 2272 | if (strcmp (tagname, "accel-groups") == 0) | |||
| 2273 | { | |||
| 2274 | GSListSubParserData *data = (GSListSubParserData*)user_data; | |||
| 2275 | ||||
| 2276 | g_object_set_qdata_full (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))), quark_ctk_buildable_accels, | |||
| 2277 | data->items, (GDestroyNotify) item_list_free); | |||
| 2278 | ||||
| 2279 | g_slice_free (GSListSubParserData, data)do { if (1) g_slice_free1 (sizeof (GSListSubParserData), (data )); else (void) ((GSListSubParserData*) 0 == (data)); } while (0); | |||
| 2280 | } | |||
| 2281 | ||||
| 2282 | if (strcmp (tagname, "initial-focus") == 0) | |||
| 2283 | { | |||
| 2284 | NameSubParserData *data = (NameSubParserData*)user_data; | |||
| 2285 | ||||
| 2286 | if (data->name) | |||
| 2287 | { | |||
| 2288 | GObject *object; | |||
| 2289 | ||||
| 2290 | object = _ctk_builder_lookup_object (builder, data->name, data->line, data->col); | |||
| 2291 | if (object) | |||
| 2292 | ctk_window_set_focus (CTK_WINDOW (buildable)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_window_get_type ())))))), CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_widget_get_type ()))))))); | |||
| 2293 | g_free (data->name)(__builtin_object_size ((data->name), 0) != ((size_t) - 1) ) ? g_free_sized (data->name, __builtin_object_size ((data ->name), 0)) : (g_free) (data->name); | |||
| 2294 | } | |||
| 2295 | ||||
| 2296 | g_slice_free (NameSubParserData, data)do { if (1) g_slice_free1 (sizeof (NameSubParserData), (data) ); else (void) ((NameSubParserData*) 0 == (data)); } while (0 ); | |||
| 2297 | } | |||
| 2298 | } | |||
| 2299 | ||||
| 2300 | /** | |||
| 2301 | * ctk_window_new: | |||
| 2302 | * @type: type of window | |||
| 2303 | * | |||
| 2304 | * Creates a new #CtkWindow, which is a toplevel window that can | |||
| 2305 | * contain other widgets. Nearly always, the type of the window should | |||
| 2306 | * be #CTK_WINDOW_TOPLEVEL. If you’re implementing something like a | |||
| 2307 | * popup menu from scratch (which is a bad idea, just use #CtkMenu), | |||
| 2308 | * you might use #CTK_WINDOW_POPUP. #CTK_WINDOW_POPUP is not for | |||
| 2309 | * dialogs, though in some other toolkits dialogs are called “popups”. | |||
| 2310 | * In CTK+, #CTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip. | |||
| 2311 | * On X11, popup windows are not controlled by the | |||
| 2312 | * [window manager][ctk-X11-arch]. | |||
| 2313 | * | |||
| 2314 | * If you simply want an undecorated window (no window borders), use | |||
| 2315 | * ctk_window_set_decorated(), don’t use #CTK_WINDOW_POPUP. | |||
| 2316 | * | |||
| 2317 | * All top-level windows created by ctk_window_new() are stored in | |||
| 2318 | * an internal top-level window list. This list can be obtained from | |||
| 2319 | * ctk_window_list_toplevels(). Due to Ctk+ keeping a reference to | |||
| 2320 | * the window internally, ctk_window_new() does not return a reference | |||
| 2321 | * to the caller. | |||
| 2322 | * | |||
| 2323 | * To delete a #CtkWindow, call ctk_widget_destroy(). | |||
| 2324 | * | |||
| 2325 | * Returns: a new #CtkWindow. | |||
| 2326 | **/ | |||
| 2327 | CtkWidget* | |||
| 2328 | ctk_window_new (CtkWindowType type) | |||
| 2329 | { | |||
| 2330 | CtkWindow *window; | |||
| 2331 | ||||
| 2332 | g_return_val_if_fail (type >= CTK_WINDOW_TOPLEVEL && type <= CTK_WINDOW_POPUP, NULL)do { if ((type >= CTK_WINDOW_TOPLEVEL && type <= CTK_WINDOW_POPUP)) { } else { g_return_if_fail_warning ("Ctk" , ((const char*) (__func__)), "type >= CTK_WINDOW_TOPLEVEL && type <= CTK_WINDOW_POPUP" ); return (((void*)0)); } } while (0); | |||
| 2333 | ||||
| 2334 | window = g_object_new (CTK_TYPE_WINDOW(ctk_window_get_type ()), "type", type, NULL((void*)0)); | |||
| 2335 | ||||
| 2336 | return CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 2337 | } | |||
| 2338 | ||||
| 2339 | static void | |||
| 2340 | ctk_window_set_title_internal (CtkWindow *window, | |||
| 2341 | const gchar *title, | |||
| 2342 | gboolean update_titlebar) | |||
| 2343 | { | |||
| 2344 | CtkWindowPrivate *priv; | |||
| 2345 | CtkWidget *widget; | |||
| 2346 | char *new_title; | |||
| 2347 | ||||
| 2348 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2349 | ||||
| 2350 | priv = window->priv; | |||
| 2351 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 2352 | ||||
| 2353 | new_title = g_strdup (title)g_strdup_inline (title); | |||
| 2354 | g_free (priv->title)(__builtin_object_size ((priv->title), 0) != ((size_t) - 1 )) ? g_free_sized (priv->title, __builtin_object_size ((priv ->title), 0)) : (g_free) (priv->title); | |||
| 2355 | priv->title = new_title; | |||
| 2356 | ||||
| 2357 | if (new_title == NULL((void*)0)) | |||
| 2358 | new_title = ""; | |||
| 2359 | ||||
| 2360 | if (_ctk_widget_get_realized (widget)) | |||
| 2361 | cdk_window_set_title (_ctk_widget_get_window (widget), new_title); | |||
| 2362 | ||||
| 2363 | if (update_titlebar && CTK_IS_HEADER_BAR (priv->title_box)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (priv->title_box)); GType _t = ((ctk_header_bar_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; }))))) | |||
| 2364 | ctk_header_bar_set_title (CTK_HEADER_BAR (priv->title_box)((((CtkHeaderBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->title_box)), ((ctk_header_bar_get_type ())))))), new_title); | |||
| 2365 | ||||
| 2366 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_TITLE]); | |||
| 2367 | } | |||
| 2368 | ||||
| 2369 | /** | |||
| 2370 | * ctk_window_set_title: | |||
| 2371 | * @window: a #CtkWindow | |||
| 2372 | * @title: title of the window | |||
| 2373 | * | |||
| 2374 | * Sets the title of the #CtkWindow. The title of a window will be | |||
| 2375 | * displayed in its title bar; on the X Window System, the title bar | |||
| 2376 | * is rendered by the [window manager][ctk-X11-arch], | |||
| 2377 | * so exactly how the title appears to users may vary | |||
| 2378 | * according to a user’s exact configuration. The title should help a | |||
| 2379 | * user distinguish this window from other windows they may have | |||
| 2380 | * open. A good title might include the application name and current | |||
| 2381 | * document filename, for example. | |||
| 2382 | * | |||
| 2383 | **/ | |||
| 2384 | void | |||
| 2385 | ctk_window_set_title (CtkWindow *window, | |||
| 2386 | const gchar *title) | |||
| 2387 | { | |||
| 2388 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2389 | ||||
| 2390 | ctk_window_set_title_internal (window, title, TRUE(!(0))); | |||
| 2391 | } | |||
| 2392 | ||||
| 2393 | /** | |||
| 2394 | * ctk_window_get_title: | |||
| 2395 | * @window: a #CtkWindow | |||
| 2396 | * | |||
| 2397 | * Retrieves the title of the window. See ctk_window_set_title(). | |||
| 2398 | * | |||
| 2399 | * Returns: (nullable): the title of the window, or %NULL if none has | |||
| 2400 | * been set explicitly. The returned string is owned by the widget | |||
| 2401 | * and must not be modified or freed. | |||
| 2402 | **/ | |||
| 2403 | const gchar * | |||
| 2404 | ctk_window_get_title (CtkWindow *window) | |||
| 2405 | { | |||
| 2406 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 2407 | ||||
| 2408 | return window->priv->title; | |||
| 2409 | } | |||
| 2410 | ||||
| 2411 | /** | |||
| 2412 | * ctk_window_set_wmclass: | |||
| 2413 | * @window: a #CtkWindow | |||
| 2414 | * @wmclass_name: window name hint | |||
| 2415 | * @wmclass_class: window class hint | |||
| 2416 | * | |||
| 2417 | * Don’t use this function. It sets the X Window System “class” and | |||
| 2418 | * “name” hints for a window. According to the ICCCM, you should | |||
| 2419 | * always set these to the same value for all windows in an | |||
| 2420 | * application, and CTK+ sets them to that value by default, so calling | |||
| 2421 | * this function is sort of pointless. However, you may want to call | |||
| 2422 | * ctk_window_set_role() on each window in your application, for the | |||
| 2423 | * benefit of the session manager. Setting the role allows the window | |||
| 2424 | * manager to restore window positions when loading a saved session. | |||
| 2425 | * | |||
| 2426 | * Deprecated: 3.22 | |||
| 2427 | **/ | |||
| 2428 | void | |||
| 2429 | ctk_window_set_wmclass (CtkWindow *window, | |||
| 2430 | const gchar *wmclass_name, | |||
| 2431 | const gchar *wmclass_class) | |||
| 2432 | { | |||
| 2433 | CtkWindowPrivate *priv; | |||
| 2434 | ||||
| 2435 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2436 | ||||
| 2437 | priv = window->priv; | |||
| 2438 | ||||
| 2439 | g_free (priv->wmclass_name)(__builtin_object_size ((priv->wmclass_name), 0) != ((size_t ) - 1)) ? g_free_sized (priv->wmclass_name, __builtin_object_size ((priv->wmclass_name), 0)) : (g_free) (priv->wmclass_name ); | |||
| 2440 | priv->wmclass_name = g_strdup (wmclass_name)g_strdup_inline (wmclass_name); | |||
| 2441 | ||||
| 2442 | g_free (priv->wmclass_class)(__builtin_object_size ((priv->wmclass_class), 0) != ((size_t ) - 1)) ? g_free_sized (priv->wmclass_class, __builtin_object_size ((priv->wmclass_class), 0)) : (g_free) (priv->wmclass_class ); | |||
| 2443 | priv->wmclass_class = g_strdup (wmclass_class)g_strdup_inline (wmclass_class); | |||
| 2444 | ||||
| 2445 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 2446 | g_warning ("ctk_window_set_wmclass: shouldn't set wmclass after window is realized!"); | |||
| 2447 | } | |||
| 2448 | ||||
| 2449 | /** | |||
| 2450 | * ctk_window_set_role: | |||
| 2451 | * @window: a #CtkWindow | |||
| 2452 | * @role: unique identifier for the window to be used when restoring a session | |||
| 2453 | * | |||
| 2454 | * This function is only useful on X11, not with other CTK+ targets. | |||
| 2455 | * | |||
| 2456 | * In combination with the window title, the window role allows a | |||
| 2457 | * [window manager][ctk-X11-arch] to identify "the | |||
| 2458 | * same" window when an application is restarted. So for example you | |||
| 2459 | * might set the “toolbox” role on your app’s toolbox window, so that | |||
| 2460 | * when the user restarts their session, the window manager can put | |||
| 2461 | * the toolbox back in the same place. | |||
| 2462 | * | |||
| 2463 | * If a window already has a unique title, you don’t need to set the | |||
| 2464 | * role, since the WM can use the title to identify the window when | |||
| 2465 | * restoring the session. | |||
| 2466 | * | |||
| 2467 | **/ | |||
| 2468 | void | |||
| 2469 | ctk_window_set_role (CtkWindow *window, | |||
| 2470 | const gchar *role) | |||
| 2471 | { | |||
| 2472 | CtkWindowPrivate *priv; | |||
| 2473 | CtkWidget *widget; | |||
| 2474 | char *new_role; | |||
| 2475 | ||||
| 2476 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2477 | ||||
| 2478 | priv = window->priv; | |||
| 2479 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 2480 | ||||
| 2481 | new_role = g_strdup (role)g_strdup_inline (role); | |||
| 2482 | g_free (priv->wm_role)(__builtin_object_size ((priv->wm_role), 0) != ((size_t) - 1)) ? g_free_sized (priv->wm_role, __builtin_object_size ( (priv->wm_role), 0)) : (g_free) (priv->wm_role); | |||
| 2483 | priv->wm_role = new_role; | |||
| 2484 | ||||
| 2485 | if (_ctk_widget_get_realized (widget)) | |||
| 2486 | cdk_window_set_role (_ctk_widget_get_window (widget), priv->wm_role); | |||
| 2487 | ||||
| 2488 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_ROLE]); | |||
| 2489 | } | |||
| 2490 | ||||
| 2491 | /** | |||
| 2492 | * ctk_window_set_startup_id: | |||
| 2493 | * @window: a #CtkWindow | |||
| 2494 | * @startup_id: a string with startup-notification identifier | |||
| 2495 | * | |||
| 2496 | * Startup notification identifiers are used by desktop environment to | |||
| 2497 | * track application startup, to provide user feedback and other | |||
| 2498 | * features. This function changes the corresponding property on the | |||
| 2499 | * underlying CdkWindow. Normally, startup identifier is managed | |||
| 2500 | * automatically and you should only use this function in special cases | |||
| 2501 | * like transferring focus from other processes. You should use this | |||
| 2502 | * function before calling ctk_window_present() or any equivalent | |||
| 2503 | * function generating a window map event. | |||
| 2504 | * | |||
| 2505 | * This function is only useful on X11, not with other CTK+ targets. | |||
| 2506 | * | |||
| 2507 | * Since: 2.12 | |||
| 2508 | **/ | |||
| 2509 | void | |||
| 2510 | ctk_window_set_startup_id (CtkWindow *window, | |||
| 2511 | const gchar *startup_id) | |||
| 2512 | { | |||
| 2513 | CtkWindowPrivate *priv; | |||
| 2514 | CtkWidget *widget; | |||
| 2515 | ||||
| 2516 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2517 | ||||
| 2518 | priv = window->priv; | |||
| 2519 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 2520 | ||||
| 2521 | g_free (priv->startup_id)(__builtin_object_size ((priv->startup_id), 0) != ((size_t ) - 1)) ? g_free_sized (priv->startup_id, __builtin_object_size ((priv->startup_id), 0)) : (g_free) (priv->startup_id); | |||
| 2522 | priv->startup_id = g_strdup (startup_id)g_strdup_inline (startup_id); | |||
| 2523 | ||||
| 2524 | if (_ctk_widget_get_realized (widget)) | |||
| 2525 | { | |||
| 2526 | CdkWindow *cdk_window; | |||
| 2527 | guint32 timestamp = extract_time_from_startup_id (priv->startup_id); | |||
| 2528 | ||||
| 2529 | cdk_window = _ctk_widget_get_window (widget); | |||
| 2530 | ||||
| 2531 | #ifdef CDK_WINDOWING_X11 | |||
| 2532 | if (timestamp != CDK_CURRENT_TIME0L && CDK_IS_X11_WINDOW(cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_x11_window_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; }))))) | |||
| 2533 | cdk_x11_window_set_user_time (cdk_window, timestamp); | |||
| 2534 | #endif | |||
| 2535 | ||||
| 2536 | /* Here we differentiate real and "fake" startup notification IDs, | |||
| 2537 | * constructed on purpose just to pass interaction timestamp | |||
| 2538 | */ | |||
| 2539 | if (startup_id_is_fake (priv->startup_id)) | |||
| 2540 | ctk_window_present_with_time (window, timestamp); | |||
| 2541 | else | |||
| 2542 | { | |||
| 2543 | cdk_window_set_startup_id (cdk_window, | |||
| 2544 | priv->startup_id); | |||
| 2545 | ||||
| 2546 | /* If window is mapped, terminate the startup-notification too */ | |||
| 2547 | if (_ctk_widget_get_mapped (widget) && | |||
| 2548 | !disable_startup_notification) | |||
| 2549 | cdk_notify_startup_complete_with_id (priv->startup_id); | |||
| 2550 | } | |||
| 2551 | } | |||
| 2552 | ||||
| 2553 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_STARTUP_ID]); | |||
| 2554 | } | |||
| 2555 | ||||
| 2556 | /** | |||
| 2557 | * ctk_window_get_role: | |||
| 2558 | * @window: a #CtkWindow | |||
| 2559 | * | |||
| 2560 | * Returns the role of the window. See ctk_window_set_role() for | |||
| 2561 | * further explanation. | |||
| 2562 | * | |||
| 2563 | * Returns: (nullable): the role of the window if set, or %NULL. The | |||
| 2564 | * returned is owned by the widget and must not be modified or freed. | |||
| 2565 | **/ | |||
| 2566 | const gchar * | |||
| 2567 | ctk_window_get_role (CtkWindow *window) | |||
| 2568 | { | |||
| 2569 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 2570 | ||||
| 2571 | return window->priv->wm_role; | |||
| 2572 | } | |||
| 2573 | ||||
| 2574 | /** | |||
| 2575 | * ctk_window_set_focus: | |||
| 2576 | * @window: a #CtkWindow | |||
| 2577 | * @focus: (allow-none): widget to be the new focus widget, or %NULL to unset | |||
| 2578 | * any focus widget for the toplevel window. | |||
| 2579 | * | |||
| 2580 | * If @focus is not the current focus widget, and is focusable, sets | |||
| 2581 | * it as the focus widget for the window. If @focus is %NULL, unsets | |||
| 2582 | * the focus widget for this window. To set the focus to a particular | |||
| 2583 | * widget in the toplevel, it is usually more convenient to use | |||
| 2584 | * ctk_widget_grab_focus() instead of this function. | |||
| 2585 | **/ | |||
| 2586 | void | |||
| 2587 | ctk_window_set_focus (CtkWindow *window, | |||
| 2588 | CtkWidget *focus) | |||
| 2589 | { | |||
| 2590 | CtkWindowPrivate *priv; | |||
| 2591 | CtkWidget *parent; | |||
| 2592 | ||||
| 2593 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2594 | ||||
| 2595 | priv = window->priv; | |||
| 2596 | ||||
| 2597 | if (focus) | |||
| 2598 | { | |||
| 2599 | g_return_if_fail (CTK_IS_WIDGET (focus))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((focus)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (focus)") ; return; } } while (0); | |||
| 2600 | g_return_if_fail (ctk_widget_get_can_focus (focus))do { if ((ctk_widget_get_can_focus (focus))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "ctk_widget_get_can_focus (focus)" ); return; } } while (0); | |||
| 2601 | } | |||
| 2602 | ||||
| 2603 | if (focus) | |||
| 2604 | { | |||
| 2605 | if (!ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 2606 | priv->initial_focus = focus; | |||
| 2607 | else | |||
| 2608 | ctk_widget_grab_focus (focus); | |||
| 2609 | } | |||
| 2610 | else | |||
| 2611 | { | |||
| 2612 | /* Clear the existing focus chain, so that when we focus into | |||
| 2613 | * the window again, we start at the beginnning. | |||
| 2614 | */ | |||
| 2615 | CtkWidget *widget = priv->focus_widget; | |||
| 2616 | if (widget) | |||
| 2617 | { | |||
| 2618 | while ((parent = _ctk_widget_get_parent (widget))) | |||
| 2619 | { | |||
| 2620 | widget = parent; | |||
| 2621 | ctk_container_set_focus_child (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), NULL((void*)0)); | |||
| 2622 | } | |||
| 2623 | } | |||
| 2624 | ||||
| 2625 | _ctk_window_internal_set_focus (window, NULL((void*)0)); | |||
| 2626 | } | |||
| 2627 | } | |||
| 2628 | ||||
| 2629 | void | |||
| 2630 | _ctk_window_internal_set_focus (CtkWindow *window, | |||
| 2631 | CtkWidget *focus) | |||
| 2632 | { | |||
| 2633 | CtkWindowPrivate *priv; | |||
| 2634 | ||||
| 2635 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2636 | ||||
| 2637 | priv = window->priv; | |||
| 2638 | ||||
| 2639 | priv->initial_focus = NULL((void*)0); | |||
| 2640 | if ((priv->focus_widget != focus) || | |||
| 2641 | (focus && !ctk_widget_has_focus (focus))) | |||
| 2642 | g_signal_emit (window, window_signals[SET_FOCUS], 0, focus); | |||
| 2643 | } | |||
| 2644 | ||||
| 2645 | /** | |||
| 2646 | * ctk_window_set_default: | |||
| 2647 | * @window: a #CtkWindow | |||
| 2648 | * @default_widget: (allow-none): widget to be the default, or %NULL | |||
| 2649 | * to unset the default widget for the toplevel | |||
| 2650 | * | |||
| 2651 | * The default widget is the widget that’s activated when the user | |||
| 2652 | * presses Enter in a dialog (for example). This function sets or | |||
| 2653 | * unsets the default widget for a #CtkWindow. When setting (rather | |||
| 2654 | * than unsetting) the default widget it’s generally easier to call | |||
| 2655 | * ctk_widget_grab_default() on the widget. Before making a widget | |||
| 2656 | * the default widget, you must call ctk_widget_set_can_default() on | |||
| 2657 | * the widget you’d like to make the default. | |||
| 2658 | */ | |||
| 2659 | void | |||
| 2660 | ctk_window_set_default (CtkWindow *window, | |||
| 2661 | CtkWidget *default_widget) | |||
| 2662 | { | |||
| 2663 | CtkWindowPrivate *priv; | |||
| 2664 | ||||
| 2665 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2666 | ||||
| 2667 | priv = window->priv; | |||
| 2668 | ||||
| 2669 | if (default_widget) | |||
| 2670 | g_return_if_fail (ctk_widget_get_can_default (default_widget))do { if ((ctk_widget_get_can_default (default_widget))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "ctk_widget_get_can_default (default_widget)"); return; } } while (0); | |||
| 2671 | ||||
| 2672 | if (priv->default_widget != default_widget) | |||
| 2673 | { | |||
| 2674 | CtkWidget *old_default_widget = NULL((void*)0); | |||
| 2675 | ||||
| 2676 | if (default_widget) | |||
| 2677 | g_object_ref (default_widget)((__typeof__ (default_widget)) (g_object_ref) (default_widget )); | |||
| 2678 | ||||
| 2679 | if (priv->default_widget) | |||
| 2680 | { | |||
| 2681 | old_default_widget = priv->default_widget; | |||
| 2682 | ||||
| 2683 | if (priv->focus_widget != priv->default_widget || | |||
| 2684 | !ctk_widget_get_receives_default (priv->default_widget)) | |||
| 2685 | _ctk_widget_set_has_default (priv->default_widget, FALSE(0)); | |||
| 2686 | ||||
| 2687 | ctk_widget_queue_draw (priv->default_widget); | |||
| 2688 | } | |||
| 2689 | ||||
| 2690 | priv->default_widget = default_widget; | |||
| 2691 | ||||
| 2692 | if (priv->default_widget) | |||
| 2693 | { | |||
| 2694 | if (priv->focus_widget == NULL((void*)0) || | |||
| 2695 | !ctk_widget_get_receives_default (priv->focus_widget)) | |||
| 2696 | _ctk_widget_set_has_default (priv->default_widget, TRUE(!(0))); | |||
| 2697 | ||||
| 2698 | ctk_widget_queue_draw (priv->default_widget); | |||
| 2699 | } | |||
| 2700 | ||||
| 2701 | if (old_default_widget) | |||
| 2702 | g_object_notify (G_OBJECT (old_default_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((old_default_widget)), (((GType) ((20) << (2))))))) ), "has-default"); | |||
| 2703 | ||||
| 2704 | if (default_widget) | |||
| 2705 | { | |||
| 2706 | g_object_notify (G_OBJECT (default_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((default_widget)), (((GType) ((20) << (2)))))))), "has-default"); | |||
| 2707 | g_object_unref (default_widget); | |||
| 2708 | } | |||
| 2709 | } | |||
| 2710 | } | |||
| 2711 | ||||
| 2712 | /** | |||
| 2713 | * ctk_window_get_default_widget: | |||
| 2714 | * @window: a #CtkWindow | |||
| 2715 | * | |||
| 2716 | * Returns the default widget for @window. See | |||
| 2717 | * ctk_window_set_default() for more details. | |||
| 2718 | * | |||
| 2719 | * Returns: (nullable) (transfer none): the default widget, or %NULL | |||
| 2720 | * if there is none. | |||
| 2721 | * | |||
| 2722 | * Since: 2.14 | |||
| 2723 | **/ | |||
| 2724 | CtkWidget * | |||
| 2725 | ctk_window_get_default_widget (CtkWindow *window) | |||
| 2726 | { | |||
| 2727 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 2728 | ||||
| 2729 | return window->priv->default_widget; | |||
| 2730 | } | |||
| 2731 | ||||
| 2732 | static gboolean | |||
| 2733 | handle_keys_changed (gpointer data) | |||
| 2734 | { | |||
| 2735 | CtkWindow *window = CTK_WINDOW (data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_window_get_type ())))))); | |||
| 2736 | CtkWindowPrivate *priv = window->priv; | |||
| 2737 | ||||
| 2738 | if (priv->keys_changed_handler) | |||
| 2739 | { | |||
| 2740 | g_source_remove (priv->keys_changed_handler); | |||
| 2741 | priv->keys_changed_handler = 0; | |||
| 2742 | } | |||
| 2743 | ||||
| 2744 | g_signal_emit (window, window_signals[KEYS_CHANGED], 0); | |||
| 2745 | ||||
| 2746 | return FALSE(0); | |||
| 2747 | } | |||
| 2748 | ||||
| 2749 | void | |||
| 2750 | _ctk_window_notify_keys_changed (CtkWindow *window) | |||
| 2751 | { | |||
| 2752 | CtkWindowPrivate *priv = window->priv; | |||
| 2753 | ||||
| 2754 | if (!priv->keys_changed_handler) | |||
| 2755 | { | |||
| 2756 | priv->keys_changed_handler = cdk_threads_add_idle (handle_keys_changed, window); | |||
| 2757 | g_source_set_name_by_id (priv->keys_changed_handler, "[ctk+] handle_keys_changed"); | |||
| 2758 | } | |||
| 2759 | } | |||
| 2760 | ||||
| 2761 | /** | |||
| 2762 | * ctk_window_add_accel_group: | |||
| 2763 | * @window: window to attach accelerator group to | |||
| 2764 | * @accel_group: a #CtkAccelGroup | |||
| 2765 | * | |||
| 2766 | * Associate @accel_group with @window, such that calling | |||
| 2767 | * ctk_accel_groups_activate() on @window will activate accelerators | |||
| 2768 | * in @accel_group. | |||
| 2769 | **/ | |||
| 2770 | void | |||
| 2771 | ctk_window_add_accel_group (CtkWindow *window, | |||
| 2772 | CtkAccelGroup *accel_group) | |||
| 2773 | { | |||
| 2774 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2775 | g_return_if_fail (CTK_IS_ACCEL_GROUP (accel_group))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((accel_group)); GType _t = ((ctk_accel_group_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 ("Ctk", ((const char*) (__func__ )), "CTK_IS_ACCEL_GROUP (accel_group)"); return; } } while (0 ); | |||
| 2776 | ||||
| 2777 | _ctk_accel_group_attach (accel_group, G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | |||
| 2778 | g_signal_connect_object (accel_group, "accel-changed", | |||
| 2779 | G_CALLBACK (_ctk_window_notify_keys_changed)((GCallback) (_ctk_window_notify_keys_changed)), | |||
| 2780 | window, G_CONNECT_SWAPPED); | |||
| 2781 | _ctk_window_notify_keys_changed (window); | |||
| 2782 | } | |||
| 2783 | ||||
| 2784 | /** | |||
| 2785 | * ctk_window_remove_accel_group: | |||
| 2786 | * @window: a #CtkWindow | |||
| 2787 | * @accel_group: a #CtkAccelGroup | |||
| 2788 | * | |||
| 2789 | * Reverses the effects of ctk_window_add_accel_group(). | |||
| 2790 | **/ | |||
| 2791 | void | |||
| 2792 | ctk_window_remove_accel_group (CtkWindow *window, | |||
| 2793 | CtkAccelGroup *accel_group) | |||
| 2794 | { | |||
| 2795 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2796 | g_return_if_fail (CTK_IS_ACCEL_GROUP (accel_group))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((accel_group)); GType _t = ((ctk_accel_group_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 ("Ctk", ((const char*) (__func__ )), "CTK_IS_ACCEL_GROUP (accel_group)"); return; } } while (0 ); | |||
| 2797 | ||||
| 2798 | g_signal_handlers_disconnect_by_func (accel_group,g_signal_handlers_disconnect_matched ((accel_group), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (_ctk_window_notify_keys_changed), (window)) | |||
| 2799 | _ctk_window_notify_keys_changed,g_signal_handlers_disconnect_matched ((accel_group), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (_ctk_window_notify_keys_changed), (window)) | |||
| 2800 | window)g_signal_handlers_disconnect_matched ((accel_group), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (_ctk_window_notify_keys_changed), (window)); | |||
| 2801 | _ctk_accel_group_detach (accel_group, G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | |||
| 2802 | _ctk_window_notify_keys_changed (window); | |||
| 2803 | } | |||
| 2804 | ||||
| 2805 | static CtkMnemonicHash * | |||
| 2806 | ctk_window_get_mnemonic_hash (CtkWindow *window, | |||
| 2807 | gboolean create) | |||
| 2808 | { | |||
| 2809 | CtkWindowPrivate *private = window->priv; | |||
| 2810 | ||||
| 2811 | if (!private->mnemonic_hash && create) | |||
| 2812 | private->mnemonic_hash = _ctk_mnemonic_hash_new (); | |||
| 2813 | ||||
| 2814 | return private->mnemonic_hash; | |||
| 2815 | } | |||
| 2816 | ||||
| 2817 | /** | |||
| 2818 | * ctk_window_add_mnemonic: | |||
| 2819 | * @window: a #CtkWindow | |||
| 2820 | * @keyval: the mnemonic | |||
| 2821 | * @target: the widget that gets activated by the mnemonic | |||
| 2822 | * | |||
| 2823 | * Adds a mnemonic to this window. | |||
| 2824 | */ | |||
| 2825 | void | |||
| 2826 | ctk_window_add_mnemonic (CtkWindow *window, | |||
| 2827 | guint keyval, | |||
| 2828 | CtkWidget *target) | |||
| 2829 | { | |||
| 2830 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2831 | g_return_if_fail (CTK_IS_WIDGET (target))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((target)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (target)" ); return; } } while (0); | |||
| 2832 | ||||
| 2833 | _ctk_mnemonic_hash_add (ctk_window_get_mnemonic_hash (window, TRUE(!(0))), | |||
| 2834 | keyval, target); | |||
| 2835 | _ctk_window_notify_keys_changed (window); | |||
| 2836 | } | |||
| 2837 | ||||
| 2838 | /** | |||
| 2839 | * ctk_window_remove_mnemonic: | |||
| 2840 | * @window: a #CtkWindow | |||
| 2841 | * @keyval: the mnemonic | |||
| 2842 | * @target: the widget that gets activated by the mnemonic | |||
| 2843 | * | |||
| 2844 | * Removes a mnemonic from this window. | |||
| 2845 | */ | |||
| 2846 | void | |||
| 2847 | ctk_window_remove_mnemonic (CtkWindow *window, | |||
| 2848 | guint keyval, | |||
| 2849 | CtkWidget *target) | |||
| 2850 | { | |||
| 2851 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2852 | g_return_if_fail (CTK_IS_WIDGET (target))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((target)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (target)" ); return; } } while (0); | |||
| 2853 | ||||
| 2854 | _ctk_mnemonic_hash_remove (ctk_window_get_mnemonic_hash (window, TRUE(!(0))), | |||
| 2855 | keyval, target); | |||
| 2856 | _ctk_window_notify_keys_changed (window); | |||
| 2857 | } | |||
| 2858 | ||||
| 2859 | /** | |||
| 2860 | * ctk_window_mnemonic_activate: | |||
| 2861 | * @window: a #CtkWindow | |||
| 2862 | * @keyval: the mnemonic | |||
| 2863 | * @modifier: the modifiers | |||
| 2864 | * | |||
| 2865 | * Activates the targets associated with the mnemonic. | |||
| 2866 | * | |||
| 2867 | * Returns: %TRUE if the activation is done. | |||
| 2868 | */ | |||
| 2869 | gboolean | |||
| 2870 | ctk_window_mnemonic_activate (CtkWindow *window, | |||
| 2871 | guint keyval, | |||
| 2872 | CdkModifierType modifier) | |||
| 2873 | { | |||
| 2874 | CtkWindowPrivate *priv; | |||
| 2875 | ||||
| 2876 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 2877 | ||||
| 2878 | priv = window->priv; | |||
| 2879 | ||||
| 2880 | if (priv->mnemonic_modifier == (modifier & ctk_accelerator_get_default_mod_mask ())) | |||
| 2881 | { | |||
| 2882 | CtkMnemonicHash *mnemonic_hash = ctk_window_get_mnemonic_hash (window, FALSE(0)); | |||
| 2883 | if (mnemonic_hash) | |||
| 2884 | return _ctk_mnemonic_hash_activate (mnemonic_hash, keyval); | |||
| 2885 | } | |||
| 2886 | ||||
| 2887 | return FALSE(0); | |||
| 2888 | } | |||
| 2889 | ||||
| 2890 | /** | |||
| 2891 | * ctk_window_set_mnemonic_modifier: | |||
| 2892 | * @window: a #CtkWindow | |||
| 2893 | * @modifier: the modifier mask used to activate | |||
| 2894 | * mnemonics on this window. | |||
| 2895 | * | |||
| 2896 | * Sets the mnemonic modifier for this window. | |||
| 2897 | **/ | |||
| 2898 | void | |||
| 2899 | ctk_window_set_mnemonic_modifier (CtkWindow *window, | |||
| 2900 | CdkModifierType modifier) | |||
| 2901 | { | |||
| 2902 | CtkWindowPrivate *priv; | |||
| 2903 | ||||
| 2904 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2905 | g_return_if_fail ((modifier & ~CDK_MODIFIER_MASK) == 0)do { if (((modifier & ~CDK_MODIFIER_MASK) == 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "(modifier & ~CDK_MODIFIER_MASK) == 0"); return; } } while (0); | |||
| 2906 | ||||
| 2907 | priv = window->priv; | |||
| 2908 | ||||
| 2909 | priv->mnemonic_modifier = modifier; | |||
| 2910 | _ctk_window_notify_keys_changed (window); | |||
| 2911 | } | |||
| 2912 | ||||
| 2913 | /** | |||
| 2914 | * ctk_window_get_mnemonic_modifier: | |||
| 2915 | * @window: a #CtkWindow | |||
| 2916 | * | |||
| 2917 | * Returns the mnemonic modifier for this window. See | |||
| 2918 | * ctk_window_set_mnemonic_modifier(). | |||
| 2919 | * | |||
| 2920 | * Returns: the modifier mask used to activate | |||
| 2921 | * mnemonics on this window. | |||
| 2922 | **/ | |||
| 2923 | CdkModifierType | |||
| 2924 | ctk_window_get_mnemonic_modifier (CtkWindow *window) | |||
| 2925 | { | |||
| 2926 | g_return_val_if_fail (CTK_IS_WINDOW (window), 0)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (0); } } while (0); | |||
| 2927 | ||||
| 2928 | return window->priv->mnemonic_modifier; | |||
| 2929 | } | |||
| 2930 | ||||
| 2931 | /** | |||
| 2932 | * ctk_window_set_position: | |||
| 2933 | * @window: a #CtkWindow. | |||
| 2934 | * @position: a position constraint. | |||
| 2935 | * | |||
| 2936 | * Sets a position constraint for this window. If the old or new | |||
| 2937 | * constraint is %CTK_WIN_POS_CENTER_ALWAYS, this will also cause | |||
| 2938 | * the window to be repositioned to satisfy the new constraint. | |||
| 2939 | **/ | |||
| 2940 | void | |||
| 2941 | ctk_window_set_position (CtkWindow *window, | |||
| 2942 | CtkWindowPosition position) | |||
| 2943 | { | |||
| 2944 | CtkWindowPrivate *priv; | |||
| 2945 | ||||
| 2946 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 2947 | ||||
| 2948 | priv = window->priv; | |||
| 2949 | ||||
| 2950 | if (position == CTK_WIN_POS_CENTER_ALWAYS || | |||
| 2951 | priv->position == CTK_WIN_POS_CENTER_ALWAYS) | |||
| 2952 | { | |||
| 2953 | CtkWindowGeometryInfo *info; | |||
| 2954 | ||||
| 2955 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 2956 | ||||
| 2957 | /* this flag causes us to re-request the CENTER_ALWAYS | |||
| 2958 | * constraint in ctk_window_move_resize(), see | |||
| 2959 | * comment in that function. | |||
| 2960 | */ | |||
| 2961 | info->position_constraints_changed = TRUE(!(0)); | |||
| 2962 | ||||
| 2963 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 2964 | } | |||
| 2965 | ||||
| 2966 | if (priv->position != position) | |||
| 2967 | { | |||
| 2968 | priv->position = position; | |||
| 2969 | ||||
| 2970 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_WIN_POS]); | |||
| 2971 | } | |||
| 2972 | } | |||
| 2973 | ||||
| 2974 | /** | |||
| 2975 | * ctk_window_activate_focus: | |||
| 2976 | * @window: a #CtkWindow | |||
| 2977 | * | |||
| 2978 | * Activates the current focused widget within the window. | |||
| 2979 | * | |||
| 2980 | * Returns: %TRUE if a widget got activated. | |||
| 2981 | **/ | |||
| 2982 | gboolean | |||
| 2983 | ctk_window_activate_focus (CtkWindow *window) | |||
| 2984 | { | |||
| 2985 | CtkWindowPrivate *priv; | |||
| 2986 | ||||
| 2987 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 2988 | ||||
| 2989 | priv = window->priv; | |||
| 2990 | ||||
| 2991 | if (priv->focus_widget && ctk_widget_is_sensitive (priv->focus_widget)) | |||
| 2992 | return ctk_widget_activate (priv->focus_widget); | |||
| 2993 | ||||
| 2994 | return FALSE(0); | |||
| 2995 | } | |||
| 2996 | ||||
| 2997 | /** | |||
| 2998 | * ctk_window_get_focus: | |||
| 2999 | * @window: a #CtkWindow | |||
| 3000 | * | |||
| 3001 | * Retrieves the current focused widget within the window. | |||
| 3002 | * Note that this is the widget that would have the focus | |||
| 3003 | * if the toplevel window focused; if the toplevel window | |||
| 3004 | * is not focused then `ctk_widget_has_focus (widget)` will | |||
| 3005 | * not be %TRUE for the widget. | |||
| 3006 | * | |||
| 3007 | * Returns: (nullable) (transfer none): the currently focused widget, | |||
| 3008 | * or %NULL if there is none. | |||
| 3009 | **/ | |||
| 3010 | CtkWidget * | |||
| 3011 | ctk_window_get_focus (CtkWindow *window) | |||
| 3012 | { | |||
| 3013 | CtkWindowPrivate *priv; | |||
| 3014 | ||||
| 3015 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 3016 | ||||
| 3017 | priv = window->priv; | |||
| 3018 | ||||
| 3019 | if (priv->initial_focus) | |||
| 3020 | return priv->initial_focus; | |||
| 3021 | else | |||
| 3022 | return priv->focus_widget; | |||
| 3023 | } | |||
| 3024 | ||||
| 3025 | /** | |||
| 3026 | * ctk_window_activate_default: | |||
| 3027 | * @window: a #CtkWindow | |||
| 3028 | * | |||
| 3029 | * Activates the default widget for the window, unless the current | |||
| 3030 | * focused widget has been configured to receive the default action | |||
| 3031 | * (see ctk_widget_set_receives_default()), in which case the | |||
| 3032 | * focused widget is activated. | |||
| 3033 | * | |||
| 3034 | * Returns: %TRUE if a widget got activated. | |||
| 3035 | **/ | |||
| 3036 | gboolean | |||
| 3037 | ctk_window_activate_default (CtkWindow *window) | |||
| 3038 | { | |||
| 3039 | CtkWindowPrivate *priv; | |||
| 3040 | ||||
| 3041 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3042 | ||||
| 3043 | priv = window->priv; | |||
| 3044 | ||||
| 3045 | if (priv->default_widget && ctk_widget_is_sensitive (priv->default_widget) && | |||
| 3046 | (!priv->focus_widget || !ctk_widget_get_receives_default (priv->focus_widget))) | |||
| 3047 | return ctk_widget_activate (priv->default_widget); | |||
| 3048 | else if (priv->focus_widget && ctk_widget_is_sensitive (priv->focus_widget)) | |||
| 3049 | return ctk_widget_activate (priv->focus_widget); | |||
| 3050 | ||||
| 3051 | return FALSE(0); | |||
| 3052 | } | |||
| 3053 | ||||
| 3054 | /** | |||
| 3055 | * ctk_window_set_modal: | |||
| 3056 | * @window: a #CtkWindow | |||
| 3057 | * @modal: whether the window is modal | |||
| 3058 | * | |||
| 3059 | * Sets a window modal or non-modal. Modal windows prevent interaction | |||
| 3060 | * with other windows in the same application. To keep modal dialogs | |||
| 3061 | * on top of main application windows, use | |||
| 3062 | * ctk_window_set_transient_for() to make the dialog transient for the | |||
| 3063 | * parent; most [window managers][ctk-X11-arch] | |||
| 3064 | * will then disallow lowering the dialog below the parent. | |||
| 3065 | * | |||
| 3066 | * | |||
| 3067 | **/ | |||
| 3068 | void | |||
| 3069 | ctk_window_set_modal (CtkWindow *window, | |||
| 3070 | gboolean modal) | |||
| 3071 | { | |||
| 3072 | CtkWindowPrivate *priv; | |||
| 3073 | CtkWidget *widget; | |||
| 3074 | ||||
| 3075 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3076 | ||||
| 3077 | priv = window->priv; | |||
| 3078 | ||||
| 3079 | modal = modal != FALSE(0); | |||
| 3080 | if (priv->modal == modal) | |||
| 3081 | return; | |||
| 3082 | ||||
| 3083 | priv->modal = modal; | |||
| 3084 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 3085 | ||||
| 3086 | /* adjust desired modality state */ | |||
| 3087 | if (_ctk_widget_get_realized (widget)) | |||
| 3088 | cdk_window_set_modal_hint (_ctk_widget_get_window (widget), priv->modal); | |||
| 3089 | ||||
| 3090 | if (ctk_widget_get_visible (widget)) | |||
| 3091 | { | |||
| 3092 | if (priv->modal) | |||
| 3093 | ctk_grab_add (widget); | |||
| 3094 | else | |||
| 3095 | ctk_grab_remove (widget); | |||
| 3096 | } | |||
| 3097 | ||||
| 3098 | update_window_buttons (window); | |||
| 3099 | ||||
| 3100 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_MODAL]); | |||
| 3101 | } | |||
| 3102 | ||||
| 3103 | /** | |||
| 3104 | * ctk_window_get_modal: | |||
| 3105 | * @window: a #CtkWindow | |||
| 3106 | * | |||
| 3107 | * Returns whether the window is modal. See ctk_window_set_modal(). | |||
| 3108 | * | |||
| 3109 | * Returns: %TRUE if the window is set to be modal and | |||
| 3110 | * establishes a grab when shown | |||
| 3111 | **/ | |||
| 3112 | gboolean | |||
| 3113 | ctk_window_get_modal (CtkWindow *window) | |||
| 3114 | { | |||
| 3115 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3116 | ||||
| 3117 | return window->priv->modal; | |||
| 3118 | } | |||
| 3119 | ||||
| 3120 | /** | |||
| 3121 | * ctk_window_list_toplevels: | |||
| 3122 | * | |||
| 3123 | * Returns a list of all existing toplevel windows. The widgets | |||
| 3124 | * in the list are not individually referenced. If you want | |||
| 3125 | * to iterate through the list and perform actions involving | |||
| 3126 | * callbacks that might destroy the widgets, you must call | |||
| 3127 | * `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, and | |||
| 3128 | * then unref all the widgets afterwards. | |||
| 3129 | * | |||
| 3130 | * Returns: (element-type CtkWidget) (transfer container): list of toplevel widgets | |||
| 3131 | **/ | |||
| 3132 | GList* | |||
| 3133 | ctk_window_list_toplevels (void) | |||
| 3134 | { | |||
| 3135 | GList *list = NULL((void*)0); | |||
| 3136 | GSList *slist; | |||
| 3137 | ||||
| 3138 | for (slist = toplevel_list; slist; slist = slist->next) | |||
| 3139 | list = g_list_prepend (list, slist->data); | |||
| 3140 | ||||
| 3141 | return list; | |||
| 3142 | } | |||
| 3143 | ||||
| 3144 | static void | |||
| 3145 | remove_attach_widget (CtkWindow *window) | |||
| 3146 | { | |||
| 3147 | CtkWindowPrivate *priv = window->priv; | |||
| 3148 | ||||
| 3149 | if (priv->attach_widget) | |||
| 3150 | { | |||
| 3151 | _ctk_widget_remove_attached_window (priv->attach_widget, window); | |||
| 3152 | ||||
| 3153 | priv->attach_widget = NULL((void*)0); | |||
| 3154 | } | |||
| 3155 | } | |||
| 3156 | ||||
| 3157 | static void | |||
| 3158 | ctk_window_dispose (GObject *object) | |||
| 3159 | { | |||
| 3160 | CtkWindow *window = CTK_WINDOW (object)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_window_get_type ())))))); | |||
| 3161 | CtkWindowPrivate *priv = window->priv; | |||
| 3162 | ||||
| 3163 | ctk_window_set_focus (window, NULL((void*)0)); | |||
| 3164 | ctk_window_set_default (window, NULL((void*)0)); | |||
| 3165 | remove_attach_widget (window); | |||
| 3166 | ||||
| 3167 | G_OBJECT_CLASS (ctk_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), (((GType) ((20) << (2)) ))))))->dispose (object); | |||
| 3168 | unset_titlebar (window); | |||
| 3169 | ||||
| 3170 | while (priv->popovers) | |||
| 3171 | { | |||
| 3172 | CtkWindowPopover *popover = priv->popovers->data; | |||
| 3173 | priv->popovers = g_list_delete_link (priv->popovers, priv->popovers); | |||
| 3174 | popover_destroy (popover); | |||
| 3175 | } | |||
| 3176 | ||||
| 3177 | } | |||
| 3178 | ||||
| 3179 | static void | |||
| 3180 | parent_destroyed_callback (CtkWindow *parent G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 3181 | CtkWindow *child) | |||
| 3182 | { | |||
| 3183 | ctk_widget_destroy (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); | |||
| 3184 | } | |||
| 3185 | ||||
| 3186 | static void | |||
| 3187 | connect_parent_destroyed (CtkWindow *window) | |||
| 3188 | { | |||
| 3189 | CtkWindowPrivate *priv = window->priv; | |||
| 3190 | ||||
| 3191 | if (priv->transient_parent) | |||
| 3192 | { | |||
| 3193 | g_signal_connect (priv->transient_parent,g_signal_connect_data ((priv->transient_parent), ("destroy" ), (((GCallback) (parent_destroyed_callback))), (window), ((void *)0), (GConnectFlags) 0) | |||
| 3194 | "destroy",g_signal_connect_data ((priv->transient_parent), ("destroy" ), (((GCallback) (parent_destroyed_callback))), (window), ((void *)0), (GConnectFlags) 0) | |||
| 3195 | G_CALLBACK (parent_destroyed_callback),g_signal_connect_data ((priv->transient_parent), ("destroy" ), (((GCallback) (parent_destroyed_callback))), (window), ((void *)0), (GConnectFlags) 0) | |||
| 3196 | window)g_signal_connect_data ((priv->transient_parent), ("destroy" ), (((GCallback) (parent_destroyed_callback))), (window), ((void *)0), (GConnectFlags) 0); | |||
| 3197 | } | |||
| 3198 | } | |||
| 3199 | ||||
| 3200 | static void | |||
| 3201 | disconnect_parent_destroyed (CtkWindow *window) | |||
| 3202 | { | |||
| 3203 | CtkWindowPrivate *priv = window->priv; | |||
| 3204 | ||||
| 3205 | if (priv->transient_parent) | |||
| 3206 | { | |||
| 3207 | g_signal_handlers_disconnect_by_func (priv->transient_parent,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (parent_destroyed_callback), (window)) | |||
| 3208 | parent_destroyed_callback,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (parent_destroyed_callback), (window)) | |||
| 3209 | window)g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (parent_destroyed_callback), (window)); | |||
| 3210 | } | |||
| 3211 | } | |||
| 3212 | ||||
| 3213 | static void | |||
| 3214 | ctk_window_transient_parent_realized (CtkWidget *parent, | |||
| 3215 | CtkWidget *window) | |||
| 3216 | { | |||
| 3217 | if (_ctk_widget_get_realized (window)) | |||
| 3218 | cdk_window_set_transient_for (_ctk_widget_get_window (window), | |||
| 3219 | _ctk_widget_get_window (parent)); | |||
| 3220 | } | |||
| 3221 | ||||
| 3222 | static void | |||
| 3223 | ctk_window_transient_parent_unrealized (CtkWidget *parent G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 3224 | CtkWidget *window) | |||
| 3225 | { | |||
| 3226 | if (_ctk_widget_get_realized (window)) | |||
| 3227 | cdk_property_delete (_ctk_widget_get_window (window), | |||
| 3228 | cdk_atom_intern_static_string ("WM_TRANSIENT_FOR")); | |||
| 3229 | } | |||
| 3230 | ||||
| 3231 | static void | |||
| 3232 | ctk_window_transient_parent_screen_changed (CtkWindow *parent, | |||
| 3233 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 3234 | CtkWindow *window) | |||
| 3235 | { | |||
| 3236 | ctk_window_set_screen (window, parent->priv->screen); | |||
| 3237 | } | |||
| 3238 | ||||
| 3239 | static void | |||
| 3240 | ctk_window_unset_transient_for (CtkWindow *window) | |||
| 3241 | { | |||
| 3242 | CtkWindowPrivate *priv = window->priv; | |||
| 3243 | ||||
| 3244 | if (priv->transient_parent) | |||
| 3245 | { | |||
| 3246 | g_signal_handlers_disconnect_by_func (priv->transient_parent,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_realized), ( window)) | |||
| 3247 | ctk_window_transient_parent_realized,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_realized), ( window)) | |||
| 3248 | window)g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_realized), ( window)); | |||
| 3249 | g_signal_handlers_disconnect_by_func (priv->transient_parent,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_unrealized) , (window)) | |||
| 3250 | ctk_window_transient_parent_unrealized,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_unrealized) , (window)) | |||
| 3251 | window)g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_unrealized) , (window)); | |||
| 3252 | g_signal_handlers_disconnect_by_func (priv->transient_parent,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_screen_changed ), (window)) | |||
| 3253 | ctk_window_transient_parent_screen_changed,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_screen_changed ), (window)) | |||
| 3254 | window)g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_window_transient_parent_screen_changed ), (window)); | |||
| 3255 | g_signal_handlers_disconnect_by_func (priv->transient_parent,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->transient_parent )) | |||
| 3256 | ctk_widget_destroyed,g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->transient_parent )) | |||
| 3257 | &priv->transient_parent)g_signal_handlers_disconnect_matched ((priv->transient_parent ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->transient_parent )); | |||
| 3258 | ||||
| 3259 | if (priv->destroy_with_parent) | |||
| 3260 | disconnect_parent_destroyed (window); | |||
| 3261 | ||||
| 3262 | priv->transient_parent = NULL((void*)0); | |||
| 3263 | ||||
| 3264 | if (priv->transient_parent_group) | |||
| 3265 | { | |||
| 3266 | priv->transient_parent_group = FALSE(0); | |||
| 3267 | ctk_window_group_remove_window (priv->group, | |||
| 3268 | window); | |||
| 3269 | } | |||
| 3270 | } | |||
| 3271 | } | |||
| 3272 | ||||
| 3273 | /** | |||
| 3274 | * ctk_window_set_transient_for: | |||
| 3275 | * @window: a #CtkWindow | |||
| 3276 | * @parent: (allow-none): parent window, or %NULL | |||
| 3277 | * | |||
| 3278 | * Dialog windows should be set transient for the main application | |||
| 3279 | * window they were spawned from. This allows | |||
| 3280 | * [window managers][ctk-X11-arch] to e.g. keep the | |||
| 3281 | * dialog on top of the main window, or center the dialog over the | |||
| 3282 | * main window. ctk_dialog_new_with_buttons() and other convenience | |||
| 3283 | * functions in CTK+ will sometimes call | |||
| 3284 | * ctk_window_set_transient_for() on your behalf. | |||
| 3285 | * | |||
| 3286 | * Passing %NULL for @parent unsets the current transient window. | |||
| 3287 | * | |||
| 3288 | * On Wayland, this function can also be used to attach a new | |||
| 3289 | * #CTK_WINDOW_POPUP to a #CTK_WINDOW_TOPLEVEL parent already mapped | |||
| 3290 | * on screen so that the #CTK_WINDOW_POPUP will be created as a | |||
| 3291 | * subsurface-based window #CDK_WINDOW_SUBSURFACE which can be | |||
| 3292 | * positioned at will relatively to the #CTK_WINDOW_TOPLEVEL surface. | |||
| 3293 | * | |||
| 3294 | * On Windows, this function puts the child window on top of the parent, | |||
| 3295 | * much as the window manager would have done on X. | |||
| 3296 | */ | |||
| 3297 | void | |||
| 3298 | ctk_window_set_transient_for (CtkWindow *window, | |||
| 3299 | CtkWindow *parent) | |||
| 3300 | { | |||
| 3301 | CtkWindowPrivate *priv; | |||
| 3302 | ||||
| 3303 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3304 | g_return_if_fail (parent == NULL || CTK_IS_WINDOW (parent))do { if ((parent == ((void*)0) || (((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ((parent)); GType _t = ((ctk_window_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 ("Ctk", ((const char *) (__func__)), "parent == NULL || CTK_IS_WINDOW (parent)"); return ; } } while (0); | |||
| 3305 | g_return_if_fail (window != parent)do { if ((window != parent)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "window != parent"); return ; } } while (0); | |||
| 3306 | ||||
| 3307 | priv = window->priv; | |||
| 3308 | ||||
| 3309 | if (priv->transient_parent) | |||
| 3310 | { | |||
| 3311 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) && | |||
| 3312 | _ctk_widget_get_realized (CTK_WIDGET (priv->transient_parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->transient_parent)), ((ctk_widget_get_type ()))) )))) && | |||
| 3313 | (!parent || !_ctk_widget_get_realized (CTK_WIDGET (parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_widget_get_type ()))))))))) | |||
| 3314 | ctk_window_transient_parent_unrealized (CTK_WIDGET (priv->transient_parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->transient_parent)), ((ctk_widget_get_type ()))) ))), | |||
| 3315 | CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3316 | ||||
| 3317 | ctk_window_unset_transient_for (window); | |||
| 3318 | } | |||
| 3319 | ||||
| 3320 | priv->transient_parent = parent; | |||
| 3321 | ||||
| 3322 | if (parent) | |||
| 3323 | { | |||
| 3324 | g_signal_connect (parent, "destroy",g_signal_connect_data ((parent), ("destroy"), (((GCallback) ( ctk_widget_destroyed))), (&priv->transient_parent), (( void*)0), (GConnectFlags) 0) | |||
| 3325 | G_CALLBACK (ctk_widget_destroyed),g_signal_connect_data ((parent), ("destroy"), (((GCallback) ( ctk_widget_destroyed))), (&priv->transient_parent), (( void*)0), (GConnectFlags) 0) | |||
| 3326 | &priv->transient_parent)g_signal_connect_data ((parent), ("destroy"), (((GCallback) ( ctk_widget_destroyed))), (&priv->transient_parent), (( void*)0), (GConnectFlags) 0); | |||
| 3327 | g_signal_connect (parent, "realize",g_signal_connect_data ((parent), ("realize"), (((GCallback) ( ctk_window_transient_parent_realized))), (window), ((void*)0) , (GConnectFlags) 0) | |||
| 3328 | G_CALLBACK (ctk_window_transient_parent_realized),g_signal_connect_data ((parent), ("realize"), (((GCallback) ( ctk_window_transient_parent_realized))), (window), ((void*)0) , (GConnectFlags) 0) | |||
| 3329 | window)g_signal_connect_data ((parent), ("realize"), (((GCallback) ( ctk_window_transient_parent_realized))), (window), ((void*)0) , (GConnectFlags) 0); | |||
| 3330 | g_signal_connect (parent, "unrealize",g_signal_connect_data ((parent), ("unrealize"), (((GCallback) (ctk_window_transient_parent_unrealized))), (window), ((void *)0), (GConnectFlags) 0) | |||
| 3331 | G_CALLBACK (ctk_window_transient_parent_unrealized),g_signal_connect_data ((parent), ("unrealize"), (((GCallback) (ctk_window_transient_parent_unrealized))), (window), ((void *)0), (GConnectFlags) 0) | |||
| 3332 | window)g_signal_connect_data ((parent), ("unrealize"), (((GCallback) (ctk_window_transient_parent_unrealized))), (window), ((void *)0), (GConnectFlags) 0); | |||
| 3333 | g_signal_connect (parent, "notify::screen",g_signal_connect_data ((parent), ("notify::screen"), (((GCallback ) (ctk_window_transient_parent_screen_changed))), (window), ( (void*)0), (GConnectFlags) 0) | |||
| 3334 | G_CALLBACK (ctk_window_transient_parent_screen_changed),g_signal_connect_data ((parent), ("notify::screen"), (((GCallback ) (ctk_window_transient_parent_screen_changed))), (window), ( (void*)0), (GConnectFlags) 0) | |||
| 3335 | window)g_signal_connect_data ((parent), ("notify::screen"), (((GCallback ) (ctk_window_transient_parent_screen_changed))), (window), ( (void*)0), (GConnectFlags) 0); | |||
| 3336 | ||||
| 3337 | ctk_window_set_screen (window, parent->priv->screen); | |||
| 3338 | ||||
| 3339 | if (priv->destroy_with_parent) | |||
| 3340 | connect_parent_destroyed (window); | |||
| 3341 | ||||
| 3342 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) && | |||
| 3343 | _ctk_widget_get_realized (CTK_WIDGET (parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_widget_get_type ())))))))) | |||
| 3344 | ctk_window_transient_parent_realized (CTK_WIDGET (parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_widget_get_type ())))))), | |||
| 3345 | CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3346 | ||||
| 3347 | if (parent->priv->group) | |||
| 3348 | { | |||
| 3349 | ctk_window_group_add_window (parent->priv->group, window); | |||
| 3350 | priv->transient_parent_group = TRUE(!(0)); | |||
| 3351 | } | |||
| 3352 | } | |||
| 3353 | ||||
| 3354 | update_window_buttons (window); | |||
| 3355 | ||||
| 3356 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_TRANSIENT_FOR]); | |||
| 3357 | } | |||
| 3358 | ||||
| 3359 | /** | |||
| 3360 | * ctk_window_get_transient_for: | |||
| 3361 | * @window: a #CtkWindow | |||
| 3362 | * | |||
| 3363 | * Fetches the transient parent for this window. See | |||
| 3364 | * ctk_window_set_transient_for(). | |||
| 3365 | * | |||
| 3366 | * Returns: (nullable) (transfer none): the transient parent for this | |||
| 3367 | * window, or %NULL if no transient parent has been set. | |||
| 3368 | **/ | |||
| 3369 | CtkWindow * | |||
| 3370 | ctk_window_get_transient_for (CtkWindow *window) | |||
| 3371 | { | |||
| 3372 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 3373 | ||||
| 3374 | return window->priv->transient_parent; | |||
| 3375 | } | |||
| 3376 | ||||
| 3377 | /** | |||
| 3378 | * ctk_window_set_attached_to: | |||
| 3379 | * @window: a #CtkWindow | |||
| 3380 | * @attach_widget: (allow-none): a #CtkWidget, or %NULL | |||
| 3381 | * | |||
| 3382 | * Marks @window as attached to @attach_widget. This creates a logical binding | |||
| 3383 | * between the window and the widget it belongs to, which is used by CTK+ to | |||
| 3384 | * propagate information such as styling or accessibility to @window as if it | |||
| 3385 | * was a children of @attach_widget. | |||
| 3386 | * | |||
| 3387 | * Examples of places where specifying this relation is useful are for instance | |||
| 3388 | * a #CtkMenu created by a #CtkComboBox, a completion popup window | |||
| 3389 | * created by #CtkEntry or a typeahead search entry created by #CtkTreeView. | |||
| 3390 | * | |||
| 3391 | * Note that this function should not be confused with | |||
| 3392 | * ctk_window_set_transient_for(), which specifies a window manager relation | |||
| 3393 | * between two toplevels instead. | |||
| 3394 | * | |||
| 3395 | * Passing %NULL for @attach_widget detaches the window. | |||
| 3396 | * | |||
| 3397 | * Since: 3.4 | |||
| 3398 | **/ | |||
| 3399 | void | |||
| 3400 | ctk_window_set_attached_to (CtkWindow *window, | |||
| 3401 | CtkWidget *attach_widget) | |||
| 3402 | { | |||
| 3403 | CtkStyleContext *context; | |||
| 3404 | CtkWindowPrivate *priv; | |||
| 3405 | ||||
| 3406 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3407 | g_return_if_fail (CTK_WIDGET (window) != attach_widget)do { if ((((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ())))))) != attach_widget)) { } else { g_return_if_fail_warning ("Ctk" , ((const char*) (__func__)), "CTK_WIDGET (window) != attach_widget" ); return; } } while (0); | |||
| 3408 | ||||
| 3409 | priv = window->priv; | |||
| 3410 | ||||
| 3411 | if (priv->attach_widget == attach_widget) | |||
| 3412 | return; | |||
| 3413 | ||||
| 3414 | remove_attach_widget (window); | |||
| 3415 | ||||
| 3416 | priv->attach_widget = attach_widget; | |||
| 3417 | ||||
| 3418 | if (priv->attach_widget) | |||
| 3419 | { | |||
| 3420 | _ctk_widget_add_attached_window (priv->attach_widget, window); | |||
| 3421 | } | |||
| 3422 | ||||
| 3423 | /* Update the style, as the widget path might change. */ | |||
| 3424 | context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3425 | if (priv->attach_widget) | |||
| 3426 | ctk_style_context_set_parent (context, ctk_widget_get_style_context (priv->attach_widget)); | |||
| 3427 | else | |||
| 3428 | ctk_style_context_set_parent (context, NULL((void*)0)); | |||
| 3429 | ||||
| 3430 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_ATTACHED_TO]); | |||
| 3431 | } | |||
| 3432 | ||||
| 3433 | /** | |||
| 3434 | * ctk_window_get_attached_to: | |||
| 3435 | * @window: a #CtkWindow | |||
| 3436 | * | |||
| 3437 | * Fetches the attach widget for this window. See | |||
| 3438 | * ctk_window_set_attached_to(). | |||
| 3439 | * | |||
| 3440 | * Returns: (nullable) (transfer none): the widget where the window | |||
| 3441 | * is attached, or %NULL if the window is not attached to any widget. | |||
| 3442 | * | |||
| 3443 | * Since: 3.4 | |||
| 3444 | **/ | |||
| 3445 | CtkWidget * | |||
| 3446 | ctk_window_get_attached_to (CtkWindow *window) | |||
| 3447 | { | |||
| 3448 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 3449 | ||||
| 3450 | return window->priv->attach_widget; | |||
| 3451 | } | |||
| 3452 | ||||
| 3453 | /** | |||
| 3454 | * ctk_window_set_opacity: | |||
| 3455 | * @window: a #CtkWindow | |||
| 3456 | * @opacity: desired opacity, between 0 and 1 | |||
| 3457 | * | |||
| 3458 | * Request the windowing system to make @window partially transparent, | |||
| 3459 | * with opacity 0 being fully transparent and 1 fully opaque. (Values | |||
| 3460 | * of the opacity parameter are clamped to the [0,1] range.) On X11 | |||
| 3461 | * this has any effect only on X screens with a compositing manager | |||
| 3462 | * running. See ctk_widget_is_composited(). On Windows it should work | |||
| 3463 | * always. | |||
| 3464 | * | |||
| 3465 | * Note that setting a window’s opacity after the window has been | |||
| 3466 | * shown causes it to flicker once on Windows. | |||
| 3467 | * | |||
| 3468 | * Since: 2.12 | |||
| 3469 | * Deprecated: 3.8: Use ctk_widget_set_opacity instead. | |||
| 3470 | **/ | |||
| 3471 | void | |||
| 3472 | ctk_window_set_opacity (CtkWindow *window, | |||
| 3473 | gdouble opacity) | |||
| 3474 | { | |||
| 3475 | ctk_widget_set_opacity (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), opacity); | |||
| 3476 | } | |||
| 3477 | ||||
| 3478 | /** | |||
| 3479 | * ctk_window_get_opacity: | |||
| 3480 | * @window: a #CtkWindow | |||
| 3481 | * | |||
| 3482 | * Fetches the requested opacity for this window. See | |||
| 3483 | * ctk_window_set_opacity(). | |||
| 3484 | * | |||
| 3485 | * Returns: the requested opacity for this window. | |||
| 3486 | * | |||
| 3487 | * Since: 2.12 | |||
| 3488 | * Deprecated: 3.8: Use ctk_widget_get_opacity instead. | |||
| 3489 | **/ | |||
| 3490 | gdouble | |||
| 3491 | ctk_window_get_opacity (CtkWindow *window) | |||
| 3492 | { | |||
| 3493 | g_return_val_if_fail (CTK_IS_WINDOW (window), 0.0)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (0.0); } } while (0); | |||
| 3494 | ||||
| 3495 | return ctk_widget_get_opacity (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3496 | } | |||
| 3497 | ||||
| 3498 | /** | |||
| 3499 | * ctk_window_get_application: | |||
| 3500 | * @window: a #CtkWindow | |||
| 3501 | * | |||
| 3502 | * Gets the #CtkApplication associated with the window (if any). | |||
| 3503 | * | |||
| 3504 | * Returns: (nullable) (transfer none): a #CtkApplication, or %NULL | |||
| 3505 | * | |||
| 3506 | * Since: 3.0 | |||
| 3507 | **/ | |||
| 3508 | CtkApplication * | |||
| 3509 | ctk_window_get_application (CtkWindow *window) | |||
| 3510 | { | |||
| 3511 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 3512 | ||||
| 3513 | return window->priv->application; | |||
| 3514 | } | |||
| 3515 | ||||
| 3516 | static void | |||
| 3517 | ctk_window_release_application (CtkWindow *window) | |||
| 3518 | { | |||
| 3519 | if (window->priv->application) | |||
| 3520 | { | |||
| 3521 | CtkApplication *application; | |||
| 3522 | ||||
| 3523 | /* steal reference into temp variable */ | |||
| 3524 | application = window->priv->application; | |||
| 3525 | window->priv->application = NULL((void*)0); | |||
| 3526 | ||||
| 3527 | ctk_application_remove_window (application, window); | |||
| 3528 | g_object_unref (application); | |||
| 3529 | } | |||
| 3530 | } | |||
| 3531 | ||||
| 3532 | /** | |||
| 3533 | * ctk_window_set_application: | |||
| 3534 | * @window: a #CtkWindow | |||
| 3535 | * @application: (allow-none): a #CtkApplication, or %NULL to unset | |||
| 3536 | * | |||
| 3537 | * Sets or unsets the #CtkApplication associated with the window. | |||
| 3538 | * | |||
| 3539 | * The application will be kept alive for at least as long as it has any windows | |||
| 3540 | * associated with it (see g_application_hold() for a way to keep it alive | |||
| 3541 | * without windows). | |||
| 3542 | * | |||
| 3543 | * Normally, the connection between the application and the window will remain | |||
| 3544 | * until the window is destroyed, but you can explicitly remove it by setting | |||
| 3545 | * the @application to %NULL. | |||
| 3546 | * | |||
| 3547 | * This is equivalent to calling ctk_application_remove_window() and/or | |||
| 3548 | * ctk_application_add_window() on the old/new applications as relevant. | |||
| 3549 | * | |||
| 3550 | * Since: 3.0 | |||
| 3551 | **/ | |||
| 3552 | void | |||
| 3553 | ctk_window_set_application (CtkWindow *window, | |||
| 3554 | CtkApplication *application) | |||
| 3555 | { | |||
| 3556 | CtkWindowPrivate *priv; | |||
| 3557 | ||||
| 3558 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3559 | ||||
| 3560 | priv = window->priv; | |||
| 3561 | if (priv->application != application) | |||
| 3562 | { | |||
| 3563 | ctk_window_release_application (window); | |||
| 3564 | ||||
| 3565 | priv->application = application; | |||
| 3566 | ||||
| 3567 | if (priv->application != NULL((void*)0)) | |||
| 3568 | { | |||
| 3569 | g_object_ref (priv->application)((__typeof__ (priv->application)) (g_object_ref) (priv-> application)); | |||
| 3570 | ||||
| 3571 | ctk_application_add_window (priv->application, window); | |||
| 3572 | } | |||
| 3573 | ||||
| 3574 | _ctk_widget_update_parent_muxer (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3575 | ||||
| 3576 | _ctk_window_notify_keys_changed (window); | |||
| 3577 | ||||
| 3578 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_APPLICATION]); | |||
| 3579 | } | |||
| 3580 | } | |||
| 3581 | ||||
| 3582 | /** | |||
| 3583 | * ctk_window_set_type_hint: | |||
| 3584 | * @window: a #CtkWindow | |||
| 3585 | * @hint: the window type | |||
| 3586 | * | |||
| 3587 | * By setting the type hint for the window, you allow the window | |||
| 3588 | * manager to decorate and handle the window in a way which is | |||
| 3589 | * suitable to the function of the window in your application. | |||
| 3590 | * | |||
| 3591 | * This function should be called before the window becomes visible. | |||
| 3592 | * | |||
| 3593 | * ctk_dialog_new_with_buttons() and other convenience functions in CTK+ | |||
| 3594 | * will sometimes call ctk_window_set_type_hint() on your behalf. | |||
| 3595 | * | |||
| 3596 | **/ | |||
| 3597 | void | |||
| 3598 | ctk_window_set_type_hint (CtkWindow *window, | |||
| 3599 | CdkWindowTypeHint hint) | |||
| 3600 | { | |||
| 3601 | CtkWindowPrivate *priv; | |||
| 3602 | CdkWindow *cdk_window; | |||
| 3603 | ||||
| 3604 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3605 | ||||
| 3606 | priv = window->priv; | |||
| 3607 | ||||
| 3608 | if (priv->type_hint == hint) | |||
| 3609 | return; | |||
| 3610 | ||||
| 3611 | priv->type_hint = hint; | |||
| 3612 | ||||
| 3613 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3614 | if (cdk_window) | |||
| 3615 | cdk_window_set_type_hint (cdk_window, hint); | |||
| 3616 | ||||
| 3617 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_TYPE_HINT]); | |||
| 3618 | ||||
| 3619 | update_window_buttons (window); | |||
| 3620 | } | |||
| 3621 | ||||
| 3622 | /** | |||
| 3623 | * ctk_window_get_type_hint: | |||
| 3624 | * @window: a #CtkWindow | |||
| 3625 | * | |||
| 3626 | * Gets the type hint for this window. See ctk_window_set_type_hint(). | |||
| 3627 | * | |||
| 3628 | * Returns: the type hint for @window. | |||
| 3629 | **/ | |||
| 3630 | CdkWindowTypeHint | |||
| 3631 | ctk_window_get_type_hint (CtkWindow *window) | |||
| 3632 | { | |||
| 3633 | g_return_val_if_fail (CTK_IS_WINDOW (window), CDK_WINDOW_TYPE_HINT_NORMAL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (CDK_WINDOW_TYPE_HINT_NORMAL); } } while (0); | |||
| 3634 | ||||
| 3635 | return window->priv->type_hint; | |||
| 3636 | } | |||
| 3637 | ||||
| 3638 | /** | |||
| 3639 | * ctk_window_set_skip_taskbar_hint: | |||
| 3640 | * @window: a #CtkWindow | |||
| 3641 | * @setting: %TRUE to keep this window from appearing in the task bar | |||
| 3642 | * | |||
| 3643 | * Windows may set a hint asking the desktop environment not to display | |||
| 3644 | * the window in the task bar. This function sets this hint. | |||
| 3645 | * | |||
| 3646 | * Since: 2.2 | |||
| 3647 | **/ | |||
| 3648 | void | |||
| 3649 | ctk_window_set_skip_taskbar_hint (CtkWindow *window, | |||
| 3650 | gboolean setting) | |||
| 3651 | { | |||
| 3652 | CtkWindowPrivate *priv; | |||
| 3653 | ||||
| 3654 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3655 | ||||
| 3656 | priv = window->priv; | |||
| 3657 | ||||
| 3658 | setting = setting != FALSE(0); | |||
| 3659 | ||||
| 3660 | if (priv->skips_taskbar != setting) | |||
| 3661 | { | |||
| 3662 | priv->skips_taskbar = setting; | |||
| 3663 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 3664 | cdk_window_set_skip_taskbar_hint (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 3665 | priv->skips_taskbar); | |||
| 3666 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_SKIP_TASKBAR_HINT]); | |||
| 3667 | } | |||
| 3668 | } | |||
| 3669 | ||||
| 3670 | /** | |||
| 3671 | * ctk_window_get_skip_taskbar_hint: | |||
| 3672 | * @window: a #CtkWindow | |||
| 3673 | * | |||
| 3674 | * Gets the value set by ctk_window_set_skip_taskbar_hint() | |||
| 3675 | * | |||
| 3676 | * Returns: %TRUE if window shouldn’t be in taskbar | |||
| 3677 | * | |||
| 3678 | * Since: 2.2 | |||
| 3679 | **/ | |||
| 3680 | gboolean | |||
| 3681 | ctk_window_get_skip_taskbar_hint (CtkWindow *window) | |||
| 3682 | { | |||
| 3683 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3684 | ||||
| 3685 | return window->priv->skips_taskbar; | |||
| 3686 | } | |||
| 3687 | ||||
| 3688 | /** | |||
| 3689 | * ctk_window_set_skip_pager_hint: | |||
| 3690 | * @window: a #CtkWindow | |||
| 3691 | * @setting: %TRUE to keep this window from appearing in the pager | |||
| 3692 | * | |||
| 3693 | * Windows may set a hint asking the desktop environment not to display | |||
| 3694 | * the window in the pager. This function sets this hint. | |||
| 3695 | * (A "pager" is any desktop navigation tool such as a workspace | |||
| 3696 | * switcher that displays a thumbnail representation of the windows | |||
| 3697 | * on the screen.) | |||
| 3698 | * | |||
| 3699 | * Since: 2.2 | |||
| 3700 | **/ | |||
| 3701 | void | |||
| 3702 | ctk_window_set_skip_pager_hint (CtkWindow *window, | |||
| 3703 | gboolean setting) | |||
| 3704 | { | |||
| 3705 | CtkWindowPrivate *priv; | |||
| 3706 | ||||
| 3707 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3708 | ||||
| 3709 | priv = window->priv; | |||
| 3710 | ||||
| 3711 | setting = setting != FALSE(0); | |||
| 3712 | ||||
| 3713 | if (priv->skips_pager != setting) | |||
| 3714 | { | |||
| 3715 | priv->skips_pager = setting; | |||
| 3716 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 3717 | cdk_window_set_skip_pager_hint (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 3718 | priv->skips_pager); | |||
| 3719 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_SKIP_PAGER_HINT]); | |||
| 3720 | } | |||
| 3721 | } | |||
| 3722 | ||||
| 3723 | /** | |||
| 3724 | * ctk_window_get_skip_pager_hint: | |||
| 3725 | * @window: a #CtkWindow | |||
| 3726 | * | |||
| 3727 | * Gets the value set by ctk_window_set_skip_pager_hint(). | |||
| 3728 | * | |||
| 3729 | * Returns: %TRUE if window shouldn’t be in pager | |||
| 3730 | * | |||
| 3731 | * Since: 2.2 | |||
| 3732 | **/ | |||
| 3733 | gboolean | |||
| 3734 | ctk_window_get_skip_pager_hint (CtkWindow *window) | |||
| 3735 | { | |||
| 3736 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3737 | ||||
| 3738 | return window->priv->skips_pager; | |||
| 3739 | } | |||
| 3740 | ||||
| 3741 | /** | |||
| 3742 | * ctk_window_set_urgency_hint: | |||
| 3743 | * @window: a #CtkWindow | |||
| 3744 | * @setting: %TRUE to mark this window as urgent | |||
| 3745 | * | |||
| 3746 | * Windows may set a hint asking the desktop environment to draw | |||
| 3747 | * the users attention to the window. This function sets this hint. | |||
| 3748 | * | |||
| 3749 | * Since: 2.8 | |||
| 3750 | **/ | |||
| 3751 | void | |||
| 3752 | ctk_window_set_urgency_hint (CtkWindow *window, | |||
| 3753 | gboolean setting) | |||
| 3754 | { | |||
| 3755 | CtkWindowPrivate *priv; | |||
| 3756 | ||||
| 3757 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3758 | ||||
| 3759 | priv = window->priv; | |||
| 3760 | ||||
| 3761 | setting = setting != FALSE(0); | |||
| 3762 | ||||
| 3763 | if (priv->urgent != setting) | |||
| 3764 | { | |||
| 3765 | priv->urgent = setting; | |||
| 3766 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 3767 | cdk_window_set_urgency_hint (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 3768 | priv->urgent); | |||
| 3769 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_URGENCY_HINT]); | |||
| 3770 | } | |||
| 3771 | } | |||
| 3772 | ||||
| 3773 | /** | |||
| 3774 | * ctk_window_get_urgency_hint: | |||
| 3775 | * @window: a #CtkWindow | |||
| 3776 | * | |||
| 3777 | * Gets the value set by ctk_window_set_urgency_hint() | |||
| 3778 | * | |||
| 3779 | * Returns: %TRUE if window is urgent | |||
| 3780 | * | |||
| 3781 | * Since: 2.8 | |||
| 3782 | **/ | |||
| 3783 | gboolean | |||
| 3784 | ctk_window_get_urgency_hint (CtkWindow *window) | |||
| 3785 | { | |||
| 3786 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3787 | ||||
| 3788 | return window->priv->urgent; | |||
| 3789 | } | |||
| 3790 | ||||
| 3791 | /** | |||
| 3792 | * ctk_window_set_accept_focus: | |||
| 3793 | * @window: a #CtkWindow | |||
| 3794 | * @setting: %TRUE to let this window receive input focus | |||
| 3795 | * | |||
| 3796 | * Windows may set a hint asking the desktop environment not to receive | |||
| 3797 | * the input focus. This function sets this hint. | |||
| 3798 | * | |||
| 3799 | * Since: 2.4 | |||
| 3800 | **/ | |||
| 3801 | void | |||
| 3802 | ctk_window_set_accept_focus (CtkWindow *window, | |||
| 3803 | gboolean setting) | |||
| 3804 | { | |||
| 3805 | CtkWindowPrivate *priv; | |||
| 3806 | ||||
| 3807 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3808 | ||||
| 3809 | priv = window->priv; | |||
| 3810 | ||||
| 3811 | setting = setting != FALSE(0); | |||
| 3812 | ||||
| 3813 | if (priv->accept_focus != setting) | |||
| 3814 | { | |||
| 3815 | priv->accept_focus = setting; | |||
| 3816 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 3817 | cdk_window_set_accept_focus (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 3818 | priv->accept_focus); | |||
| 3819 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_ACCEPT_FOCUS]); | |||
| 3820 | } | |||
| 3821 | } | |||
| 3822 | ||||
| 3823 | /** | |||
| 3824 | * ctk_window_get_accept_focus: | |||
| 3825 | * @window: a #CtkWindow | |||
| 3826 | * | |||
| 3827 | * Gets the value set by ctk_window_set_accept_focus(). | |||
| 3828 | * | |||
| 3829 | * Returns: %TRUE if window should receive the input focus | |||
| 3830 | * | |||
| 3831 | * Since: 2.4 | |||
| 3832 | **/ | |||
| 3833 | gboolean | |||
| 3834 | ctk_window_get_accept_focus (CtkWindow *window) | |||
| 3835 | { | |||
| 3836 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3837 | ||||
| 3838 | return window->priv->accept_focus; | |||
| 3839 | } | |||
| 3840 | ||||
| 3841 | /** | |||
| 3842 | * ctk_window_set_focus_on_map: | |||
| 3843 | * @window: a #CtkWindow | |||
| 3844 | * @setting: %TRUE to let this window receive input focus on map | |||
| 3845 | * | |||
| 3846 | * Windows may set a hint asking the desktop environment not to receive | |||
| 3847 | * the input focus when the window is mapped. This function sets this | |||
| 3848 | * hint. | |||
| 3849 | * | |||
| 3850 | * Since: 2.6 | |||
| 3851 | **/ | |||
| 3852 | void | |||
| 3853 | ctk_window_set_focus_on_map (CtkWindow *window, | |||
| 3854 | gboolean setting) | |||
| 3855 | { | |||
| 3856 | CtkWindowPrivate *priv; | |||
| 3857 | ||||
| 3858 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3859 | ||||
| 3860 | priv = window->priv; | |||
| 3861 | ||||
| 3862 | setting = setting != FALSE(0); | |||
| 3863 | ||||
| 3864 | if (priv->focus_on_map != setting) | |||
| 3865 | { | |||
| 3866 | priv->focus_on_map = setting; | |||
| 3867 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 3868 | cdk_window_set_focus_on_map (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 3869 | priv->focus_on_map); | |||
| 3870 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_FOCUS_ON_MAP]); | |||
| 3871 | } | |||
| 3872 | } | |||
| 3873 | ||||
| 3874 | /** | |||
| 3875 | * ctk_window_get_focus_on_map: | |||
| 3876 | * @window: a #CtkWindow | |||
| 3877 | * | |||
| 3878 | * Gets the value set by ctk_window_set_focus_on_map(). | |||
| 3879 | * | |||
| 3880 | * Returns: %TRUE if window should receive the input focus when | |||
| 3881 | * mapped. | |||
| 3882 | * | |||
| 3883 | * Since: 2.6 | |||
| 3884 | **/ | |||
| 3885 | gboolean | |||
| 3886 | ctk_window_get_focus_on_map (CtkWindow *window) | |||
| 3887 | { | |||
| 3888 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3889 | ||||
| 3890 | return window->priv->focus_on_map; | |||
| 3891 | } | |||
| 3892 | ||||
| 3893 | /** | |||
| 3894 | * ctk_window_set_destroy_with_parent: | |||
| 3895 | * @window: a #CtkWindow | |||
| 3896 | * @setting: whether to destroy @window with its transient parent | |||
| 3897 | * | |||
| 3898 | * If @setting is %TRUE, then destroying the transient parent of @window | |||
| 3899 | * will also destroy @window itself. This is useful for dialogs that | |||
| 3900 | * shouldn’t persist beyond the lifetime of the main window they're | |||
| 3901 | * associated with, for example. | |||
| 3902 | **/ | |||
| 3903 | void | |||
| 3904 | ctk_window_set_destroy_with_parent (CtkWindow *window, | |||
| 3905 | gboolean setting) | |||
| 3906 | { | |||
| 3907 | CtkWindowPrivate *priv; | |||
| 3908 | ||||
| 3909 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3910 | ||||
| 3911 | priv = window->priv; | |||
| 3912 | ||||
| 3913 | if (priv->destroy_with_parent == (setting != FALSE(0))) | |||
| 3914 | return; | |||
| 3915 | ||||
| 3916 | if (priv->destroy_with_parent) | |||
| 3917 | { | |||
| 3918 | disconnect_parent_destroyed (window); | |||
| 3919 | } | |||
| 3920 | else | |||
| 3921 | { | |||
| 3922 | connect_parent_destroyed (window); | |||
| 3923 | } | |||
| 3924 | ||||
| 3925 | priv->destroy_with_parent = setting; | |||
| 3926 | ||||
| 3927 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_DESTROY_WITH_PARENT]); | |||
| 3928 | } | |||
| 3929 | ||||
| 3930 | /** | |||
| 3931 | * ctk_window_get_destroy_with_parent: | |||
| 3932 | * @window: a #CtkWindow | |||
| 3933 | * | |||
| 3934 | * Returns whether the window will be destroyed with its transient parent. See | |||
| 3935 | * ctk_window_set_destroy_with_parent (). | |||
| 3936 | * | |||
| 3937 | * Returns: %TRUE if the window will be destroyed with its transient parent. | |||
| 3938 | **/ | |||
| 3939 | gboolean | |||
| 3940 | ctk_window_get_destroy_with_parent (CtkWindow *window) | |||
| 3941 | { | |||
| 3942 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 3943 | ||||
| 3944 | return window->priv->destroy_with_parent; | |||
| 3945 | } | |||
| 3946 | ||||
| 3947 | static void | |||
| 3948 | ctk_window_apply_hide_titlebar_when_maximized (CtkWindow *window) | |||
| 3949 | { | |||
| 3950 | #ifdef CDK_WINDOWING_X11 | |||
| 3951 | CdkWindow *cdk_window; | |||
| 3952 | gboolean setting; | |||
| 3953 | ||||
| 3954 | setting = window->priv->hide_titlebar_when_maximized; | |||
| 3955 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 3956 | ||||
| 3957 | if (CDK_IS_X11_WINDOW (cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_x11_window_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; }))))) | |||
| 3958 | cdk_x11_window_set_hide_titlebar_when_maximized (cdk_window, setting); | |||
| 3959 | #endif | |||
| 3960 | } | |||
| 3961 | ||||
| 3962 | /** | |||
| 3963 | * ctk_window_set_hide_titlebar_when_maximized: | |||
| 3964 | * @window: a #CtkWindow | |||
| 3965 | * @setting: whether to hide the titlebar when @window is maximized | |||
| 3966 | * | |||
| 3967 | * If @setting is %TRUE, then @window will request that it’s titlebar | |||
| 3968 | * should be hidden when maximized. | |||
| 3969 | * This is useful for windows that don’t convey any information other | |||
| 3970 | * than the application name in the titlebar, to put the available | |||
| 3971 | * screen space to better use. If the underlying window system does not | |||
| 3972 | * support the request, the setting will not have any effect. | |||
| 3973 | * | |||
| 3974 | * Note that custom titlebars set with ctk_window_set_titlebar() are | |||
| 3975 | * not affected by this. The application is in full control of their | |||
| 3976 | * content and visibility anyway. | |||
| 3977 | * | |||
| 3978 | * Since: 3.4 | |||
| 3979 | **/ | |||
| 3980 | void | |||
| 3981 | ctk_window_set_hide_titlebar_when_maximized (CtkWindow *window, | |||
| 3982 | gboolean setting) | |||
| 3983 | { | |||
| 3984 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 3985 | ||||
| 3986 | if (window->priv->hide_titlebar_when_maximized == setting) | |||
| 3987 | return; | |||
| 3988 | ||||
| 3989 | window->priv->hide_titlebar_when_maximized = setting; | |||
| 3990 | ctk_window_apply_hide_titlebar_when_maximized (window); | |||
| 3991 | ||||
| 3992 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_HIDE_TITLEBAR_WHEN_MAXIMIZED]); | |||
| 3993 | } | |||
| 3994 | ||||
| 3995 | /** | |||
| 3996 | * ctk_window_get_hide_titlebar_when_maximized: | |||
| 3997 | * @window: a #CtkWindow | |||
| 3998 | * | |||
| 3999 | * Returns whether the window has requested to have its titlebar hidden | |||
| 4000 | * when maximized. See ctk_window_set_hide_titlebar_when_maximized (). | |||
| 4001 | * | |||
| 4002 | * Returns: %TRUE if the window has requested to have its titlebar | |||
| 4003 | * hidden when maximized | |||
| 4004 | * | |||
| 4005 | * Since: 3.4 | |||
| 4006 | **/ | |||
| 4007 | gboolean | |||
| 4008 | ctk_window_get_hide_titlebar_when_maximized (CtkWindow *window) | |||
| 4009 | { | |||
| 4010 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 4011 | ||||
| 4012 | return window->priv->hide_titlebar_when_maximized; | |||
| 4013 | } | |||
| 4014 | ||||
| 4015 | static CtkWindowGeometryInfo* | |||
| 4016 | ctk_window_get_geometry_info (CtkWindow *window, | |||
| 4017 | gboolean create) | |||
| 4018 | { | |||
| 4019 | CtkWindowPrivate *priv = window->priv; | |||
| 4020 | CtkWindowGeometryInfo *info; | |||
| 4021 | ||||
| 4022 | info = priv->geometry_info; | |||
| 4023 | if (!info && create) | |||
| 4024 | { | |||
| 4025 | info = g_new0 (CtkWindowGeometryInfo, 1)((CtkWindowGeometryInfo *) g_malloc0_n ((1), sizeof (CtkWindowGeometryInfo ))); | |||
| 4026 | ||||
| 4027 | info->default_width = -1; | |||
| 4028 | info->default_height = -1; | |||
| 4029 | info->resize_width = -1; | |||
| 4030 | info->resize_height = -1; | |||
| 4031 | info->initial_x = 0; | |||
| 4032 | info->initial_y = 0; | |||
| 4033 | info->initial_pos_set = FALSE(0); | |||
| 4034 | info->default_is_geometry = FALSE(0); | |||
| 4035 | info->position_constraints_changed = FALSE(0); | |||
| 4036 | info->last.configure_request.x = 0; | |||
| 4037 | info->last.configure_request.y = 0; | |||
| 4038 | info->last.configure_request.width = -1; | |||
| 4039 | info->last.configure_request.height = -1; | |||
| 4040 | info->mask = 0; | |||
| 4041 | priv->geometry_info = info; | |||
| 4042 | } | |||
| 4043 | ||||
| 4044 | return info; | |||
| 4045 | } | |||
| 4046 | ||||
| 4047 | /** | |||
| 4048 | * ctk_window_set_geometry_hints: | |||
| 4049 | * @window: a #CtkWindow | |||
| 4050 | * @geometry_widget: (allow-none): widget the geometry hints used to be applied to | |||
| 4051 | * or %NULL. Since 3.20 this argument is ignored and CTK behaves as if %NULL was | |||
| 4052 | * set. | |||
| 4053 | * @geometry: (allow-none): struct containing geometry information or %NULL | |||
| 4054 | * @geom_mask: mask indicating which struct fields should be paid attention to | |||
| 4055 | * | |||
| 4056 | * This function sets up hints about how a window can be resized by | |||
| 4057 | * the user. You can set a minimum and maximum size; allowed resize | |||
| 4058 | * increments (e.g. for xterm, you can only resize by the size of a | |||
| 4059 | * character); aspect ratios; and more. See the #CdkGeometry struct. | |||
| 4060 | */ | |||
| 4061 | void | |||
| 4062 | ctk_window_set_geometry_hints (CtkWindow *window, | |||
| 4063 | CtkWidget *geometry_widget, | |||
| 4064 | CdkGeometry *geometry, | |||
| 4065 | CdkWindowHints geom_mask) | |||
| 4066 | { | |||
| 4067 | CtkWindowGeometryInfo *info; | |||
| 4068 | ||||
| 4069 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4070 | g_return_if_fail (geometry_widget == NULL || CTK_IS_WIDGET (geometry_widget))do { if ((geometry_widget == ((void*)0) || (((__extension__ ( { GTypeInstance *_inst = (GTypeInstance*) ((geometry_widget)) ; 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 ("Ctk", ((const char*) (__func__)), "geometry_widget == NULL || CTK_IS_WIDGET (geometry_widget)" ); return; } } while (0); | |||
| 4071 | ||||
| 4072 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 4073 | ||||
| 4074 | if (geometry) | |||
| 4075 | info->geometry = *geometry; | |||
| 4076 | ||||
| 4077 | /* We store gravity in priv->gravity not in the hints. */ | |||
| 4078 | info->mask = geom_mask & ~(CDK_HINT_WIN_GRAVITY); | |||
| 4079 | ||||
| 4080 | if (geometry_widget) | |||
| 4081 | info->mask &= ~(CDK_HINT_BASE_SIZE | CDK_HINT_RESIZE_INC); | |||
| 4082 | ||||
| 4083 | if (geom_mask & CDK_HINT_WIN_GRAVITY) | |||
| 4084 | ctk_window_set_gravity (window, geometry->win_gravity); | |||
| 4085 | ||||
| 4086 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 4087 | } | |||
| 4088 | ||||
| 4089 | static void | |||
| 4090 | unset_titlebar (CtkWindow *window) | |||
| 4091 | { | |||
| 4092 | CtkWindowPrivate *priv = window->priv; | |||
| 4093 | ||||
| 4094 | if (priv->title_box != NULL((void*)0)) | |||
| 4095 | { | |||
| 4096 | g_signal_handlers_disconnect_by_func (priv->title_box,g_signal_handlers_disconnect_matched ((priv->title_box), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (on_titlebar_title_notify), (window)) | |||
| 4097 | on_titlebar_title_notify,g_signal_handlers_disconnect_matched ((priv->title_box), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (on_titlebar_title_notify), (window)) | |||
| 4098 | window)g_signal_handlers_disconnect_matched ((priv->title_box), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (on_titlebar_title_notify), (window)); | |||
| 4099 | ctk_widget_unparent (priv->title_box); | |||
| 4100 | priv->title_box = NULL((void*)0); | |||
| 4101 | priv->titlebar = NULL((void*)0); | |||
| 4102 | } | |||
| 4103 | } | |||
| 4104 | ||||
| 4105 | static gboolean | |||
| 4106 | ctk_window_supports_client_shadow (CtkWindow *window) | |||
| 4107 | { | |||
| 4108 | CdkDisplay *display; | |||
| 4109 | CdkScreen *screen; | |||
| 4110 | CdkVisual *visual; | |||
| 4111 | ||||
| 4112 | screen = _ctk_window_get_screen (window); | |||
| 4113 | display = cdk_screen_get_display (screen); | |||
| 4114 | ||||
| 4115 | #ifdef CDK_WINDOWING_X11 | |||
| 4116 | if (CDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (display)); GType _t = ((cdk_x11_display_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; }))))) | |||
| 4117 | { | |||
| 4118 | if (!cdk_screen_is_composited (screen)) | |||
| 4119 | return FALSE(0); | |||
| 4120 | ||||
| 4121 | if (!cdk_x11_screen_supports_net_wm_hint (screen, cdk_atom_intern_static_string ("_CTK_FRAME_EXTENTS"))) | |||
| 4122 | return FALSE(0); | |||
| 4123 | ||||
| 4124 | /* We need a visual with alpha */ | |||
| 4125 | visual = cdk_screen_get_rgba_visual (screen); | |||
| 4126 | if (!visual) | |||
| 4127 | return FALSE(0); | |||
| 4128 | } | |||
| 4129 | #endif | |||
| 4130 | ||||
| 4131 | #ifdef CDK_WINDOWING_WIN32 | |||
| 4132 | if (CDK_IS_WIN32_DISPLAY (display)) | |||
| 4133 | { | |||
| 4134 | if (!cdk_screen_is_composited (screen)) | |||
| 4135 | return FALSE(0); | |||
| 4136 | ||||
| 4137 | /* We need a visual with alpha */ | |||
| 4138 | visual = cdk_screen_get_rgba_visual (screen); | |||
| 4139 | if (!visual) | |||
| 4140 | return FALSE(0); | |||
| 4141 | } | |||
| 4142 | #endif | |||
| 4143 | ||||
| 4144 | return TRUE(!(0)); | |||
| 4145 | } | |||
| 4146 | ||||
| 4147 | static void | |||
| 4148 | ctk_window_enable_csd (CtkWindow *window) | |||
| 4149 | { | |||
| 4150 | CtkWindowPrivate *priv = window->priv; | |||
| 4151 | CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 4152 | CdkVisual *visual; | |||
| 4153 | ||||
| 4154 | /* We need a visual with alpha for client shadows */ | |||
| 4155 | if (priv->use_client_shadow) | |||
| 4156 | { | |||
| 4157 | visual = cdk_screen_get_rgba_visual (ctk_widget_get_screen (widget)); | |||
| 4158 | if (visual != NULL((void*)0)) | |||
| 4159 | ctk_widget_set_visual (widget, visual); | |||
| 4160 | ||||
| 4161 | ctk_style_context_add_class (ctk_widget_get_style_context (widget), CTK_STYLE_CLASS_CSD"csd"); | |||
| 4162 | } | |||
| 4163 | else | |||
| 4164 | { | |||
| 4165 | ctk_style_context_add_class (ctk_widget_get_style_context (widget), "solid-csd"); | |||
| 4166 | } | |||
| 4167 | ||||
| 4168 | priv->client_decorated = TRUE(!(0)); | |||
| 4169 | } | |||
| 4170 | ||||
| 4171 | static void | |||
| 4172 | on_titlebar_title_notify (CtkHeaderBar *titlebar, | |||
| 4173 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 4174 | CtkWindow *self) | |||
| 4175 | { | |||
| 4176 | const gchar *title; | |||
| 4177 | ||||
| 4178 | title = ctk_header_bar_get_title (titlebar); | |||
| 4179 | ctk_window_set_title_internal (self, title, FALSE(0)); | |||
| 4180 | } | |||
| 4181 | ||||
| 4182 | /** | |||
| 4183 | * ctk_window_set_titlebar: | |||
| 4184 | * @window: a #CtkWindow | |||
| 4185 | * @titlebar: (allow-none): the widget to use as titlebar | |||
| 4186 | * | |||
| 4187 | * Sets a custom titlebar for @window. | |||
| 4188 | * | |||
| 4189 | * A typical widget used here is #CtkHeaderBar, as it provides various features | |||
| 4190 | * expected of a titlebar while allowing the addition of child widgets to it. | |||
| 4191 | * | |||
| 4192 | * If you set a custom titlebar, CTK+ will do its best to convince | |||
| 4193 | * the window manager not to put its own titlebar on the window. | |||
| 4194 | * Depending on the system, this function may not work for a window | |||
| 4195 | * that is already visible, so you set the titlebar before calling | |||
| 4196 | * ctk_widget_show(). | |||
| 4197 | * | |||
| 4198 | * Since: 3.10 | |||
| 4199 | */ | |||
| 4200 | void | |||
| 4201 | ctk_window_set_titlebar (CtkWindow *window, | |||
| 4202 | CtkWidget *titlebar) | |||
| 4203 | { | |||
| 4204 | CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 4205 | CtkWindowPrivate *priv = window->priv; | |||
| 4206 | gboolean was_mapped; | |||
| 4207 | ||||
| 4208 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4209 | ||||
| 4210 | if ((!priv->title_box && titlebar) || (priv->title_box && !titlebar)) | |||
| 4211 | { | |||
| 4212 | was_mapped = _ctk_widget_get_mapped (widget); | |||
| 4213 | if (_ctk_widget_get_realized (widget)) | |||
| 4214 | { | |||
| 4215 | g_warning ("ctk_window_set_titlebar() called on a realized window"); | |||
| 4216 | ctk_widget_unrealize (widget); | |||
| 4217 | } | |||
| 4218 | } | |||
| 4219 | else | |||
| 4220 | was_mapped = FALSE(0); | |||
| 4221 | ||||
| 4222 | unset_titlebar (window); | |||
| 4223 | ||||
| 4224 | if (titlebar == NULL((void*)0)) | |||
| 4225 | { | |||
| 4226 | priv->client_decorated = FALSE(0); | |||
| 4227 | ctk_style_context_remove_class (ctk_widget_get_style_context (widget), CTK_STYLE_CLASS_CSD"csd"); | |||
| 4228 | ||||
| 4229 | goto out; | |||
| 4230 | } | |||
| 4231 | ||||
| 4232 | priv->use_client_shadow = ctk_window_supports_client_shadow (window); | |||
| 4233 | ||||
| 4234 | ctk_window_enable_csd (window); | |||
| 4235 | priv->title_box = titlebar; | |||
| 4236 | ctk_widget_set_parent (priv->title_box, widget); | |||
| 4237 | if (CTK_IS_HEADER_BAR (titlebar)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (titlebar)); GType _t = ((ctk_header_bar_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; }))))) | |||
| 4238 | { | |||
| 4239 | g_signal_connect (titlebar, "notify::title",g_signal_connect_data ((titlebar), ("notify::title"), (((GCallback ) (on_titlebar_title_notify))), (window), ((void*)0), (GConnectFlags ) 0) | |||
| 4240 | G_CALLBACK (on_titlebar_title_notify), window)g_signal_connect_data ((titlebar), ("notify::title"), (((GCallback ) (on_titlebar_title_notify))), (window), ((void*)0), (GConnectFlags ) 0); | |||
| 4241 | on_titlebar_title_notify (CTK_HEADER_BAR (titlebar)((((CtkHeaderBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((titlebar)), ((ctk_header_bar_get_type ())))))), NULL((void*)0), window); | |||
| 4242 | } | |||
| 4243 | ||||
| 4244 | ctk_style_context_add_class (ctk_widget_get_style_context (titlebar), | |||
| 4245 | CTK_STYLE_CLASS_TITLEBAR"titlebar"); | |||
| 4246 | ||||
| 4247 | out: | |||
| 4248 | if (was_mapped) | |||
| 4249 | ctk_widget_map (widget); | |||
| 4250 | } | |||
| 4251 | ||||
| 4252 | /** | |||
| 4253 | * ctk_window_get_titlebar: | |||
| 4254 | * @window: a #CtkWindow | |||
| 4255 | * | |||
| 4256 | * Returns the custom titlebar that has been set with | |||
| 4257 | * ctk_window_set_titlebar(). | |||
| 4258 | * | |||
| 4259 | * Returns: (nullable) (transfer none): the custom titlebar, or %NULL | |||
| 4260 | * | |||
| 4261 | * Since: 3.16 | |||
| 4262 | */ | |||
| 4263 | CtkWidget * | |||
| 4264 | ctk_window_get_titlebar (CtkWindow *window) | |||
| 4265 | { | |||
| 4266 | CtkWindowPrivate *priv = window->priv; | |||
| 4267 | ||||
| 4268 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 4269 | ||||
| 4270 | /* Don't return the internal titlebar */ | |||
| 4271 | if (priv->title_box == priv->titlebar) | |||
| 4272 | return NULL((void*)0); | |||
| 4273 | ||||
| 4274 | return priv->title_box; | |||
| 4275 | } | |||
| 4276 | ||||
| 4277 | gboolean | |||
| 4278 | _ctk_window_titlebar_shows_app_menu (CtkWindow *window) | |||
| 4279 | { | |||
| 4280 | CtkWindowPrivate *priv = window->priv; | |||
| 4281 | ||||
| 4282 | if (CTK_IS_HEADER_BAR (priv->title_box)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (priv->title_box)); GType _t = ((ctk_header_bar_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; }))))) | |||
| 4283 | return _ctk_header_bar_shows_app_menu (CTK_HEADER_BAR (priv->title_box)((((CtkHeaderBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->title_box)), ((ctk_header_bar_get_type ()))))))); | |||
| 4284 | ||||
| 4285 | return FALSE(0); | |||
| 4286 | } | |||
| 4287 | ||||
| 4288 | /** | |||
| 4289 | * ctk_window_set_decorated: | |||
| 4290 | * @window: a #CtkWindow | |||
| 4291 | * @setting: %TRUE to decorate the window | |||
| 4292 | * | |||
| 4293 | * By default, windows are decorated with a title bar, resize | |||
| 4294 | * controls, etc. Some [window managers][ctk-X11-arch] | |||
| 4295 | * allow CTK+ to disable these decorations, creating a | |||
| 4296 | * borderless window. If you set the decorated property to %FALSE | |||
| 4297 | * using this function, CTK+ will do its best to convince the window | |||
| 4298 | * manager not to decorate the window. Depending on the system, this | |||
| 4299 | * function may not have any effect when called on a window that is | |||
| 4300 | * already visible, so you should call it before calling ctk_widget_show(). | |||
| 4301 | * | |||
| 4302 | * On Windows, this function always works, since there’s no window manager | |||
| 4303 | * policy involved. | |||
| 4304 | * | |||
| 4305 | **/ | |||
| 4306 | void | |||
| 4307 | ctk_window_set_decorated (CtkWindow *window, | |||
| 4308 | gboolean setting) | |||
| 4309 | { | |||
| 4310 | CtkWindowPrivate *priv; | |||
| 4311 | CdkWindow *cdk_window; | |||
| 4312 | ||||
| 4313 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4314 | ||||
| 4315 | priv = window->priv; | |||
| 4316 | ||||
| 4317 | setting = setting != FALSE(0); | |||
| 4318 | ||||
| 4319 | if (setting == priv->decorated) | |||
| 4320 | return; | |||
| 4321 | ||||
| 4322 | priv->decorated = setting; | |||
| 4323 | ||||
| 4324 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 4325 | if (cdk_window) | |||
| 4326 | { | |||
| 4327 | if (priv->decorated) | |||
| 4328 | { | |||
| 4329 | if (priv->client_decorated) | |||
| 4330 | cdk_window_set_decorations (cdk_window, 0); | |||
| 4331 | else | |||
| 4332 | cdk_window_set_decorations (cdk_window, CDK_DECOR_ALL); | |||
| 4333 | } | |||
| 4334 | else | |||
| 4335 | cdk_window_set_decorations (cdk_window, 0); | |||
| 4336 | } | |||
| 4337 | ||||
| 4338 | update_window_buttons (window); | |||
| 4339 | ctk_widget_queue_resize (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 4340 | ||||
| 4341 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_DECORATED]); | |||
| 4342 | } | |||
| 4343 | ||||
| 4344 | /** | |||
| 4345 | * ctk_window_get_decorated: | |||
| 4346 | * @window: a #CtkWindow | |||
| 4347 | * | |||
| 4348 | * Returns whether the window has been set to have decorations | |||
| 4349 | * such as a title bar via ctk_window_set_decorated(). | |||
| 4350 | * | |||
| 4351 | * Returns: %TRUE if the window has been set to have decorations | |||
| 4352 | **/ | |||
| 4353 | gboolean | |||
| 4354 | ctk_window_get_decorated (CtkWindow *window) | |||
| 4355 | { | |||
| 4356 | g_return_val_if_fail (CTK_IS_WINDOW (window), TRUE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((!(0))); } } while (0); | |||
| 4357 | ||||
| 4358 | return window->priv->decorated; | |||
| 4359 | } | |||
| 4360 | ||||
| 4361 | /** | |||
| 4362 | * ctk_window_set_deletable: | |||
| 4363 | * @window: a #CtkWindow | |||
| 4364 | * @setting: %TRUE to decorate the window as deletable | |||
| 4365 | * | |||
| 4366 | * By default, windows have a close button in the window frame. Some | |||
| 4367 | * [window managers][ctk-X11-arch] allow CTK+ to | |||
| 4368 | * disable this button. If you set the deletable property to %FALSE | |||
| 4369 | * using this function, CTK+ will do its best to convince the window | |||
| 4370 | * manager not to show a close button. Depending on the system, this | |||
| 4371 | * function may not have any effect when called on a window that is | |||
| 4372 | * already visible, so you should call it before calling ctk_widget_show(). | |||
| 4373 | * | |||
| 4374 | * On Windows, this function always works, since there’s no window manager | |||
| 4375 | * policy involved. | |||
| 4376 | * | |||
| 4377 | * Since: 2.10 | |||
| 4378 | */ | |||
| 4379 | void | |||
| 4380 | ctk_window_set_deletable (CtkWindow *window, | |||
| 4381 | gboolean setting) | |||
| 4382 | { | |||
| 4383 | CtkWindowPrivate *priv; | |||
| 4384 | CdkWindow *cdk_window; | |||
| 4385 | ||||
| 4386 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4387 | ||||
| 4388 | priv = window->priv; | |||
| 4389 | ||||
| 4390 | setting = setting != FALSE(0); | |||
| 4391 | ||||
| 4392 | if (setting == priv->deletable) | |||
| 4393 | return; | |||
| 4394 | ||||
| 4395 | priv->deletable = setting; | |||
| 4396 | ||||
| 4397 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 4398 | if (cdk_window) | |||
| 4399 | { | |||
| 4400 | if (priv->deletable) | |||
| 4401 | cdk_window_set_functions (cdk_window, | |||
| 4402 | CDK_FUNC_ALL); | |||
| 4403 | else | |||
| 4404 | cdk_window_set_functions (cdk_window, | |||
| 4405 | CDK_FUNC_ALL | CDK_FUNC_CLOSE); | |||
| 4406 | } | |||
| 4407 | ||||
| 4408 | update_window_buttons (window); | |||
| 4409 | ||||
| 4410 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_DELETABLE]); | |||
| 4411 | } | |||
| 4412 | ||||
| 4413 | /** | |||
| 4414 | * ctk_window_get_deletable: | |||
| 4415 | * @window: a #CtkWindow | |||
| 4416 | * | |||
| 4417 | * Returns whether the window has been set to have a close button | |||
| 4418 | * via ctk_window_set_deletable(). | |||
| 4419 | * | |||
| 4420 | * Returns: %TRUE if the window has been set to have a close button | |||
| 4421 | * | |||
| 4422 | * Since: 2.10 | |||
| 4423 | **/ | |||
| 4424 | gboolean | |||
| 4425 | ctk_window_get_deletable (CtkWindow *window) | |||
| 4426 | { | |||
| 4427 | g_return_val_if_fail (CTK_IS_WINDOW (window), TRUE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((!(0))); } } while (0); | |||
| 4428 | ||||
| 4429 | return window->priv->deletable; | |||
| 4430 | } | |||
| 4431 | ||||
| 4432 | static CtkWindowIconInfo* | |||
| 4433 | get_icon_info (CtkWindow *window) | |||
| 4434 | { | |||
| 4435 | return g_object_get_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), quark_ctk_window_icon_info); | |||
| 4436 | } | |||
| 4437 | ||||
| 4438 | static void | |||
| 4439 | free_icon_info (CtkWindowIconInfo *info) | |||
| 4440 | { | |||
| 4441 | g_free (info->icon_name)(__builtin_object_size ((info->icon_name), 0) != ((size_t) - 1)) ? g_free_sized (info->icon_name, __builtin_object_size ((info->icon_name), 0)) : (g_free) (info->icon_name); | |||
| 4442 | g_slice_free (CtkWindowIconInfo, info)do { if (1) g_slice_free1 (sizeof (CtkWindowIconInfo), (info) ); else (void) ((CtkWindowIconInfo*) 0 == (info)); } while (0 ); | |||
| 4443 | } | |||
| 4444 | ||||
| 4445 | ||||
| 4446 | static CtkWindowIconInfo* | |||
| 4447 | ensure_icon_info (CtkWindow *window) | |||
| 4448 | { | |||
| 4449 | CtkWindowIconInfo *info; | |||
| 4450 | ||||
| 4451 | info = get_icon_info (window); | |||
| 4452 | ||||
| 4453 | if (info == NULL((void*)0)) | |||
| 4454 | { | |||
| 4455 | info = g_slice_new0 (CtkWindowIconInfo)((CtkWindowIconInfo*) g_slice_alloc0 ((sizeof (CtkWindowIconInfo ) > 0 ? sizeof (CtkWindowIconInfo) : 1))); | |||
| 4456 | g_object_set_qdata_full (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), | |||
| 4457 | quark_ctk_window_icon_info, | |||
| 4458 | info, | |||
| 4459 | (GDestroyNotify)free_icon_info); | |||
| 4460 | } | |||
| 4461 | ||||
| 4462 | return info; | |||
| 4463 | } | |||
| 4464 | ||||
| 4465 | static GList * | |||
| 4466 | icon_list_from_theme (CtkWindow *window, | |||
| 4467 | const gchar *name) | |||
| 4468 | { | |||
| 4469 | GList *list; | |||
| 4470 | ||||
| 4471 | CtkIconTheme *icon_theme; | |||
| 4472 | CdkPixbuf *icon; | |||
| 4473 | gint *sizes; | |||
| 4474 | gint i; | |||
| 4475 | ||||
| 4476 | icon_theme = ctk_css_icon_theme_value_get_icon_theme | |||
| 4477 | (_ctk_style_context_peek_property (ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 4478 | CTK_CSS_PROPERTY_ICON_THEME)); | |||
| 4479 | ||||
| 4480 | sizes = ctk_icon_theme_get_icon_sizes (icon_theme, name); | |||
| 4481 | ||||
| 4482 | list = NULL((void*)0); | |||
| 4483 | for (i = 0; sizes[i]; i++) | |||
| 4484 | { | |||
| 4485 | /* FIXME | |||
| 4486 | * We need an EWMH extension to handle scalable icons | |||
| 4487 | * by passing their name to the WM. For now just use a | |||
| 4488 | * fixed size of 48. | |||
| 4489 | */ | |||
| 4490 | if (sizes[i] == -1) | |||
| 4491 | icon = ctk_icon_theme_load_icon (icon_theme, name, | |||
| 4492 | 48, 0, NULL((void*)0)); | |||
| 4493 | else | |||
| 4494 | icon = ctk_icon_theme_load_icon (icon_theme, name, | |||
| 4495 | sizes[i], 0, NULL((void*)0)); | |||
| 4496 | if (icon) | |||
| 4497 | list = g_list_append (list, icon); | |||
| 4498 | } | |||
| 4499 | ||||
| 4500 | g_free (sizes)(__builtin_object_size ((sizes), 0) != ((size_t) - 1)) ? g_free_sized (sizes, __builtin_object_size ((sizes), 0)) : (g_free) (sizes ); | |||
| 4501 | ||||
| 4502 | return list; | |||
| 4503 | } | |||
| 4504 | ||||
| 4505 | static void | |||
| 4506 | ctk_window_realize_icon (CtkWindow *window) | |||
| 4507 | { | |||
| 4508 | CtkWindowPrivate *priv = window->priv; | |||
| 4509 | CtkWidget *widget; | |||
| 4510 | CtkWindowIconInfo *info; | |||
| 4511 | CdkWindow *cdk_window; | |||
| 4512 | GList *icon_list; | |||
| 4513 | ||||
| 4514 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 4515 | cdk_window = _ctk_widget_get_window (widget); | |||
| 4516 | ||||
| 4517 | g_return_if_fail (cdk_window != NULL)do { if ((cdk_window != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cdk_window != NULL"); return ; } } while (0); | |||
| 4518 | ||||
| 4519 | /* no point setting an icon on override-redirect */ | |||
| 4520 | if (priv->type == CTK_WINDOW_POPUP) | |||
| 4521 | return; | |||
| 4522 | ||||
| 4523 | icon_list = NULL((void*)0); | |||
| 4524 | ||||
| 4525 | info = ensure_icon_info (window); | |||
| 4526 | ||||
| 4527 | if (info->realized) | |||
| 4528 | return; | |||
| 4529 | ||||
| 4530 | info->using_default_icon = FALSE(0); | |||
| 4531 | info->using_parent_icon = FALSE(0); | |||
| 4532 | info->using_themed_icon = FALSE(0); | |||
| 4533 | ||||
| 4534 | icon_list = info->icon_list; | |||
| 4535 | ||||
| 4536 | /* Look up themed icon */ | |||
| 4537 | if (icon_list == NULL((void*)0) && info->icon_name) | |||
| 4538 | { | |||
| 4539 | icon_list = icon_list_from_theme (window, info->icon_name); | |||
| 4540 | if (icon_list) | |||
| 4541 | info->using_themed_icon = TRUE(!(0)); | |||
| 4542 | } | |||
| 4543 | ||||
| 4544 | /* Inherit from transient parent */ | |||
| 4545 | if (icon_list == NULL((void*)0) && priv->transient_parent) | |||
| 4546 | { | |||
| 4547 | icon_list = ensure_icon_info (priv->transient_parent)->icon_list; | |||
| 4548 | if (icon_list) | |||
| 4549 | info->using_parent_icon = TRUE(!(0)); | |||
| 4550 | } | |||
| 4551 | ||||
| 4552 | /* Inherit from default */ | |||
| 4553 | if (icon_list == NULL((void*)0)) | |||
| 4554 | { | |||
| 4555 | icon_list = default_icon_list; | |||
| 4556 | if (icon_list) | |||
| 4557 | info->using_default_icon = TRUE(!(0)); | |||
| 4558 | } | |||
| 4559 | ||||
| 4560 | /* Look up themed icon */ | |||
| 4561 | if (icon_list == NULL((void*)0) && default_icon_name) | |||
| 4562 | { | |||
| 4563 | icon_list = icon_list_from_theme (window, default_icon_name); | |||
| 4564 | info->using_default_icon = TRUE(!(0)); | |||
| 4565 | info->using_themed_icon = TRUE(!(0)); | |||
| 4566 | } | |||
| 4567 | ||||
| 4568 | info->realized = TRUE(!(0)); | |||
| 4569 | ||||
| 4570 | cdk_window_set_icon_list (cdk_window, icon_list); | |||
| 4571 | if (CTK_IS_HEADER_BAR (priv->title_box)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (priv->title_box)); GType _t = ((ctk_header_bar_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; }))))) | |||
| 4572 | _ctk_header_bar_update_window_icon (CTK_HEADER_BAR (priv->title_box)((((CtkHeaderBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->title_box)), ((ctk_header_bar_get_type ())))))), window); | |||
| 4573 | ||||
| 4574 | if (info->using_themed_icon) | |||
| 4575 | { | |||
| 4576 | g_list_free_full (icon_list, g_object_unref); | |||
| 4577 | } | |||
| 4578 | } | |||
| 4579 | ||||
| 4580 | static CdkPixbuf * | |||
| 4581 | icon_from_list (GList *list, | |||
| 4582 | gint size) | |||
| 4583 | { | |||
| 4584 | CdkPixbuf *best; | |||
| 4585 | CdkPixbuf *pixbuf; | |||
| 4586 | GList *l; | |||
| 4587 | ||||
| 4588 | best = NULL((void*)0); | |||
| 4589 | for (l = list; l; l = l->next) | |||
| 4590 | { | |||
| 4591 | pixbuf = list->data; | |||
| 4592 | if (cdk_pixbuf_get_width (pixbuf) <= size && | |||
| 4593 | cdk_pixbuf_get_height (pixbuf) <= size) | |||
| 4594 | { | |||
| 4595 | best = g_object_ref (pixbuf)((__typeof__ (pixbuf)) (g_object_ref) (pixbuf)); | |||
| 4596 | break; | |||
| 4597 | } | |||
| 4598 | } | |||
| 4599 | ||||
| 4600 | if (best == NULL((void*)0)) | |||
| 4601 | best = cdk_pixbuf_scale_simple (CDK_PIXBUF (list->data)((((CdkPixbuf*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list->data)), ((cdk_pixbuf_get_type ())))))), size, size, CDK_INTERP_BILINEAR); | |||
| 4602 | ||||
| 4603 | return best; | |||
| 4604 | } | |||
| 4605 | ||||
| 4606 | static CdkPixbuf * | |||
| 4607 | icon_from_name (const gchar *name, | |||
| 4608 | gint size) | |||
| 4609 | { | |||
| 4610 | return ctk_icon_theme_load_icon (ctk_icon_theme_get_default (), | |||
| 4611 | name, size, | |||
| 4612 | CTK_ICON_LOOKUP_FORCE_SIZE, NULL((void*)0)); | |||
| 4613 | } | |||
| 4614 | ||||
| 4615 | CdkPixbuf * | |||
| 4616 | ctk_window_get_icon_for_size (CtkWindow *window, | |||
| 4617 | gint size) | |||
| 4618 | { | |||
| 4619 | CtkWindowPrivate *priv = window->priv; | |||
| 4620 | CtkWindowIconInfo *info; | |||
| 4621 | const gchar *name; | |||
| 4622 | ||||
| 4623 | info = ensure_icon_info (window); | |||
| 4624 | ||||
| 4625 | if (info->icon_list != NULL((void*)0)) | |||
| 4626 | return icon_from_list (info->icon_list, size); | |||
| 4627 | ||||
| 4628 | name = ctk_window_get_icon_name (window); | |||
| 4629 | if (name != NULL((void*)0)) | |||
| 4630 | return icon_from_name (name, size); | |||
| 4631 | ||||
| 4632 | if (priv->transient_parent != NULL((void*)0)) | |||
| 4633 | { | |||
| 4634 | info = ensure_icon_info (priv->transient_parent); | |||
| 4635 | if (info->icon_list) | |||
| 4636 | return icon_from_list (info->icon_list, size); | |||
| 4637 | } | |||
| 4638 | ||||
| 4639 | if (default_icon_list != NULL((void*)0)) | |||
| 4640 | return icon_from_list (default_icon_list, size); | |||
| 4641 | ||||
| 4642 | if (default_icon_name != NULL((void*)0)) | |||
| 4643 | return icon_from_name (default_icon_name, size); | |||
| 4644 | ||||
| 4645 | return NULL((void*)0); | |||
| 4646 | } | |||
| 4647 | ||||
| 4648 | static void | |||
| 4649 | ctk_window_unrealize_icon (CtkWindow *window) | |||
| 4650 | { | |||
| 4651 | CtkWindowIconInfo *info; | |||
| 4652 | ||||
| 4653 | info = get_icon_info (window); | |||
| 4654 | ||||
| 4655 | if (info == NULL((void*)0)) | |||
| 4656 | return; | |||
| 4657 | ||||
| 4658 | /* We don't clear the properties on the window, just figure the | |||
| 4659 | * window is going away. | |||
| 4660 | */ | |||
| 4661 | ||||
| 4662 | info->realized = FALSE(0); | |||
| 4663 | ||||
| 4664 | } | |||
| 4665 | ||||
| 4666 | /** | |||
| 4667 | * ctk_window_set_icon_list: | |||
| 4668 | * @window: a #CtkWindow | |||
| 4669 | * @list: (element-type CdkPixbuf): list of #CdkPixbuf | |||
| 4670 | * | |||
| 4671 | * Sets up the icon representing a #CtkWindow. The icon is used when | |||
| 4672 | * the window is minimized (also known as iconified). Some window | |||
| 4673 | * managers or desktop environments may also place it in the window | |||
| 4674 | * frame, or display it in other contexts. On others, the icon is not | |||
| 4675 | * used at all, so your mileage may vary. | |||
| 4676 | * | |||
| 4677 | * ctk_window_set_icon_list() allows you to pass in the same icon in | |||
| 4678 | * several hand-drawn sizes. The list should contain the natural sizes | |||
| 4679 | * your icon is available in; that is, don’t scale the image before | |||
| 4680 | * passing it to CTK+. Scaling is postponed until the last minute, | |||
| 4681 | * when the desired final size is known, to allow best quality. | |||
| 4682 | * | |||
| 4683 | * By passing several sizes, you may improve the final image quality | |||
| 4684 | * of the icon, by reducing or eliminating automatic image scaling. | |||
| 4685 | * | |||
| 4686 | * Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and | |||
| 4687 | * larger images (64x64, 128x128) if you have them. | |||
| 4688 | * | |||
| 4689 | * See also ctk_window_set_default_icon_list() to set the icon | |||
| 4690 | * for all windows in your application in one go. | |||
| 4691 | * | |||
| 4692 | * Note that transient windows (those who have been set transient for another | |||
| 4693 | * window using ctk_window_set_transient_for()) will inherit their | |||
| 4694 | * icon from their transient parent. So there’s no need to explicitly | |||
| 4695 | * set the icon on transient windows. | |||
| 4696 | **/ | |||
| 4697 | void | |||
| 4698 | ctk_window_set_icon_list (CtkWindow *window, | |||
| 4699 | GList *list) | |||
| 4700 | { | |||
| 4701 | CtkWindowIconInfo *info; | |||
| 4702 | ||||
| 4703 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4704 | ||||
| 4705 | info = ensure_icon_info (window); | |||
| 4706 | ||||
| 4707 | if (info->icon_list == list) /* check for NULL mostly */ | |||
| 4708 | return; | |||
| 4709 | ||||
| 4710 | g_list_foreach (list, | |||
| 4711 | (GFunc) g_object_ref, NULL((void*)0)); | |||
| 4712 | ||||
| 4713 | g_list_free_full (info->icon_list, g_object_unref); | |||
| 4714 | ||||
| 4715 | info->icon_list = g_list_copy (list); | |||
| 4716 | ||||
| 4717 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_ICON]); | |||
| 4718 | ||||
| 4719 | ctk_window_unrealize_icon (window); | |||
| 4720 | ||||
| 4721 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 4722 | ctk_window_realize_icon (window); | |||
| 4723 | ||||
| 4724 | /* We could try to update our transient children, but I don't think | |||
| 4725 | * it's really worth it. If we did it, the best way would probably | |||
| 4726 | * be to have children connect to notify::icon-list | |||
| 4727 | */ | |||
| 4728 | } | |||
| 4729 | ||||
| 4730 | /** | |||
| 4731 | * ctk_window_get_icon_list: | |||
| 4732 | * @window: a #CtkWindow | |||
| 4733 | * | |||
| 4734 | * Retrieves the list of icons set by ctk_window_set_icon_list(). | |||
| 4735 | * The list is copied, but the reference count on each | |||
| 4736 | * member won’t be incremented. | |||
| 4737 | * | |||
| 4738 | * Returns: (element-type CdkPixbuf) (transfer container): copy of window’s icon list | |||
| 4739 | **/ | |||
| 4740 | GList* | |||
| 4741 | ctk_window_get_icon_list (CtkWindow *window) | |||
| 4742 | { | |||
| 4743 | CtkWindowIconInfo *info; | |||
| 4744 | ||||
| 4745 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 4746 | ||||
| 4747 | info = get_icon_info (window); | |||
| 4748 | ||||
| 4749 | if (info) | |||
| 4750 | return g_list_copy (info->icon_list); | |||
| 4751 | else | |||
| 4752 | return NULL((void*)0); | |||
| 4753 | } | |||
| 4754 | ||||
| 4755 | /** | |||
| 4756 | * ctk_window_set_icon: | |||
| 4757 | * @window: a #CtkWindow | |||
| 4758 | * @icon: (allow-none): icon image, or %NULL | |||
| 4759 | * | |||
| 4760 | * Sets up the icon representing a #CtkWindow. This icon is used when | |||
| 4761 | * the window is minimized (also known as iconified). Some window | |||
| 4762 | * managers or desktop environments may also place it in the window | |||
| 4763 | * frame, or display it in other contexts. On others, the icon is not | |||
| 4764 | * used at all, so your mileage may vary. | |||
| 4765 | * | |||
| 4766 | * The icon should be provided in whatever size it was naturally | |||
| 4767 | * drawn; that is, don’t scale the image before passing it to | |||
| 4768 | * CTK+. Scaling is postponed until the last minute, when the desired | |||
| 4769 | * final size is known, to allow best quality. | |||
| 4770 | * | |||
| 4771 | * If you have your icon hand-drawn in multiple sizes, use | |||
| 4772 | * ctk_window_set_icon_list(). Then the best size will be used. | |||
| 4773 | * | |||
| 4774 | * This function is equivalent to calling ctk_window_set_icon_list() | |||
| 4775 | * with a 1-element list. | |||
| 4776 | * | |||
| 4777 | * See also ctk_window_set_default_icon_list() to set the icon | |||
| 4778 | * for all windows in your application in one go. | |||
| 4779 | **/ | |||
| 4780 | void | |||
| 4781 | ctk_window_set_icon (CtkWindow *window, | |||
| 4782 | CdkPixbuf *icon) | |||
| 4783 | { | |||
| 4784 | GList *list; | |||
| 4785 | ||||
| 4786 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4787 | g_return_if_fail (icon == NULL || CDK_IS_PIXBUF (icon))do { if ((icon == ((void*)0) || (((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ((icon)); GType _t = ((cdk_pixbuf_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 ("Ctk", ((const char *) (__func__)), "icon == NULL || CDK_IS_PIXBUF (icon)"); return ; } } while (0); | |||
| 4788 | ||||
| 4789 | list = NULL((void*)0); | |||
| 4790 | ||||
| 4791 | if (icon) | |||
| 4792 | list = g_list_append (list, icon); | |||
| 4793 | ||||
| 4794 | ctk_window_set_icon_list (window, list); | |||
| 4795 | g_list_free (list); | |||
| 4796 | } | |||
| 4797 | ||||
| 4798 | ||||
| 4799 | static void | |||
| 4800 | update_themed_icon (CtkWindow *window) | |||
| 4801 | { | |||
| 4802 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_ICON_NAME]); | |||
| 4803 | ||||
| 4804 | ctk_window_unrealize_icon (window); | |||
| 4805 | ||||
| 4806 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 4807 | ctk_window_realize_icon (window); | |||
| 4808 | } | |||
| 4809 | ||||
| 4810 | /** | |||
| 4811 | * ctk_window_set_icon_name: | |||
| 4812 | * @window: a #CtkWindow | |||
| 4813 | * @name: (allow-none): the name of the themed icon | |||
| 4814 | * | |||
| 4815 | * Sets the icon for the window from a named themed icon. | |||
| 4816 | * See the docs for #CtkIconTheme for more details. | |||
| 4817 | * On some platforms, the window icon is not used at all. | |||
| 4818 | * | |||
| 4819 | * Note that this has nothing to do with the WM_ICON_NAME | |||
| 4820 | * property which is mentioned in the ICCCM. | |||
| 4821 | * | |||
| 4822 | * Since: 2.6 | |||
| 4823 | */ | |||
| 4824 | void | |||
| 4825 | ctk_window_set_icon_name (CtkWindow *window, | |||
| 4826 | const gchar *name) | |||
| 4827 | { | |||
| 4828 | CtkWindowIconInfo *info; | |||
| 4829 | gchar *tmp; | |||
| 4830 | ||||
| 4831 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 4832 | ||||
| 4833 | info = ensure_icon_info (window); | |||
| 4834 | ||||
| 4835 | if (g_strcmp0 (info->icon_name, name) == 0) | |||
| 4836 | return; | |||
| 4837 | ||||
| 4838 | tmp = info->icon_name; | |||
| 4839 | info->icon_name = g_strdup (name)g_strdup_inline (name); | |||
| 4840 | g_free (tmp)(__builtin_object_size ((tmp), 0) != ((size_t) - 1)) ? g_free_sized (tmp, __builtin_object_size ((tmp), 0)) : (g_free) (tmp); | |||
| 4841 | ||||
| 4842 | g_list_free_full (info->icon_list, g_object_unref); | |||
| 4843 | info->icon_list = NULL((void*)0); | |||
| 4844 | ||||
| 4845 | update_themed_icon (window); | |||
| 4846 | ||||
| 4847 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_ICON_NAME]); | |||
| 4848 | } | |||
| 4849 | ||||
| 4850 | /** | |||
| 4851 | * ctk_window_get_icon_name: | |||
| 4852 | * @window: a #CtkWindow | |||
| 4853 | * | |||
| 4854 | * Returns the name of the themed icon for the window, | |||
| 4855 | * see ctk_window_set_icon_name(). | |||
| 4856 | * | |||
| 4857 | * Returns: (nullable): the icon name or %NULL if the window has | |||
| 4858 | * no themed icon | |||
| 4859 | * | |||
| 4860 | * Since: 2.6 | |||
| 4861 | */ | |||
| 4862 | const gchar * | |||
| 4863 | ctk_window_get_icon_name (CtkWindow *window) | |||
| 4864 | { | |||
| 4865 | CtkWindowIconInfo *info; | |||
| 4866 | ||||
| 4867 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 4868 | ||||
| 4869 | info = ensure_icon_info (window); | |||
| 4870 | ||||
| 4871 | return info->icon_name; | |||
| 4872 | } | |||
| 4873 | ||||
| 4874 | /** | |||
| 4875 | * ctk_window_get_icon: | |||
| 4876 | * @window: a #CtkWindow | |||
| 4877 | * | |||
| 4878 | * Gets the value set by ctk_window_set_icon() (or if you've | |||
| 4879 | * called ctk_window_set_icon_list(), gets the first icon in | |||
| 4880 | * the icon list). | |||
| 4881 | * | |||
| 4882 | * Returns: (transfer none) (nullable): icon for window or %NULL if none | |||
| 4883 | **/ | |||
| 4884 | CdkPixbuf* | |||
| 4885 | ctk_window_get_icon (CtkWindow *window) | |||
| 4886 | { | |||
| 4887 | CtkWindowIconInfo *info; | |||
| 4888 | ||||
| 4889 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 4890 | ||||
| 4891 | info = get_icon_info (window); | |||
| 4892 | if (info && info->icon_list) | |||
| 4893 | return CDK_PIXBUF (info->icon_list->data)((((CdkPixbuf*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((info->icon_list->data)), ((cdk_pixbuf_get_type ()) ))))); | |||
| 4894 | else | |||
| 4895 | return NULL((void*)0); | |||
| 4896 | } | |||
| 4897 | ||||
| 4898 | /* Load pixbuf, printing warning on failure if error == NULL | |||
| 4899 | */ | |||
| 4900 | static CdkPixbuf * | |||
| 4901 | load_pixbuf_verbosely (const char *filename, | |||
| 4902 | GError **err) | |||
| 4903 | { | |||
| 4904 | GError *local_err = NULL((void*)0); | |||
| 4905 | CdkPixbuf *pixbuf; | |||
| 4906 | ||||
| 4907 | pixbuf = cdk_pixbuf_new_from_file (filename, &local_err); | |||
| 4908 | ||||
| 4909 | if (!pixbuf) | |||
| 4910 | { | |||
| 4911 | if (err) | |||
| 4912 | *err = local_err; | |||
| 4913 | else | |||
| 4914 | { | |||
| 4915 | g_warning ("Error loading icon from file '%s':\n\t%s", | |||
| 4916 | filename, local_err->message); | |||
| 4917 | g_error_free (local_err); | |||
| 4918 | } | |||
| 4919 | } | |||
| 4920 | ||||
| 4921 | return pixbuf; | |||
| 4922 | } | |||
| 4923 | ||||
| 4924 | /** | |||
| 4925 | * ctk_window_set_icon_from_file: | |||
| 4926 | * @window: a #CtkWindow | |||
| 4927 | * @filename: (type filename): location of icon file | |||
| 4928 | * @err: (allow-none): location to store error, or %NULL. | |||
| 4929 | * | |||
| 4930 | * Sets the icon for @window. | |||
| 4931 | * Warns on failure if @err is %NULL. | |||
| 4932 | * | |||
| 4933 | * This function is equivalent to calling ctk_window_set_icon() | |||
| 4934 | * with a pixbuf created by loading the image from @filename. | |||
| 4935 | * | |||
| 4936 | * Returns: %TRUE if setting the icon succeeded. | |||
| 4937 | * | |||
| 4938 | * Since: 2.2 | |||
| 4939 | **/ | |||
| 4940 | gboolean | |||
| 4941 | ctk_window_set_icon_from_file (CtkWindow *window, | |||
| 4942 | const gchar *filename, | |||
| 4943 | GError **err) | |||
| 4944 | { | |||
| 4945 | CdkPixbuf *pixbuf = load_pixbuf_verbosely (filename, err); | |||
| 4946 | ||||
| 4947 | if (pixbuf) | |||
| 4948 | { | |||
| 4949 | ctk_window_set_icon (window, pixbuf); | |||
| 4950 | g_object_unref (pixbuf); | |||
| 4951 | ||||
| 4952 | return TRUE(!(0)); | |||
| 4953 | } | |||
| 4954 | else | |||
| 4955 | return FALSE(0); | |||
| 4956 | } | |||
| 4957 | ||||
| 4958 | /** | |||
| 4959 | * ctk_window_set_default_icon_list: | |||
| 4960 | * @list: (element-type CdkPixbuf) (transfer container): a list of #CdkPixbuf | |||
| 4961 | * | |||
| 4962 | * Sets an icon list to be used as fallback for windows that haven't | |||
| 4963 | * had ctk_window_set_icon_list() called on them to set up a | |||
| 4964 | * window-specific icon list. This function allows you to set up the | |||
| 4965 | * icon for all windows in your app at once. | |||
| 4966 | * | |||
| 4967 | * See ctk_window_set_icon_list() for more details. | |||
| 4968 | * | |||
| 4969 | **/ | |||
| 4970 | void | |||
| 4971 | ctk_window_set_default_icon_list (GList *list) | |||
| 4972 | { | |||
| 4973 | GList *toplevels; | |||
| 4974 | GList *tmp_list; | |||
| 4975 | if (list == default_icon_list) | |||
| 4976 | return; | |||
| 4977 | ||||
| 4978 | /* Update serial so we don't used cached pixmaps/masks | |||
| 4979 | */ | |||
| 4980 | default_icon_serial++; | |||
| 4981 | ||||
| 4982 | g_list_foreach (list, | |||
| 4983 | (GFunc) g_object_ref, NULL((void*)0)); | |||
| 4984 | ||||
| 4985 | g_list_free_full (default_icon_list, g_object_unref); | |||
| 4986 | ||||
| 4987 | default_icon_list = g_list_copy (list); | |||
| 4988 | ||||
| 4989 | /* Update all toplevels */ | |||
| 4990 | toplevels = ctk_window_list_toplevels (); | |||
| 4991 | tmp_list = toplevels; | |||
| 4992 | while (tmp_list != NULL((void*)0)) | |||
| 4993 | { | |||
| 4994 | CtkWindowIconInfo *info; | |||
| 4995 | CtkWindow *w = tmp_list->data; | |||
| 4996 | ||||
| 4997 | info = get_icon_info (w); | |||
| 4998 | if (info && info->using_default_icon) | |||
| 4999 | { | |||
| 5000 | ctk_window_unrealize_icon (w); | |||
| 5001 | if (_ctk_widget_get_realized (CTK_WIDGET (w)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((w)), ((ctk_widget_get_type ())))))))) | |||
| 5002 | ctk_window_realize_icon (w); | |||
| 5003 | } | |||
| 5004 | ||||
| 5005 | tmp_list = tmp_list->next; | |||
| 5006 | } | |||
| 5007 | g_list_free (toplevels); | |||
| 5008 | } | |||
| 5009 | ||||
| 5010 | /** | |||
| 5011 | * ctk_window_set_default_icon: | |||
| 5012 | * @icon: the icon | |||
| 5013 | * | |||
| 5014 | * Sets an icon to be used as fallback for windows that haven't | |||
| 5015 | * had ctk_window_set_icon() called on them from a pixbuf. | |||
| 5016 | * | |||
| 5017 | * Since: 2.4 | |||
| 5018 | **/ | |||
| 5019 | void | |||
| 5020 | ctk_window_set_default_icon (CdkPixbuf *icon) | |||
| 5021 | { | |||
| 5022 | GList *list; | |||
| 5023 | ||||
| 5024 | g_return_if_fail (CDK_IS_PIXBUF (icon))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((icon)); GType _t = ((cdk_pixbuf_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 ("Ctk", ((const char*) (__func__)), "CDK_IS_PIXBUF (icon)"); return; } } while (0); | |||
| 5025 | ||||
| 5026 | list = g_list_prepend (NULL((void*)0), icon); | |||
| 5027 | ctk_window_set_default_icon_list (list); | |||
| 5028 | g_list_free (list); | |||
| 5029 | } | |||
| 5030 | ||||
| 5031 | /** | |||
| 5032 | * ctk_window_set_default_icon_name: | |||
| 5033 | * @name: the name of the themed icon | |||
| 5034 | * | |||
| 5035 | * Sets an icon to be used as fallback for windows that haven't | |||
| 5036 | * had ctk_window_set_icon_list() called on them from a named | |||
| 5037 | * themed icon, see ctk_window_set_icon_name(). | |||
| 5038 | * | |||
| 5039 | * Since: 2.6 | |||
| 5040 | **/ | |||
| 5041 | void | |||
| 5042 | ctk_window_set_default_icon_name (const gchar *name) | |||
| 5043 | { | |||
| 5044 | GList *tmp_list; | |||
| 5045 | GList *toplevels; | |||
| 5046 | ||||
| 5047 | /* Update serial so we don't used cached pixmaps/masks | |||
| 5048 | */ | |||
| 5049 | default_icon_serial++; | |||
| 5050 | ||||
| 5051 | g_free (default_icon_name)(__builtin_object_size ((default_icon_name), 0) != ((size_t) - 1)) ? g_free_sized (default_icon_name, __builtin_object_size ((default_icon_name), 0)) : (g_free) (default_icon_name); | |||
| 5052 | default_icon_name = g_strdup (name)g_strdup_inline (name); | |||
| 5053 | ||||
| 5054 | g_list_free_full (default_icon_list, g_object_unref); | |||
| 5055 | default_icon_list = NULL((void*)0); | |||
| 5056 | ||||
| 5057 | /* Update all toplevels */ | |||
| 5058 | toplevels = ctk_window_list_toplevels (); | |||
| 5059 | tmp_list = toplevels; | |||
| 5060 | while (tmp_list != NULL((void*)0)) | |||
| 5061 | { | |||
| 5062 | CtkWindowIconInfo *info; | |||
| 5063 | CtkWindow *w = tmp_list->data; | |||
| 5064 | ||||
| 5065 | info = get_icon_info (w); | |||
| 5066 | if (info && info->using_default_icon && info->using_themed_icon) | |||
| 5067 | { | |||
| 5068 | ctk_window_unrealize_icon (w); | |||
| 5069 | if (_ctk_widget_get_realized (CTK_WIDGET (w)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((w)), ((ctk_widget_get_type ())))))))) | |||
| 5070 | ctk_window_realize_icon (w); | |||
| 5071 | } | |||
| 5072 | ||||
| 5073 | tmp_list = tmp_list->next; | |||
| 5074 | } | |||
| 5075 | g_list_free (toplevels); | |||
| 5076 | } | |||
| 5077 | ||||
| 5078 | /** | |||
| 5079 | * ctk_window_get_default_icon_name: | |||
| 5080 | * | |||
| 5081 | * Returns the fallback icon name for windows that has been set | |||
| 5082 | * with ctk_window_set_default_icon_name(). The returned | |||
| 5083 | * string is owned by CTK+ and should not be modified. It | |||
| 5084 | * is only valid until the next call to | |||
| 5085 | * ctk_window_set_default_icon_name(). | |||
| 5086 | * | |||
| 5087 | * Returns: the fallback icon name for windows | |||
| 5088 | * | |||
| 5089 | * Since: 2.16 | |||
| 5090 | */ | |||
| 5091 | const gchar * | |||
| 5092 | ctk_window_get_default_icon_name (void) | |||
| 5093 | { | |||
| 5094 | return default_icon_name; | |||
| 5095 | } | |||
| 5096 | ||||
| 5097 | /** | |||
| 5098 | * ctk_window_set_default_icon_from_file: | |||
| 5099 | * @filename: (type filename): location of icon file | |||
| 5100 | * @err: (allow-none): location to store error, or %NULL. | |||
| 5101 | * | |||
| 5102 | * Sets an icon to be used as fallback for windows that haven't | |||
| 5103 | * had ctk_window_set_icon_list() called on them from a file | |||
| 5104 | * on disk. Warns on failure if @err is %NULL. | |||
| 5105 | * | |||
| 5106 | * Returns: %TRUE if setting the icon succeeded. | |||
| 5107 | * | |||
| 5108 | * Since: 2.2 | |||
| 5109 | **/ | |||
| 5110 | gboolean | |||
| 5111 | ctk_window_set_default_icon_from_file (const gchar *filename, | |||
| 5112 | GError **err) | |||
| 5113 | { | |||
| 5114 | CdkPixbuf *pixbuf = load_pixbuf_verbosely (filename, err); | |||
| 5115 | ||||
| 5116 | if (pixbuf) | |||
| 5117 | { | |||
| 5118 | ctk_window_set_default_icon (pixbuf); | |||
| 5119 | g_object_unref (pixbuf); | |||
| 5120 | ||||
| 5121 | return TRUE(!(0)); | |||
| 5122 | } | |||
| 5123 | else | |||
| 5124 | return FALSE(0); | |||
| 5125 | } | |||
| 5126 | ||||
| 5127 | /** | |||
| 5128 | * ctk_window_get_default_icon_list: | |||
| 5129 | * | |||
| 5130 | * Gets the value set by ctk_window_set_default_icon_list(). | |||
| 5131 | * The list is a copy and should be freed with g_list_free(), | |||
| 5132 | * but the pixbufs in the list have not had their reference count | |||
| 5133 | * incremented. | |||
| 5134 | * | |||
| 5135 | * Returns: (element-type CdkPixbuf) (transfer container): copy of default icon list | |||
| 5136 | **/ | |||
| 5137 | GList* | |||
| 5138 | ctk_window_get_default_icon_list (void) | |||
| 5139 | { | |||
| 5140 | return g_list_copy (default_icon_list); | |||
| 5141 | } | |||
| 5142 | ||||
| 5143 | #define INCLUDE_CSD_SIZE 1 | |||
| 5144 | #define EXCLUDE_CSD_SIZE -1 | |||
| 5145 | ||||
| 5146 | static void | |||
| 5147 | ctk_window_update_csd_size (CtkWindow *window, | |||
| 5148 | gint *width, | |||
| 5149 | gint *height, | |||
| 5150 | gint apply) | |||
| 5151 | { | |||
| 5152 | CtkWindowPrivate *priv = window->priv; | |||
| 5153 | CtkBorder window_border = { 0 }; | |||
| 5154 | gint w, h; | |||
| 5155 | ||||
| 5156 | if (priv->type != CTK_WINDOW_TOPLEVEL) | |||
| 5157 | return; | |||
| 5158 | ||||
| 5159 | if (!priv->decorated || | |||
| 5160 | priv->fullscreen) | |||
| 5161 | return; | |||
| 5162 | ||||
| 5163 | get_shadow_width (window, &window_border); | |||
| 5164 | w = *width + apply * (window_border.left + window_border.right); | |||
| 5165 | h = *height + apply * (window_border.top + window_border.bottom); | |||
| 5166 | ||||
| 5167 | if (priv->title_box != NULL((void*)0) && | |||
| 5168 | ctk_widget_get_visible (priv->title_box) && | |||
| 5169 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 5170 | { | |||
| 5171 | gint minimum_height; | |||
| 5172 | gint natural_height; | |||
| 5173 | ||||
| 5174 | ctk_widget_get_preferred_height (priv->title_box, &minimum_height, &natural_height); | |||
| 5175 | h += apply * natural_height; | |||
| 5176 | } | |||
| 5177 | ||||
| 5178 | /* Make sure the size remains acceptable */ | |||
| 5179 | if (w < 1) | |||
| 5180 | w = 1; | |||
| 5181 | if (h < 1) | |||
| 5182 | h = 1; | |||
| 5183 | ||||
| 5184 | /* Only update given size if not negative */ | |||
| 5185 | if (*width > -1) | |||
| 5186 | *width = w; | |||
| 5187 | if (*height > -1) | |||
| 5188 | *height = h; | |||
| 5189 | } | |||
| 5190 | ||||
| 5191 | static void | |||
| 5192 | ctk_window_set_default_size_internal (CtkWindow *window, | |||
| 5193 | gboolean change_width, | |||
| 5194 | gint width, | |||
| 5195 | gboolean change_height, | |||
| 5196 | gint height, | |||
| 5197 | gboolean is_geometry) | |||
| 5198 | { | |||
| 5199 | CtkWindowGeometryInfo *info; | |||
| 5200 | ||||
| 5201 | g_return_if_fail (change_width == FALSE || width >= -1)do { if ((change_width == (0) || width >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "change_width == FALSE || width >= -1" ); return; } } while (0); | |||
| 5202 | g_return_if_fail (change_height == FALSE || height >= -1)do { if ((change_height == (0) || height >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "change_height == FALSE || height >= -1"); return; } } while (0); | |||
| 5203 | ||||
| 5204 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 5205 | ||||
| 5206 | g_object_freeze_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | |||
| 5207 | ||||
| 5208 | info->default_is_geometry = is_geometry != FALSE(0); | |||
| 5209 | ||||
| 5210 | if (change_width) | |||
| 5211 | { | |||
| 5212 | if (width == 0) | |||
| 5213 | width = 1; | |||
| 5214 | ||||
| 5215 | if (width < 0) | |||
| 5216 | width = -1; | |||
| 5217 | ||||
| 5218 | if (info->default_width != width) | |||
| 5219 | { | |||
| 5220 | info->default_width = width; | |||
| 5221 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_DEFAULT_WIDTH]); | |||
| 5222 | } | |||
| 5223 | } | |||
| 5224 | ||||
| 5225 | if (change_height) | |||
| 5226 | { | |||
| 5227 | if (height == 0) | |||
| 5228 | height = 1; | |||
| 5229 | ||||
| 5230 | if (height < 0) | |||
| 5231 | height = -1; | |||
| 5232 | ||||
| 5233 | if (info->default_height != height) | |||
| 5234 | { | |||
| 5235 | info->default_height = height; | |||
| 5236 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_DEFAULT_HEIGHT]); | |||
| 5237 | } | |||
| 5238 | } | |||
| 5239 | ||||
| 5240 | g_object_thaw_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | |||
| 5241 | ||||
| 5242 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 5243 | } | |||
| 5244 | ||||
| 5245 | /** | |||
| 5246 | * ctk_window_set_default_size: | |||
| 5247 | * @window: a #CtkWindow | |||
| 5248 | * @width: width in pixels, or -1 to unset the default width | |||
| 5249 | * @height: height in pixels, or -1 to unset the default height | |||
| 5250 | * | |||
| 5251 | * Sets the default size of a window. If the window’s “natural” size | |||
| 5252 | * (its size request) is larger than the default, the default will be | |||
| 5253 | * ignored. More generally, if the default size does not obey the | |||
| 5254 | * geometry hints for the window (ctk_window_set_geometry_hints() can | |||
| 5255 | * be used to set these explicitly), the default size will be clamped | |||
| 5256 | * to the nearest permitted size. | |||
| 5257 | * | |||
| 5258 | * Unlike ctk_widget_set_size_request(), which sets a size request for | |||
| 5259 | * a widget and thus would keep users from shrinking the window, this | |||
| 5260 | * function only sets the initial size, just as if the user had | |||
| 5261 | * resized the window themselves. Users can still shrink the window | |||
| 5262 | * again as they normally would. Setting a default size of -1 means to | |||
| 5263 | * use the “natural” default size (the size request of the window). | |||
| 5264 | * | |||
| 5265 | * For more control over a window’s initial size and how resizing works, | |||
| 5266 | * investigate ctk_window_set_geometry_hints(). | |||
| 5267 | * | |||
| 5268 | * For some uses, ctk_window_resize() is a more appropriate function. | |||
| 5269 | * ctk_window_resize() changes the current size of the window, rather | |||
| 5270 | * than the size to be used on initial display. ctk_window_resize() always | |||
| 5271 | * affects the window itself, not the geometry widget. | |||
| 5272 | * | |||
| 5273 | * The default size of a window only affects the first time a window is | |||
| 5274 | * shown; if a window is hidden and re-shown, it will remember the size | |||
| 5275 | * it had prior to hiding, rather than using the default size. | |||
| 5276 | * | |||
| 5277 | * Windows can’t actually be 0x0 in size, they must be at least 1x1, but | |||
| 5278 | * passing 0 for @width and @height is OK, resulting in a 1x1 default size. | |||
| 5279 | * | |||
| 5280 | * If you use this function to reestablish a previously saved window size, | |||
| 5281 | * note that the appropriate size to save is the one returned by | |||
| 5282 | * ctk_window_get_size(). Using the window allocation directly will not | |||
| 5283 | * work in all circumstances and can lead to growing or shrinking windows. | |||
| 5284 | */ | |||
| 5285 | void | |||
| 5286 | ctk_window_set_default_size (CtkWindow *window, | |||
| 5287 | gint width, | |||
| 5288 | gint height) | |||
| 5289 | { | |||
| 5290 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5291 | g_return_if_fail (width >= -1)do { if ((width >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "width >= -1"); return ; } } while (0); | |||
| 5292 | g_return_if_fail (height >= -1)do { if ((height >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "height >= -1"); return ; } } while (0); | |||
| 5293 | ||||
| 5294 | ctk_window_set_default_size_internal (window, TRUE(!(0)), width, TRUE(!(0)), height, FALSE(0)); | |||
| 5295 | } | |||
| 5296 | ||||
| 5297 | /** | |||
| 5298 | * ctk_window_set_default_geometry: | |||
| 5299 | * @window: a #CtkWindow | |||
| 5300 | * @width: width in resize increments, or -1 to unset the default width | |||
| 5301 | * @height: height in resize increments, or -1 to unset the default height | |||
| 5302 | * | |||
| 5303 | * Like ctk_window_set_default_size(), but @width and @height are interpreted | |||
| 5304 | * in terms of the base size and increment set with | |||
| 5305 | * ctk_window_set_geometry_hints. | |||
| 5306 | * | |||
| 5307 | * Since: 3.0 | |||
| 5308 | * | |||
| 5309 | * Deprecated: 3.20: This function does nothing. If you want to set a default | |||
| 5310 | * size, use ctk_window_set_default_size() instead. | |||
| 5311 | */ | |||
| 5312 | void | |||
| 5313 | ctk_window_set_default_geometry (CtkWindow *window, | |||
| 5314 | gint width, | |||
| 5315 | gint height) | |||
| 5316 | { | |||
| 5317 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5318 | g_return_if_fail (width >= -1)do { if ((width >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "width >= -1"); return ; } } while (0); | |||
| 5319 | g_return_if_fail (height >= -1)do { if ((height >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "height >= -1"); return ; } } while (0); | |||
| 5320 | ||||
| 5321 | ctk_window_set_default_size_internal (window, TRUE(!(0)), width, TRUE(!(0)), height, TRUE(!(0))); | |||
| 5322 | } | |||
| 5323 | ||||
| 5324 | /** | |||
| 5325 | * ctk_window_get_default_size: | |||
| 5326 | * @window: a #CtkWindow | |||
| 5327 | * @width: (out) (allow-none): location to store the default width, or %NULL | |||
| 5328 | * @height: (out) (allow-none): location to store the default height, or %NULL | |||
| 5329 | * | |||
| 5330 | * Gets the default size of the window. A value of -1 for the width or | |||
| 5331 | * height indicates that a default size has not been explicitly set | |||
| 5332 | * for that dimension, so the “natural” size of the window will be | |||
| 5333 | * used. | |||
| 5334 | * | |||
| 5335 | **/ | |||
| 5336 | void | |||
| 5337 | ctk_window_get_default_size (CtkWindow *window, | |||
| 5338 | gint *width, | |||
| 5339 | gint *height) | |||
| 5340 | { | |||
| 5341 | CtkWindowGeometryInfo *info; | |||
| 5342 | ||||
| 5343 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5344 | ||||
| 5345 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 5346 | ||||
| 5347 | if (width) | |||
| 5348 | *width = info ? info->default_width : -1; | |||
| 5349 | ||||
| 5350 | if (height) | |||
| 5351 | *height = info ? info->default_height : -1; | |||
| 5352 | } | |||
| 5353 | ||||
| 5354 | /** | |||
| 5355 | * ctk_window_resize: | |||
| 5356 | * @window: a #CtkWindow | |||
| 5357 | * @width: width in pixels to resize the window to | |||
| 5358 | * @height: height in pixels to resize the window to | |||
| 5359 | * | |||
| 5360 | * Resizes the window as if the user had done so, obeying geometry | |||
| 5361 | * constraints. The default geometry constraint is that windows may | |||
| 5362 | * not be smaller than their size request; to override this | |||
| 5363 | * constraint, call ctk_widget_set_size_request() to set the window's | |||
| 5364 | * request to a smaller value. | |||
| 5365 | * | |||
| 5366 | * If ctk_window_resize() is called before showing a window for the | |||
| 5367 | * first time, it overrides any default size set with | |||
| 5368 | * ctk_window_set_default_size(). | |||
| 5369 | * | |||
| 5370 | * Windows may not be resized smaller than 1 by 1 pixels. | |||
| 5371 | * | |||
| 5372 | * When using client side decorations, CTK+ will do its best to adjust | |||
| 5373 | * the given size so that the resulting window size matches the | |||
| 5374 | * requested size without the title bar, borders and shadows added for | |||
| 5375 | * the client side decorations, but there is no guarantee that the | |||
| 5376 | * result will be totally accurate because these widgets added for | |||
| 5377 | * client side decorations depend on the theme and may not be realized | |||
| 5378 | * or visible at the time ctk_window_resize() is issued. | |||
| 5379 | * | |||
| 5380 | * If the CtkWindow has a titlebar widget (see ctk_window_set_titlebar()), then | |||
| 5381 | * typically, ctk_window_resize() will compensate for the height of the titlebar | |||
| 5382 | * widget only if the height is known when the resulting CtkWindow configuration | |||
| 5383 | * is issued. | |||
| 5384 | * For example, if new widgets are added after the CtkWindow configuration | |||
| 5385 | * and cause the titlebar widget to grow in height, this will result in a | |||
| 5386 | * window content smaller that specified by ctk_window_resize() and not | |||
| 5387 | * a larger window. | |||
| 5388 | * | |||
| 5389 | **/ | |||
| 5390 | void | |||
| 5391 | ctk_window_resize (CtkWindow *window, | |||
| 5392 | gint width, | |||
| 5393 | gint height) | |||
| 5394 | { | |||
| 5395 | CtkWindowGeometryInfo *info; | |||
| 5396 | ||||
| 5397 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5398 | g_return_if_fail (width > 0)do { if ((width > 0)) { } else { g_return_if_fail_warning ( "Ctk", ((const char*) (__func__)), "width > 0"); return; } } while (0); | |||
| 5399 | g_return_if_fail (height > 0)do { if ((height > 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "height > 0"); return ; } } while (0); | |||
| 5400 | ||||
| 5401 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 5402 | ||||
| 5403 | info->resize_width = width; | |||
| 5404 | info->resize_height = height; | |||
| 5405 | ||||
| 5406 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 5407 | } | |||
| 5408 | ||||
| 5409 | /** | |||
| 5410 | * ctk_window_resize_to_geometry: | |||
| 5411 | * @window: a #CtkWindow | |||
| 5412 | * @width: width in resize increments to resize the window to | |||
| 5413 | * @height: height in resize increments to resize the window to | |||
| 5414 | * | |||
| 5415 | * Like ctk_window_resize(), but @width and @height are interpreted | |||
| 5416 | * in terms of the base size and increment set with | |||
| 5417 | * ctk_window_set_geometry_hints. | |||
| 5418 | * | |||
| 5419 | * Since: 3.0 | |||
| 5420 | * | |||
| 5421 | * Deprecated: 3.20: This function does nothing. Use | |||
| 5422 | * ctk_window_resize() and compute the geometry yourself. | |||
| 5423 | */ | |||
| 5424 | void | |||
| 5425 | ctk_window_resize_to_geometry (CtkWindow *window, | |||
| 5426 | gint width, | |||
| 5427 | gint height) | |||
| 5428 | { | |||
| 5429 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5430 | g_return_if_fail (width > 0)do { if ((width > 0)) { } else { g_return_if_fail_warning ( "Ctk", ((const char*) (__func__)), "width > 0"); return; } } while (0); | |||
| 5431 | g_return_if_fail (height > 0)do { if ((height > 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "height > 0"); return ; } } while (0); | |||
| 5432 | } | |||
| 5433 | ||||
| 5434 | /** | |||
| 5435 | * ctk_window_get_size: | |||
| 5436 | * @window: a #CtkWindow | |||
| 5437 | * @width: (out) (nullable): return location for width, or %NULL | |||
| 5438 | * @height: (out) (nullable): return location for height, or %NULL | |||
| 5439 | * | |||
| 5440 | * Obtains the current size of @window. | |||
| 5441 | * | |||
| 5442 | * If @window is not visible on screen, this function return the size CTK+ | |||
| 5443 | * will suggest to the [window manager][ctk-X11-arch] for the initial window | |||
| 5444 | * size (but this is not reliably the same as the size the window manager | |||
| 5445 | * will actually select). See: ctk_window_set_default_size(). | |||
| 5446 | * | |||
| 5447 | * Depending on the windowing system and the window manager constraints, | |||
| 5448 | * the size returned by this function may not match the size set using | |||
| 5449 | * ctk_window_resize(); additionally, since ctk_window_resize() may be | |||
| 5450 | * implemented as an asynchronous operation, CTK+ cannot guarantee in any | |||
| 5451 | * way that this code: | |||
| 5452 | * | |||
| 5453 | * |[<!-- language="C" --> | |||
| 5454 | * // width and height are set elsewhere | |||
| 5455 | * ctk_window_resize (window, width, height); | |||
| 5456 | * | |||
| 5457 | * int new_width, new_height; | |||
| 5458 | * ctk_window_get_size (window, &new_width, &new_height); | |||
| 5459 | * ]| | |||
| 5460 | * | |||
| 5461 | * will result in `new_width` and `new_height` matching `width` and | |||
| 5462 | * `height`, respectively. | |||
| 5463 | * | |||
| 5464 | * This function will return the logical size of the #CtkWindow, | |||
| 5465 | * excluding the widgets used in client side decorations; there is, | |||
| 5466 | * however, no guarantee that the result will be completely accurate | |||
| 5467 | * because client side decoration may include widgets that depend on | |||
| 5468 | * the user preferences and that may not be visibile at the time you | |||
| 5469 | * call this function. | |||
| 5470 | * | |||
| 5471 | * The dimensions returned by this function are suitable for being | |||
| 5472 | * stored across sessions; use ctk_window_set_default_size() to | |||
| 5473 | * restore them when before showing the window. | |||
| 5474 | * | |||
| 5475 | * To avoid potential race conditions, you should only call this | |||
| 5476 | * function in response to a size change notification, for instance | |||
| 5477 | * inside a handler for the #CtkWidget::size-allocate signal, or | |||
| 5478 | * inside a handler for the #CtkWidget::configure-event signal: | |||
| 5479 | * | |||
| 5480 | * |[<!-- language="C" --> | |||
| 5481 | * static void | |||
| 5482 | * on_size_allocate (CtkWidget *widget, CtkAllocation *allocation) | |||
| 5483 | * { | |||
| 5484 | * int new_width, new_height; | |||
| 5485 | * | |||
| 5486 | * ctk_window_get_size (CTK_WINDOW (widget), &new_width, &new_height); | |||
| 5487 | * | |||
| 5488 | * ... | |||
| 5489 | * } | |||
| 5490 | * ]| | |||
| 5491 | * | |||
| 5492 | * Note that, if you connect to the #CtkWidget::size-allocate signal, | |||
| 5493 | * you should not use the dimensions of the #CtkAllocation passed to | |||
| 5494 | * the signal handler, as the allocation may contain client side | |||
| 5495 | * decorations added by CTK+, depending on the windowing system in | |||
| 5496 | * use. | |||
| 5497 | * | |||
| 5498 | * If you are getting a window size in order to position the window | |||
| 5499 | * on the screen, you should, instead, simply set the window’s semantic | |||
| 5500 | * type with ctk_window_set_type_hint(), which allows the window manager | |||
| 5501 | * to e.g. center dialogs. Also, if you set the transient parent of | |||
| 5502 | * dialogs with ctk_window_set_transient_for() window managers will | |||
| 5503 | * often center the dialog over its parent window. It's much preferred | |||
| 5504 | * to let the window manager handle these cases rather than doing it | |||
| 5505 | * yourself, because all apps will behave consistently and according to | |||
| 5506 | * user or system preferences, if the window manager handles it. Also, | |||
| 5507 | * the window manager can take into account the size of the window | |||
| 5508 | * decorations and border that it may add, and of which CTK+ has no | |||
| 5509 | * knowledge. Additionally, positioning windows in global screen coordinates | |||
| 5510 | * may not be allowed by the windowing system. For more information, | |||
| 5511 | * see: ctk_window_set_position(). | |||
| 5512 | */ | |||
| 5513 | void | |||
| 5514 | ctk_window_get_size (CtkWindow *window, | |||
| 5515 | gint *width, | |||
| 5516 | gint *height) | |||
| 5517 | { | |||
| 5518 | gint w, h; | |||
| 5519 | ||||
| 5520 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5521 | ||||
| 5522 | if (width == NULL((void*)0) && height == NULL((void*)0)) | |||
| 5523 | return; | |||
| 5524 | ||||
| 5525 | if (_ctk_widget_get_mapped (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 5526 | { | |||
| 5527 | w = cdk_window_get_width (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
| 5528 | h = cdk_window_get_height (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
| 5529 | } | |||
| 5530 | else | |||
| 5531 | { | |||
| 5532 | CdkRectangle configure_request; | |||
| 5533 | ||||
| 5534 | ctk_window_compute_configure_request (window, | |||
| 5535 | &configure_request, | |||
| 5536 | NULL((void*)0), NULL((void*)0)); | |||
| 5537 | ||||
| 5538 | w = configure_request.width; | |||
| 5539 | h = configure_request.height; | |||
| 5540 | } | |||
| 5541 | ||||
| 5542 | ctk_window_update_csd_size (window, &w, &h, EXCLUDE_CSD_SIZE); | |||
| 5543 | ||||
| 5544 | if (width) | |||
| 5545 | *width = w; | |||
| 5546 | if (height) | |||
| 5547 | *height = h; | |||
| 5548 | } | |||
| 5549 | ||||
| 5550 | static void | |||
| 5551 | ctk_window_translate_csd_pos (CtkWindow *window, | |||
| 5552 | gint *root_x, | |||
| 5553 | gint *root_y, | |||
| 5554 | gint apply) | |||
| 5555 | { | |||
| 5556 | CtkWindowPrivate *priv = window->priv; | |||
| 5557 | ||||
| 5558 | if (priv->type != CTK_WINDOW_TOPLEVEL) | |||
| 5559 | return; | |||
| 5560 | ||||
| 5561 | if (priv->decorated && | |||
| 5562 | !priv->fullscreen) | |||
| 5563 | { | |||
| 5564 | CtkBorder window_border = { 0 }; | |||
| 5565 | gint title_height = 0; | |||
| 5566 | gint dx; | |||
| 5567 | gint dy; | |||
| 5568 | ||||
| 5569 | get_shadow_width (window, &window_border); | |||
| 5570 | if (priv->title_box != NULL((void*)0) && | |||
| 5571 | ctk_widget_get_visible (priv->title_box) && | |||
| 5572 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 5573 | { | |||
| 5574 | gint minimum_height; | |||
| 5575 | ||||
| 5576 | ctk_widget_get_preferred_height (priv->title_box, &minimum_height, &title_height); | |||
| 5577 | } | |||
| 5578 | ||||
| 5579 | switch (priv->gravity) | |||
| 5580 | { | |||
| 5581 | case CDK_GRAVITY_NORTH: | |||
| 5582 | case CDK_GRAVITY_CENTER: | |||
| 5583 | case CDK_GRAVITY_SOUTH: | |||
| 5584 | dx = (window_border.left + window_border.right) / 2; | |||
| 5585 | break; | |||
| 5586 | ||||
| 5587 | case CDK_GRAVITY_NORTH_WEST: | |||
| 5588 | case CDK_GRAVITY_WEST: | |||
| 5589 | case CDK_GRAVITY_SOUTH_WEST: | |||
| 5590 | case CDK_GRAVITY_SOUTH_EAST: | |||
| 5591 | case CDK_GRAVITY_EAST: | |||
| 5592 | case CDK_GRAVITY_NORTH_EAST: | |||
| 5593 | dx = window_border.left; | |||
| 5594 | break; | |||
| 5595 | ||||
| 5596 | default: | |||
| 5597 | dx = 0; | |||
| 5598 | break; | |||
| 5599 | } | |||
| 5600 | ||||
| 5601 | switch (priv->gravity) | |||
| 5602 | { | |||
| 5603 | case CDK_GRAVITY_WEST: | |||
| 5604 | case CDK_GRAVITY_CENTER: | |||
| 5605 | case CDK_GRAVITY_EAST: | |||
| 5606 | dy = (window_border.top + title_height + window_border.bottom) / 2; | |||
| 5607 | break; | |||
| 5608 | ||||
| 5609 | case CDK_GRAVITY_NORTH_WEST: | |||
| 5610 | case CDK_GRAVITY_NORTH: | |||
| 5611 | case CDK_GRAVITY_NORTH_EAST: | |||
| 5612 | dy = window_border.top; | |||
| 5613 | break; | |||
| 5614 | ||||
| 5615 | case CDK_GRAVITY_SOUTH_WEST: | |||
| 5616 | case CDK_GRAVITY_SOUTH: | |||
| 5617 | case CDK_GRAVITY_SOUTH_EAST: | |||
| 5618 | dy = window_border.top + title_height; | |||
| 5619 | break; | |||
| 5620 | ||||
| 5621 | default: | |||
| 5622 | dy = 0; | |||
| 5623 | break; | |||
| 5624 | } | |||
| 5625 | ||||
| 5626 | if (root_x) | |||
| 5627 | *root_x = *root_x + (dx * apply); | |||
| 5628 | if (root_y) | |||
| 5629 | *root_y = *root_y + (dy * apply); | |||
| 5630 | } | |||
| 5631 | } | |||
| 5632 | ||||
| 5633 | /** | |||
| 5634 | * ctk_window_move: | |||
| 5635 | * @window: a #CtkWindow | |||
| 5636 | * @x: X coordinate to move window to | |||
| 5637 | * @y: Y coordinate to move window to | |||
| 5638 | * | |||
| 5639 | * Asks the [window manager][ctk-X11-arch] to move | |||
| 5640 | * @window to the given position. Window managers are free to ignore | |||
| 5641 | * this; most window managers ignore requests for initial window | |||
| 5642 | * positions (instead using a user-defined placement algorithm) and | |||
| 5643 | * honor requests after the window has already been shown. | |||
| 5644 | * | |||
| 5645 | * Note: the position is the position of the gravity-determined | |||
| 5646 | * reference point for the window. The gravity determines two things: | |||
| 5647 | * first, the location of the reference point in root window | |||
| 5648 | * coordinates; and second, which point on the window is positioned at | |||
| 5649 | * the reference point. | |||
| 5650 | * | |||
| 5651 | * By default the gravity is #CDK_GRAVITY_NORTH_WEST, so the reference | |||
| 5652 | * point is simply the @x, @y supplied to ctk_window_move(). The | |||
| 5653 | * top-left corner of the window decorations (aka window frame or | |||
| 5654 | * border) will be placed at @x, @y. Therefore, to position a window | |||
| 5655 | * at the top left of the screen, you want to use the default gravity | |||
| 5656 | * (which is #CDK_GRAVITY_NORTH_WEST) and move the window to 0,0. | |||
| 5657 | * | |||
| 5658 | * To position a window at the bottom right corner of the screen, you | |||
| 5659 | * would set #CDK_GRAVITY_SOUTH_EAST, which means that the reference | |||
| 5660 | * point is at @x + the window width and @y + the window height, and | |||
| 5661 | * the bottom-right corner of the window border will be placed at that | |||
| 5662 | * reference point. So, to place a window in the bottom right corner | |||
| 5663 | * you would first set gravity to south east, then write: | |||
| 5664 | * `ctk_window_move (window, cdk_screen_width () - window_width, | |||
| 5665 | * cdk_screen_height () - window_height)` (note that this | |||
| 5666 | * example does not take multi-head scenarios into account). | |||
| 5667 | * | |||
| 5668 | * The [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec) | |||
| 5669 | * has a nice table of gravities in the “implementation notes” section. | |||
| 5670 | * | |||
| 5671 | * The ctk_window_get_position() documentation may also be relevant. | |||
| 5672 | */ | |||
| 5673 | void | |||
| 5674 | ctk_window_move (CtkWindow *window, | |||
| 5675 | gint x, | |||
| 5676 | gint y) | |||
| 5677 | { | |||
| 5678 | CtkWindowGeometryInfo *info; | |||
| 5679 | CtkWidget *widget; | |||
| 5680 | ||||
| 5681 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5682 | ||||
| 5683 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 5684 | ||||
| 5685 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 5686 | ctk_window_translate_csd_pos (window, &x, &y, EXCLUDE_CSD_SIZE); | |||
| 5687 | ||||
| 5688 | if (_ctk_widget_get_mapped (widget)) | |||
| 5689 | { | |||
| 5690 | CtkAllocation allocation; | |||
| 5691 | ||||
| 5692 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 5693 | ||||
| 5694 | /* we have now sent a request with this position | |||
| 5695 | * with currently-active constraints, so toggle flag. | |||
| 5696 | */ | |||
| 5697 | info->position_constraints_changed = FALSE(0); | |||
| 5698 | ||||
| 5699 | /* we only constrain if mapped - if not mapped, | |||
| 5700 | * then ctk_window_compute_configure_request() | |||
| 5701 | * will apply the constraints later, and we | |||
| 5702 | * don't want to lose information about | |||
| 5703 | * what position the user set before then. | |||
| 5704 | * i.e. if you do a move() then turn off POS_CENTER | |||
| 5705 | * then show the window, your move() will work. | |||
| 5706 | */ | |||
| 5707 | ctk_window_constrain_position (window, | |||
| 5708 | allocation.width, allocation.height, | |||
| 5709 | &x, &y); | |||
| 5710 | ||||
| 5711 | /* Note that this request doesn't go through our standard request | |||
| 5712 | * framework, e.g. doesn't increment configure_request_count, | |||
| 5713 | * doesn't set info->last, etc.; that's because | |||
| 5714 | * we don't save the info needed to arrive at this same request | |||
| 5715 | * again. | |||
| 5716 | * | |||
| 5717 | * To ctk_window_move_resize(), this will end up looking exactly | |||
| 5718 | * the same as the position being changed by the window | |||
| 5719 | * manager. | |||
| 5720 | */ | |||
| 5721 | cdk_window_move (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), x, y); | |||
| 5722 | } | |||
| 5723 | else | |||
| 5724 | { | |||
| 5725 | /* Save this position to apply on mapping */ | |||
| 5726 | ctk_widget_queue_resize (widget); | |||
| 5727 | info->initial_x = x; | |||
| 5728 | info->initial_y = y; | |||
| 5729 | info->initial_pos_set = TRUE(!(0)); | |||
| 5730 | } | |||
| 5731 | } | |||
| 5732 | ||||
| 5733 | /** | |||
| 5734 | * ctk_window_get_position: | |||
| 5735 | * @window: a #CtkWindow | |||
| 5736 | * @root_x: (out) (allow-none): return location for X coordinate of | |||
| 5737 | * gravity-determined reference point, or %NULL | |||
| 5738 | * @root_y: (out) (allow-none): return location for Y coordinate of | |||
| 5739 | * gravity-determined reference point, or %NULL | |||
| 5740 | * | |||
| 5741 | * This function returns the position you need to pass to | |||
| 5742 | * ctk_window_move() to keep @window in its current position. | |||
| 5743 | * This means that the meaning of the returned value varies with | |||
| 5744 | * window gravity. See ctk_window_move() for more details. | |||
| 5745 | * | |||
| 5746 | * The reliability of this function depends on the windowing system | |||
| 5747 | * currently in use. Some windowing systems, such as Wayland, do not | |||
| 5748 | * support a global coordinate system, and thus the position of the | |||
| 5749 | * window will always be (0, 0). Others, like X11, do not have a reliable | |||
| 5750 | * way to obtain the geometry of the decorations of a window if they are | |||
| 5751 | * provided by the window manager. Additionally, on X11, window manager | |||
| 5752 | * have been known to mismanage window gravity, which result in windows | |||
| 5753 | * moving even if you use the coordinates of the current position as | |||
| 5754 | * returned by this function. | |||
| 5755 | * | |||
| 5756 | * If you haven’t changed the window gravity, its gravity will be | |||
| 5757 | * #CDK_GRAVITY_NORTH_WEST. This means that ctk_window_get_position() | |||
| 5758 | * gets the position of the top-left corner of the window manager | |||
| 5759 | * frame for the window. ctk_window_move() sets the position of this | |||
| 5760 | * same top-left corner. | |||
| 5761 | * | |||
| 5762 | * If a window has gravity #CDK_GRAVITY_STATIC the window manager | |||
| 5763 | * frame is not relevant, and thus ctk_window_get_position() will | |||
| 5764 | * always produce accurate results. However you can’t use static | |||
| 5765 | * gravity to do things like place a window in a corner of the screen, | |||
| 5766 | * because static gravity ignores the window manager decorations. | |||
| 5767 | * | |||
| 5768 | * Ideally, this function should return appropriate values if the | |||
| 5769 | * window has client side decorations, assuming that the windowing | |||
| 5770 | * system supports global coordinates. | |||
| 5771 | * | |||
| 5772 | * In practice, saving the window position should not be left to | |||
| 5773 | * applications, as they lack enough knowledge of the windowing | |||
| 5774 | * system and the window manager state to effectively do so. The | |||
| 5775 | * appropriate way to implement saving the window position is to | |||
| 5776 | * use a platform-specific protocol, wherever that is available. | |||
| 5777 | */ | |||
| 5778 | void | |||
| 5779 | ctk_window_get_position (CtkWindow *window, | |||
| 5780 | gint *root_x, | |||
| 5781 | gint *root_y) | |||
| 5782 | { | |||
| 5783 | CtkWindowPrivate *priv; | |||
| 5784 | CtkWidget *widget; | |||
| 5785 | CdkWindow *cdk_window; | |||
| 5786 | ||||
| 5787 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5788 | ||||
| 5789 | priv = window->priv; | |||
| 5790 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 5791 | cdk_window = _ctk_widget_get_window (widget); | |||
| 5792 | ||||
| 5793 | if (priv->gravity == CDK_GRAVITY_STATIC) | |||
| 5794 | { | |||
| 5795 | if (_ctk_widget_get_mapped (widget)) | |||
| 5796 | { | |||
| 5797 | /* This does a server round-trip, which is sort of wrong; | |||
| 5798 | * but a server round-trip is inevitable for | |||
| 5799 | * cdk_window_get_frame_extents() in the usual | |||
| 5800 | * NorthWestGravity case below, so not sure what else to | |||
| 5801 | * do. We should likely be consistent about whether we get | |||
| 5802 | * the client-side info or the server-side info. | |||
| 5803 | */ | |||
| 5804 | cdk_window_get_origin (cdk_window, root_x, root_y); | |||
| 5805 | } | |||
| 5806 | else | |||
| 5807 | { | |||
| 5808 | CdkRectangle configure_request; | |||
| 5809 | ||||
| 5810 | ctk_window_compute_configure_request (window, | |||
| 5811 | &configure_request, | |||
| 5812 | NULL((void*)0), NULL((void*)0)); | |||
| 5813 | ||||
| 5814 | *root_x = configure_request.x; | |||
| 5815 | *root_y = configure_request.y; | |||
| 5816 | } | |||
| 5817 | ctk_window_translate_csd_pos (window, root_x, root_y, INCLUDE_CSD_SIZE); | |||
| 5818 | } | |||
| 5819 | else | |||
| 5820 | { | |||
| 5821 | CdkRectangle frame_extents; | |||
| 5822 | ||||
| 5823 | gint x, y; | |||
| 5824 | gint w, h; | |||
| 5825 | ||||
| 5826 | if (_ctk_widget_get_mapped (widget)) | |||
| 5827 | { | |||
| 5828 | cdk_window_get_frame_extents (cdk_window, &frame_extents); | |||
| 5829 | x = frame_extents.x; | |||
| 5830 | y = frame_extents.y; | |||
| 5831 | ctk_window_get_size (window, &w, &h); | |||
| 5832 | /* ctk_window_get_size() will have already taken into account | |||
| 5833 | * the padding added by the CSD shadow and title bar, so we need | |||
| 5834 | * to revert it here, otherwise we'll end up counting it twice... | |||
| 5835 | */ | |||
| 5836 | ctk_window_update_csd_size (window, &w, &h, INCLUDE_CSD_SIZE); | |||
| 5837 | } | |||
| 5838 | else | |||
| 5839 | { | |||
| 5840 | /* We just say the frame has 0 size on all sides. | |||
| 5841 | * Not sure what else to do. | |||
| 5842 | */ | |||
| 5843 | ctk_window_compute_configure_request (window, | |||
| 5844 | &frame_extents, | |||
| 5845 | NULL((void*)0), NULL((void*)0)); | |||
| 5846 | x = frame_extents.x; | |||
| 5847 | y = frame_extents.y; | |||
| 5848 | w = frame_extents.width; | |||
| 5849 | h = frame_extents.height; | |||
| 5850 | } | |||
| 5851 | ||||
| 5852 | ctk_window_translate_csd_pos (window, &x, &y, INCLUDE_CSD_SIZE); | |||
| 5853 | switch (priv->gravity) | |||
| 5854 | { | |||
| 5855 | case CDK_GRAVITY_NORTH: | |||
| 5856 | case CDK_GRAVITY_CENTER: | |||
| 5857 | case CDK_GRAVITY_SOUTH: | |||
| 5858 | /* Find center of frame. */ | |||
| 5859 | x += frame_extents.width / 2; | |||
| 5860 | /* Center client window on that point. */ | |||
| 5861 | x -= w / 2; | |||
| 5862 | break; | |||
| 5863 | ||||
| 5864 | case CDK_GRAVITY_SOUTH_EAST: | |||
| 5865 | case CDK_GRAVITY_EAST: | |||
| 5866 | case CDK_GRAVITY_NORTH_EAST: | |||
| 5867 | /* Find right edge of frame */ | |||
| 5868 | x += frame_extents.width; | |||
| 5869 | /* Align left edge of client at that point. */ | |||
| 5870 | x -= w; | |||
| 5871 | break; | |||
| 5872 | default: | |||
| 5873 | break; | |||
| 5874 | } | |||
| 5875 | ||||
| 5876 | switch (priv->gravity) | |||
| 5877 | { | |||
| 5878 | case CDK_GRAVITY_WEST: | |||
| 5879 | case CDK_GRAVITY_CENTER: | |||
| 5880 | case CDK_GRAVITY_EAST: | |||
| 5881 | /* Find center of frame. */ | |||
| 5882 | y += frame_extents.height / 2; | |||
| 5883 | /* Center client window there. */ | |||
| 5884 | y -= h / 2; | |||
| 5885 | break; | |||
| 5886 | case CDK_GRAVITY_SOUTH_WEST: | |||
| 5887 | case CDK_GRAVITY_SOUTH: | |||
| 5888 | case CDK_GRAVITY_SOUTH_EAST: | |||
| 5889 | /* Find south edge of frame */ | |||
| 5890 | y += frame_extents.height; | |||
| 5891 | /* Place bottom edge of client there */ | |||
| 5892 | y -= h; | |||
| 5893 | break; | |||
| 5894 | default: | |||
| 5895 | break; | |||
| 5896 | } | |||
| 5897 | ||||
| 5898 | if (root_x) | |||
| 5899 | *root_x = x; | |||
| 5900 | if (root_y) | |||
| 5901 | *root_y = y; | |||
| 5902 | } | |||
| 5903 | } | |||
| 5904 | ||||
| 5905 | /** | |||
| 5906 | * ctk_window_reshow_with_initial_size: | |||
| 5907 | * @window: a #CtkWindow | |||
| 5908 | * | |||
| 5909 | * Hides @window, then reshows it, resetting the | |||
| 5910 | * default size and position of the window. Used | |||
| 5911 | * by GUI builders only. | |||
| 5912 | * | |||
| 5913 | * Deprecated: 3.10: GUI builders can call ctk_widget_hide(), | |||
| 5914 | * ctk_widget_unrealize() and then ctk_widget_show() on @window | |||
| 5915 | * themselves, if they still need this functionality. | |||
| 5916 | **/ | |||
| 5917 | void | |||
| 5918 | ctk_window_reshow_with_initial_size (CtkWindow *window) | |||
| 5919 | { | |||
| 5920 | CtkWidget *widget; | |||
| 5921 | ||||
| 5922 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 5923 | ||||
| 5924 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 5925 | ||||
| 5926 | ctk_widget_hide (widget); | |||
| 5927 | ctk_widget_unrealize (widget); | |||
| 5928 | ctk_widget_show (widget); | |||
| 5929 | } | |||
| 5930 | ||||
| 5931 | static void | |||
| 5932 | ctk_window_destroy (CtkWidget *widget) | |||
| 5933 | { | |||
| 5934 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 5935 | CtkWindowPrivate *priv = window->priv; | |||
| 5936 | ||||
| 5937 | ctk_window_release_application (window); | |||
| 5938 | ||||
| 5939 | toplevel_list = g_slist_remove (toplevel_list, window); | |||
| 5940 | ctk_window_update_debugging (); | |||
| 5941 | ||||
| 5942 | if (priv->transient_parent) | |||
| 5943 | ctk_window_set_transient_for (window, NULL((void*)0)); | |||
| 5944 | ||||
| 5945 | remove_attach_widget (window); | |||
| 5946 | ||||
| 5947 | /* frees the icons */ | |||
| 5948 | ctk_window_set_icon_list (window, NULL((void*)0)); | |||
| 5949 | ||||
| 5950 | if (priv->has_user_ref_count) | |||
| 5951 | { | |||
| 5952 | priv->has_user_ref_count = FALSE(0); | |||
| 5953 | g_object_unref (window); | |||
| 5954 | } | |||
| 5955 | ||||
| 5956 | if (priv->group) | |||
| 5957 | ctk_window_group_remove_window (priv->group, window); | |||
| 5958 | ||||
| 5959 | ctk_window_free_key_hash (window); | |||
| 5960 | ||||
| 5961 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->destroy (widget); | |||
| 5962 | } | |||
| 5963 | ||||
| 5964 | static void | |||
| 5965 | ctk_window_finalize (GObject *object) | |||
| 5966 | { | |||
| 5967 | CtkWindow *window = CTK_WINDOW (object)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_window_get_type ())))))); | |||
| 5968 | CtkWindowPrivate *priv = window->priv; | |||
| 5969 | CtkMnemonicHash *mnemonic_hash; | |||
| 5970 | ||||
| 5971 | g_free (priv->title)(__builtin_object_size ((priv->title), 0) != ((size_t) - 1 )) ? g_free_sized (priv->title, __builtin_object_size ((priv ->title), 0)) : (g_free) (priv->title); | |||
| 5972 | g_free (priv->wmclass_name)(__builtin_object_size ((priv->wmclass_name), 0) != ((size_t ) - 1)) ? g_free_sized (priv->wmclass_name, __builtin_object_size ((priv->wmclass_name), 0)) : (g_free) (priv->wmclass_name ); | |||
| 5973 | g_free (priv->wmclass_class)(__builtin_object_size ((priv->wmclass_class), 0) != ((size_t ) - 1)) ? g_free_sized (priv->wmclass_class, __builtin_object_size ((priv->wmclass_class), 0)) : (g_free) (priv->wmclass_class ); | |||
| 5974 | g_free (priv->wm_role)(__builtin_object_size ((priv->wm_role), 0) != ((size_t) - 1)) ? g_free_sized (priv->wm_role, __builtin_object_size ( (priv->wm_role), 0)) : (g_free) (priv->wm_role); | |||
| 5975 | ctk_window_release_application (window); | |||
| 5976 | ||||
| 5977 | mnemonic_hash = ctk_window_get_mnemonic_hash (window, FALSE(0)); | |||
| 5978 | if (mnemonic_hash) | |||
| 5979 | _ctk_mnemonic_hash_free (mnemonic_hash); | |||
| 5980 | ||||
| 5981 | if (priv->geometry_info) | |||
| 5982 | { | |||
| 5983 | g_free (priv->geometry_info)(__builtin_object_size ((priv->geometry_info), 0) != ((size_t ) - 1)) ? g_free_sized (priv->geometry_info, __builtin_object_size ((priv->geometry_info), 0)) : (g_free) (priv->geometry_info ); | |||
| 5984 | } | |||
| 5985 | ||||
| 5986 | if (priv->keys_changed_handler) | |||
| 5987 | { | |||
| 5988 | g_source_remove (priv->keys_changed_handler); | |||
| 5989 | priv->keys_changed_handler = 0; | |||
| 5990 | } | |||
| 5991 | ||||
| 5992 | if (priv->delete_event_handler) | |||
| 5993 | { | |||
| 5994 | g_source_remove (priv->delete_event_handler); | |||
| 5995 | priv->delete_event_handler = 0; | |||
| 5996 | } | |||
| 5997 | ||||
| 5998 | if (priv->screen) | |||
| 5999 | { | |||
| 6000 | g_signal_handlers_disconnect_by_func (priv->screen,g_signal_handlers_disconnect_matched ((priv->screen), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_window_on_composited_changed), (window)) | |||
| 6001 | ctk_window_on_composited_changed, window)g_signal_handlers_disconnect_matched ((priv->screen), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_window_on_composited_changed), (window)); | |||
| 6002 | #ifdef CDK_WINDOWING_X11 | |||
| 6003 | g_signal_handlers_disconnect_by_func (ctk_settings_get_for_screen (priv->screen),g_signal_handlers_disconnect_matched ((ctk_settings_get_for_screen (priv->screen)), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (ctk_window_on_theme_variant_changed ), (window)) | |||
| 6004 | ctk_window_on_theme_variant_changed,g_signal_handlers_disconnect_matched ((ctk_settings_get_for_screen (priv->screen)), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (ctk_window_on_theme_variant_changed ), (window)) | |||
| 6005 | window)g_signal_handlers_disconnect_matched ((ctk_settings_get_for_screen (priv->screen)), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (ctk_window_on_theme_variant_changed ), (window)); | |||
| 6006 | #endif | |||
| 6007 | } | |||
| 6008 | ||||
| 6009 | g_free (priv->startup_id)(__builtin_object_size ((priv->startup_id), 0) != ((size_t ) - 1)) ? g_free_sized (priv->startup_id, __builtin_object_size ((priv->startup_id), 0)) : (g_free) (priv->startup_id); | |||
| 6010 | ||||
| 6011 | if (priv->mnemonics_display_timeout_id) | |||
| 6012 | { | |||
| 6013 | g_source_remove (priv->mnemonics_display_timeout_id); | |||
| 6014 | priv->mnemonics_display_timeout_id = 0; | |||
| 6015 | } | |||
| 6016 | ||||
| 6017 | if (priv->multipress_gesture) | |||
| 6018 | g_object_unref (priv->multipress_gesture); | |||
| 6019 | ||||
| 6020 | if (priv->drag_gesture) | |||
| 6021 | g_object_unref (priv->drag_gesture); | |||
| 6022 | ||||
| 6023 | G_OBJECT_CLASS (ctk_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), (((GType) ((20) << (2)) ))))))->finalize (object); | |||
| 6024 | } | |||
| 6025 | ||||
| 6026 | /* copied from cdkwindow-x11.c */ | |||
| 6027 | static const gchar * | |||
| 6028 | get_default_title (void) | |||
| 6029 | { | |||
| 6030 | const gchar *title; | |||
| 6031 | ||||
| 6032 | title = g_get_application_name (); | |||
| 6033 | if (!title) | |||
| 6034 | title = g_get_prgname (); | |||
| 6035 | if (!title) | |||
| 6036 | title = ""; | |||
| 6037 | ||||
| 6038 | return title; | |||
| 6039 | } | |||
| 6040 | ||||
| 6041 | static gboolean | |||
| 6042 | update_csd_visibility (CtkWindow *window) | |||
| 6043 | { | |||
| 6044 | CtkWindowPrivate *priv = window->priv; | |||
| 6045 | gboolean visible; | |||
| 6046 | ||||
| 6047 | if (priv->title_box == NULL((void*)0)) | |||
| 6048 | return FALSE(0); | |||
| 6049 | ||||
| 6050 | visible = priv->decorated && | |||
| 6051 | !priv->fullscreen && | |||
| 6052 | !(priv->titlebar == priv->title_box && | |||
| 6053 | priv->maximized && | |||
| 6054 | priv->hide_titlebar_when_maximized); | |||
| 6055 | ctk_widget_set_child_visible (priv->title_box, visible); | |||
| 6056 | ||||
| 6057 | return visible; | |||
| 6058 | } | |||
| 6059 | ||||
| 6060 | static void | |||
| 6061 | update_window_buttons (CtkWindow *window) | |||
| 6062 | { | |||
| 6063 | CtkWindowPrivate *priv = window->priv; | |||
| 6064 | ||||
| 6065 | if (!update_csd_visibility (window)) | |||
| 6066 | return; | |||
| 6067 | ||||
| 6068 | if (CTK_IS_HEADER_BAR (priv->title_box)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (priv->title_box)); GType _t = ((ctk_header_bar_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; }))))) | |||
| 6069 | _ctk_header_bar_update_window_buttons (CTK_HEADER_BAR (priv->title_box)((((CtkHeaderBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->title_box)), ((ctk_header_bar_get_type ()))))))); | |||
| 6070 | } | |||
| 6071 | ||||
| 6072 | static CtkWidget * | |||
| 6073 | create_titlebar (CtkWindow *window) | |||
| 6074 | { | |||
| 6075 | CtkWindowPrivate *priv = window->priv; | |||
| 6076 | CtkWidget *titlebar; | |||
| 6077 | CtkStyleContext *context; | |||
| 6078 | ||||
| 6079 | titlebar = ctk_header_bar_new (); | |||
| 6080 | g_object_set (titlebar, | |||
| 6081 | "title", priv->title ? priv->title : get_default_title (), | |||
| 6082 | "has-subtitle", FALSE(0), | |||
| 6083 | "show-close-button", TRUE(!(0)), | |||
| 6084 | NULL((void*)0)); | |||
| 6085 | context = ctk_widget_get_style_context (titlebar); | |||
| 6086 | ctk_style_context_add_class (context, CTK_STYLE_CLASS_TITLEBAR"titlebar"); | |||
| 6087 | ctk_style_context_add_class (context, "default-decoration"); | |||
| 6088 | ||||
| 6089 | return titlebar; | |||
| 6090 | } | |||
| 6091 | ||||
| 6092 | void | |||
| 6093 | _ctk_window_request_csd (CtkWindow *window) | |||
| 6094 | { | |||
| 6095 | CtkWindowPrivate *priv = window->priv; | |||
| 6096 | ||||
| 6097 | priv->csd_requested = TRUE(!(0)); | |||
| 6098 | } | |||
| 6099 | ||||
| 6100 | static gboolean | |||
| 6101 | ctk_window_should_use_csd (CtkWindow *window) | |||
| 6102 | { | |||
| 6103 | CtkWindowPrivate *priv = window->priv; | |||
| 6104 | const gchar *csd_env; | |||
| 6105 | ||||
| 6106 | if (priv->csd_requested) | |||
| 6107 | return TRUE(!(0)); | |||
| 6108 | ||||
| 6109 | if (!priv->decorated) | |||
| 6110 | return FALSE(0); | |||
| 6111 | ||||
| 6112 | if (priv->type == CTK_WINDOW_POPUP) | |||
| 6113 | return FALSE(0); | |||
| 6114 | ||||
| 6115 | csd_env = g_getenv ("CTK_CSD"); | |||
| 6116 | ||||
| 6117 | #ifdef CDK_WINDOWING_BROADWAY | |||
| 6118 | if (CDK_IS_BROADWAY_DISPLAY (ctk_widget_get_display (CTK_WIDGET (window)))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ())))))) ))); GType _t = ((cdk_broadway_display_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; }))))) | |||
| 6119 | return TRUE(!(0)); | |||
| 6120 | #endif | |||
| 6121 | ||||
| 6122 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 6123 | if (CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (CTK_WIDGET (window)))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ())))))) ))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 6124 | { | |||
| 6125 | CdkDisplay *cdk_display = ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 6126 | return !cdk_wayland_display_prefers_ssd (cdk_display); | |||
| 6127 | } | |||
| 6128 | #endif | |||
| 6129 | ||||
| 6130 | #ifdef CDK_WINDOWING_WIN32 | |||
| 6131 | if (g_strcmp0 (csd_env, "0") != 0 && | |||
| 6132 | CDK_IS_WIN32_DISPLAY (ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))))) | |||
| 6133 | return TRUE(!(0)); | |||
| 6134 | #endif | |||
| 6135 | ||||
| 6136 | return (g_strcmp0 (csd_env, "1") == 0); | |||
| 6137 | } | |||
| 6138 | ||||
| 6139 | static void | |||
| 6140 | create_decoration (CtkWidget *widget) | |||
| 6141 | { | |||
| 6142 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 6143 | CtkWindowPrivate *priv = window->priv; | |||
| 6144 | ||||
| 6145 | priv->use_client_shadow = ctk_window_supports_client_shadow (window); | |||
| 6146 | if (!priv->use_client_shadow) | |||
| 6147 | return; | |||
| 6148 | ||||
| 6149 | ctk_window_enable_csd (window); | |||
| 6150 | ||||
| 6151 | if (priv->type == CTK_WINDOW_POPUP) | |||
| 6152 | return; | |||
| 6153 | ||||
| 6154 | if (priv->title_box == NULL((void*)0)) | |||
| 6155 | { | |||
| 6156 | priv->titlebar = create_titlebar (window); | |||
| 6157 | ctk_widget_set_parent (priv->titlebar, widget); | |||
| 6158 | ctk_widget_show_all (priv->titlebar); | |||
| 6159 | priv->title_box = priv->titlebar; | |||
| 6160 | } | |||
| 6161 | ||||
| 6162 | update_window_buttons (window); | |||
| 6163 | } | |||
| 6164 | ||||
| 6165 | static void | |||
| 6166 | ctk_window_show (CtkWidget *widget) | |||
| 6167 | { | |||
| 6168 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 6169 | CtkWindowPrivate *priv = window->priv; | |||
| 6170 | CtkContainer *container = CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))); | |||
| 6171 | gboolean is_plug; | |||
| 6172 | ||||
| 6173 | if (!_ctk_widget_is_toplevel (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_widget_get_type ())))))))) | |||
| 6174 | { | |||
| 6175 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->show (widget); | |||
| 6176 | return; | |||
| 6177 | } | |||
| 6178 | ||||
| 6179 | _ctk_widget_set_visible_flag (widget, TRUE(!(0))); | |||
| 6180 | ||||
| 6181 | ctk_css_node_validate (ctk_widget_get_css_node (widget)); | |||
| 6182 | ||||
| 6183 | ctk_widget_realize (widget); | |||
| 6184 | ||||
| 6185 | ctk_container_check_resize (container); | |||
| 6186 | ||||
| 6187 | ctk_widget_map (widget); | |||
| 6188 | ||||
| 6189 | /* Try to make sure that we have some focused widget | |||
| 6190 | */ | |||
| 6191 | #ifdef CDK_WINDOWING_X11 | |||
| 6192 | is_plug = CDK_IS_X11_WINDOW (_ctk_widget_get_window (widget))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (_ctk_widget_get_window (widget))); GType _t = ((cdk_x11_window_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; } )))) && | |||
| 6193 | CTK_IS_PLUG (window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (window)); GType _t = ((ctk_plug_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; })))); | |||
| 6194 | #else | |||
| 6195 | is_plug = FALSE(0); | |||
| 6196 | #endif | |||
| 6197 | if (!priv->focus_widget && !is_plug) | |||
| 6198 | { | |||
| 6199 | if (priv->initial_focus) | |||
| 6200 | ctk_window_set_focus (window, priv->initial_focus); | |||
| 6201 | else | |||
| 6202 | ctk_window_move_focus (widget, CTK_DIR_TAB_FORWARD); | |||
| 6203 | } | |||
| 6204 | ||||
| 6205 | if (priv->modal) | |||
| 6206 | ctk_grab_add (widget); | |||
| 6207 | } | |||
| 6208 | ||||
| 6209 | static void | |||
| 6210 | ctk_window_hide (CtkWidget *widget) | |||
| 6211 | { | |||
| 6212 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 6213 | CtkWindowPrivate *priv = window->priv; | |||
| 6214 | ||||
| 6215 | if (!_ctk_widget_is_toplevel (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_widget_get_type ())))))))) | |||
| 6216 | { | |||
| 6217 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->hide (widget); | |||
| 6218 | return; | |||
| 6219 | } | |||
| 6220 | ||||
| 6221 | _ctk_widget_set_visible_flag (widget, FALSE(0)); | |||
| 6222 | ctk_widget_unmap (widget); | |||
| 6223 | ||||
| 6224 | if (priv->modal) | |||
| 6225 | ctk_grab_remove (widget); | |||
| 6226 | } | |||
| 6227 | ||||
| 6228 | static void | |||
| 6229 | popover_unmap (CtkWidget *widget, | |||
| 6230 | CtkWindowPopover *popover) | |||
| 6231 | { | |||
| 6232 | if (popover->unmap_id) | |||
| 6233 | { | |||
| 6234 | g_signal_handler_disconnect (widget, popover->unmap_id); | |||
| 6235 | popover->unmap_id = 0; | |||
| 6236 | } | |||
| 6237 | ||||
| 6238 | if (popover->window) | |||
| 6239 | { | |||
| 6240 | cdk_window_hide (popover->window); | |||
| 6241 | ctk_widget_unmap (popover->widget); | |||
| 6242 | } | |||
| 6243 | } | |||
| 6244 | ||||
| 6245 | static void | |||
| 6246 | popover_map (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 6247 | CtkWindowPopover *popover) | |||
| 6248 | { | |||
| 6249 | if (popover->window && ctk_widget_get_visible (popover->widget)) | |||
| 6250 | { | |||
| 6251 | cdk_window_show_unraised (popover->window); | |||
| 6252 | ctk_widget_map (popover->widget); | |||
| 6253 | popover->unmap_id = g_signal_connect (popover->widget, "unmap",g_signal_connect_data ((popover->widget), ("unmap"), (((GCallback ) (popover_unmap))), (popover), ((void*)0), (GConnectFlags) 0 ) | |||
| 6254 | G_CALLBACK (popover_unmap), popover)g_signal_connect_data ((popover->widget), ("unmap"), (((GCallback ) (popover_unmap))), (popover), ((void*)0), (GConnectFlags) 0 ); | |||
| 6255 | } | |||
| 6256 | } | |||
| 6257 | ||||
| 6258 | static void | |||
| 6259 | ctk_window_map (CtkWidget *widget) | |||
| 6260 | { | |||
| 6261 | CtkWidget *child; | |||
| 6262 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 6263 | CtkWindowPrivate *priv = window->priv; | |||
| 6264 | CdkWindow *cdk_window; | |||
| 6265 | GList *link; | |||
| 6266 | CdkDisplay *display; | |||
| 6267 | ||||
| 6268 | if (!_ctk_widget_is_toplevel (widget)) | |||
| 6269 | { | |||
| 6270 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->map (widget); | |||
| 6271 | return; | |||
| 6272 | } | |||
| 6273 | ||||
| 6274 | display = ctk_widget_get_display (widget); | |||
| 6275 | if (priv->initial_fullscreen_monitor > cdk_display_get_n_monitors (display)) | |||
| 6276 | priv->initial_fullscreen_monitor = -1; | |||
| 6277 | ||||
| 6278 | ctk_widget_set_mapped (widget, TRUE(!(0))); | |||
| 6279 | ||||
| 6280 | child = ctk_bin_get_child (&(window->bin)); | |||
| 6281 | if (child != NULL((void*)0) && ctk_widget_get_visible (child)) | |||
| 6282 | ctk_widget_map (child); | |||
| 6283 | ||||
| 6284 | if (priv->title_box != NULL((void*)0) && | |||
| 6285 | ctk_widget_get_visible (priv->title_box) && | |||
| 6286 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 6287 | ctk_widget_map (priv->title_box); | |||
| 6288 | ||||
| 6289 | cdk_window = _ctk_widget_get_window (widget); | |||
| 6290 | ||||
| 6291 | if (priv->maximize_initially) | |||
| 6292 | cdk_window_maximize (cdk_window); | |||
| 6293 | else | |||
| 6294 | cdk_window_unmaximize (cdk_window); | |||
| 6295 | ||||
| 6296 | if (priv->stick_initially) | |||
| 6297 | cdk_window_stick (cdk_window); | |||
| 6298 | else | |||
| 6299 | cdk_window_unstick (cdk_window); | |||
| 6300 | ||||
| 6301 | if (priv->iconify_initially) | |||
| 6302 | cdk_window_iconify (cdk_window); | |||
| 6303 | else | |||
| 6304 | cdk_window_deiconify (cdk_window); | |||
| 6305 | ||||
| 6306 | if (priv->fullscreen_initially) | |||
| 6307 | { | |||
| 6308 | if (priv->initial_fullscreen_monitor < 0) | |||
| 6309 | cdk_window_fullscreen (cdk_window); | |||
| 6310 | else | |||
| 6311 | cdk_window_fullscreen_on_monitor (cdk_window, | |||
| 6312 | priv->initial_fullscreen_monitor); | |||
| 6313 | } | |||
| 6314 | else | |||
| 6315 | cdk_window_unfullscreen (cdk_window); | |||
| 6316 | ||||
| 6317 | cdk_window_set_keep_above (cdk_window, priv->above_initially); | |||
| 6318 | ||||
| 6319 | cdk_window_set_keep_below (cdk_window, priv->below_initially); | |||
| 6320 | ||||
| 6321 | if (priv->type == CTK_WINDOW_TOPLEVEL) | |||
| 6322 | { | |||
| 6323 | ctk_window_set_theme_variant (window); | |||
| 6324 | ctk_window_apply_hide_titlebar_when_maximized (window); | |||
| 6325 | } | |||
| 6326 | ||||
| 6327 | /* No longer use the default settings */ | |||
| 6328 | priv->need_default_size = FALSE(0); | |||
| 6329 | priv->need_default_position = FALSE(0); | |||
| 6330 | ||||
| 6331 | cdk_window_show (cdk_window); | |||
| 6332 | ||||
| 6333 | if (!disable_startup_notification && | |||
| 6334 | !CTK_IS_OFFSCREEN_WINDOW (window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (window)); GType _t = ((ctk_offscreen_window_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; })))) && | |||
| 6335 | priv->type != CTK_WINDOW_POPUP) | |||
| 6336 | { | |||
| 6337 | /* Do we have a custom startup-notification id? */ | |||
| 6338 | if (priv->startup_id != NULL((void*)0)) | |||
| 6339 | { | |||
| 6340 | /* Make sure we have a "real" id */ | |||
| 6341 | if (!startup_id_is_fake (priv->startup_id)) | |||
| 6342 | cdk_notify_startup_complete_with_id (priv->startup_id); | |||
| 6343 | ||||
| 6344 | g_free (priv->startup_id)(__builtin_object_size ((priv->startup_id), 0) != ((size_t ) - 1)) ? g_free_sized (priv->startup_id, __builtin_object_size ((priv->startup_id), 0)) : (g_free) (priv->startup_id); | |||
| 6345 | priv->startup_id = NULL((void*)0); | |||
| 6346 | } | |||
| 6347 | else | |||
| 6348 | { | |||
| 6349 | cdk_notify_startup_complete (); | |||
| 6350 | } | |||
| 6351 | } | |||
| 6352 | ||||
| 6353 | /* if mnemonics visible is not already set | |||
| 6354 | * (as in the case of popup menus), then hide mnemonics initially | |||
| 6355 | */ | |||
| 6356 | if (!priv->mnemonics_visible_set) | |||
| 6357 | ctk_window_set_mnemonics_visible (window, FALSE(0)); | |||
| 6358 | ||||
| 6359 | /* inherit from transient parent, so that a dialog that is | |||
| 6360 | * opened via keynav shows focus initially | |||
| 6361 | */ | |||
| 6362 | if (priv->transient_parent) | |||
| 6363 | ctk_window_set_focus_visible (window, ctk_window_get_focus_visible (priv->transient_parent)); | |||
| 6364 | else | |||
| 6365 | ctk_window_set_focus_visible (window, FALSE(0)); | |||
| 6366 | ||||
| 6367 | if (priv->application) | |||
| 6368 | ctk_application_handle_window_map (priv->application, window); | |||
| 6369 | ||||
| 6370 | link = priv->popovers; | |||
| 6371 | ||||
| 6372 | while (link) | |||
| 6373 | { | |||
| 6374 | CtkWindowPopover *popover = link->data; | |||
| 6375 | link = link->next; | |||
| 6376 | popover_map (popover->widget, popover); | |||
| 6377 | } | |||
| 6378 | } | |||
| 6379 | ||||
| 6380 | static gboolean | |||
| 6381 | ctk_window_map_event (CtkWidget *widget, | |||
| 6382 | CdkEventAny *event G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 6383 | { | |||
| 6384 | if (!_ctk_widget_get_mapped (widget)) | |||
| 6385 | { | |||
| 6386 | /* we should be be unmapped, but are getting a MapEvent, this may happen | |||
| 6387 | * to toplevel XWindows if mapping was intercepted by a window manager | |||
| 6388 | * and an unmap request occoured while the MapRequestEvent was still | |||
| 6389 | * being handled. we work around this situaiton here by re-requesting | |||
| 6390 | * the window being unmapped. more details can be found in: | |||
| 6391 | * http://bugzilla.gnome.org/show_bug.cgi?id=316180 | |||
| 6392 | */ | |||
| 6393 | cdk_window_hide (_ctk_widget_get_window (widget)); | |||
| 6394 | } | |||
| 6395 | return FALSE(0); | |||
| 6396 | } | |||
| 6397 | ||||
| 6398 | static void | |||
| 6399 | ctk_window_unmap (CtkWidget *widget) | |||
| 6400 | { | |||
| 6401 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 6402 | CtkWindowPrivate *priv = window->priv; | |||
| 6403 | CtkWidget *child; | |||
| 6404 | CtkWindowGeometryInfo *info; | |||
| 6405 | CdkWindow *cdk_window; | |||
| 6406 | CdkWindowState state; | |||
| 6407 | GList *link; | |||
| 6408 | ||||
| 6409 | if (!_ctk_widget_is_toplevel (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_widget_get_type ())))))))) | |||
| 6410 | { | |||
| 6411 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->unmap (widget); | |||
| 6412 | return; | |||
| 6413 | } | |||
| 6414 | ||||
| 6415 | link = priv->popovers; | |||
| 6416 | ||||
| 6417 | while (link) | |||
| 6418 | { | |||
| 6419 | CtkWindowPopover *popover = link->data; | |||
| 6420 | link = link->next; | |||
| 6421 | popover_unmap (popover->widget, popover); | |||
| 6422 | } | |||
| 6423 | ||||
| 6424 | cdk_window = _ctk_widget_get_window (widget); | |||
| 6425 | ||||
| 6426 | ctk_widget_set_mapped (widget, FALSE(0)); | |||
| 6427 | cdk_window_withdraw (cdk_window); | |||
| 6428 | ||||
| 6429 | while (priv->configure_request_count > 0) | |||
| 6430 | { | |||
| 6431 | priv->configure_request_count--; | |||
| 6432 | CDK_PRIVATE_CALL (cdk_window_thaw_toplevel_updates)(cdk__private__ ()->cdk_window_thaw_toplevel_updates) (_ctk_widget_get_window (widget)); | |||
| 6433 | } | |||
| 6434 | priv->configure_notify_received = FALSE(0); | |||
| 6435 | ||||
| 6436 | /* on unmap, we reset the default positioning of the window, | |||
| 6437 | * so it's placed again, but we don't reset the default | |||
| 6438 | * size of the window, so it's remembered. | |||
| 6439 | */ | |||
| 6440 | priv->need_default_position = TRUE(!(0)); | |||
| 6441 | ||||
| 6442 | priv->fixate_size = FALSE(0); | |||
| 6443 | ||||
| 6444 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 6445 | if (info) | |||
| 6446 | { | |||
| 6447 | info->initial_pos_set = FALSE(0); | |||
| 6448 | info->position_constraints_changed = FALSE(0); | |||
| 6449 | } | |||
| 6450 | ||||
| 6451 | state = cdk_window_get_state (cdk_window); | |||
| 6452 | priv->iconify_initially = (state & CDK_WINDOW_STATE_ICONIFIED) != 0; | |||
| 6453 | priv->maximize_initially = (state & CDK_WINDOW_STATE_MAXIMIZED) != 0; | |||
| 6454 | priv->stick_initially = (state & CDK_WINDOW_STATE_STICKY) != 0; | |||
| 6455 | priv->above_initially = (state & CDK_WINDOW_STATE_ABOVE) != 0; | |||
| 6456 | priv->below_initially = (state & CDK_WINDOW_STATE_BELOW) != 0; | |||
| 6457 | ||||
| 6458 | if (priv->title_box != NULL((void*)0)) | |||
| 6459 | ctk_widget_unmap (priv->title_box); | |||
| 6460 | ||||
| 6461 | child = ctk_bin_get_child (&(window->bin)); | |||
| 6462 | if (child != NULL((void*)0)) | |||
| 6463 | ctk_widget_unmap (child); | |||
| 6464 | } | |||
| 6465 | ||||
| 6466 | void | |||
| 6467 | ctk_window_set_unlimited_guessed_size (CtkWindow *window, | |||
| 6468 | gboolean x, | |||
| 6469 | gboolean y) | |||
| 6470 | { | |||
| 6471 | CtkWindowPrivate *priv = window->priv; | |||
| 6472 | ||||
| 6473 | priv->unlimited_guessed_size_x = x; | |||
| 6474 | priv->unlimited_guessed_size_y = y; | |||
| 6475 | } | |||
| 6476 | ||||
| 6477 | void | |||
| 6478 | ctk_window_force_resize (CtkWindow *window) | |||
| 6479 | { | |||
| 6480 | CtkWindowPrivate *priv = window->priv; | |||
| 6481 | ||||
| 6482 | priv->force_resize = TRUE(!(0)); | |||
| 6483 | } | |||
| 6484 | ||||
| 6485 | void | |||
| 6486 | ctk_window_fixate_size (CtkWindow *window) | |||
| 6487 | { | |||
| 6488 | CtkWindowPrivate *priv = window->priv; | |||
| 6489 | ||||
| 6490 | priv->fixate_size = TRUE(!(0)); | |||
| 6491 | } | |||
| 6492 | ||||
| 6493 | /* (Note: Replace "size" with "width" or "height". Also, the request | |||
| 6494 | * mode is honoured.) | |||
| 6495 | * For selecting the default window size, the following conditions | |||
| 6496 | * should hold (in order of importance): | |||
| 6497 | * - the size is not below the minimum size | |||
| 6498 | * Windows cannot be resized below their minimum size, so we must | |||
| 6499 | * ensure we don’t do that either. | |||
| 6500 | * - the size is not above the natural size | |||
| 6501 | * It seems weird to allocate more than this in an initial guess. | |||
| 6502 | * - the size does not exceed that of a maximized window | |||
| 6503 | * We want to see the whole window after all. | |||
| 6504 | * (Note that this may not be possible to achieve due to imperfect | |||
| 6505 | * information from the windowing system.) | |||
| 6506 | */ | |||
| 6507 | ||||
| 6508 | static void | |||
| 6509 | ctk_window_guess_default_size (CtkWindow *window, | |||
| 6510 | gint *width, | |||
| 6511 | gint *height) | |||
| 6512 | { | |||
| 6513 | CtkWidget *widget; | |||
| 6514 | CdkDisplay *display; | |||
| 6515 | CdkWindow *cdkwindow; | |||
| 6516 | CdkMonitor *monitor; | |||
| 6517 | CdkRectangle workarea; | |||
| 6518 | int minimum, natural; | |||
| 6519 | ||||
| 6520 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 6521 | display = ctk_widget_get_display (widget); | |||
| 6522 | cdkwindow = _ctk_widget_get_window (widget); | |||
| 6523 | ||||
| 6524 | if (window->priv->fixate_size) | |||
| 6525 | { | |||
| 6526 | g_assert (cdkwindow)do { if (cdkwindow) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c" , 6526, ((const char*) (__func__)), "cdkwindow"); } while (0); | |||
| 6527 | ctk_window_get_remembered_size (window, width, height); | |||
| 6528 | return; | |||
| 6529 | } | |||
| 6530 | ||||
| 6531 | if (cdkwindow) | |||
| 6532 | monitor = cdk_display_get_monitor_at_window (display, cdkwindow); | |||
| 6533 | else | |||
| 6534 | monitor = cdk_display_get_monitor (display, 0); | |||
| 6535 | ||||
| 6536 | cdk_monitor_get_workarea (monitor, &workarea); | |||
| 6537 | ||||
| 6538 | if (window->priv->unlimited_guessed_size_x) | |||
| 6539 | *width = INT_MAX2147483647; | |||
| 6540 | else | |||
| 6541 | *width = workarea.width; | |||
| 6542 | ||||
| 6543 | if (window->priv->unlimited_guessed_size_y) | |||
| 6544 | *height = INT_MAX2147483647; | |||
| 6545 | else | |||
| 6546 | *height = workarea.height; | |||
| 6547 | ||||
| 6548 | if (ctk_widget_get_request_mode (widget) == CTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT) | |||
| 6549 | { | |||
| 6550 | ctk_widget_get_preferred_height (widget, &minimum, &natural); | |||
| 6551 | *height = MAX (minimum, MIN (*height, natural))(((minimum) > ((((*height) < (natural)) ? (*height) : ( natural)))) ? (minimum) : ((((*height) < (natural)) ? (*height ) : (natural)))); | |||
| 6552 | ||||
| 6553 | ctk_widget_get_preferred_width_for_height (widget, *height, &minimum, &natural); | |||
| 6554 | *width = MAX (minimum, MIN (*width, natural))(((minimum) > ((((*width) < (natural)) ? (*width) : (natural )))) ? (minimum) : ((((*width) < (natural)) ? (*width) : ( natural)))); | |||
| 6555 | } | |||
| 6556 | else /* CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or CONSTANT_SIZE */ | |||
| 6557 | { | |||
| 6558 | ctk_widget_get_preferred_width (widget, &minimum, &natural); | |||
| 6559 | *width = MAX (minimum, MIN (*width, natural))(((minimum) > ((((*width) < (natural)) ? (*width) : (natural )))) ? (minimum) : ((((*width) < (natural)) ? (*width) : ( natural)))); | |||
| 6560 | ||||
| 6561 | ctk_widget_get_preferred_height_for_width (widget, *width, &minimum, &natural); | |||
| 6562 | *height = MAX (minimum, MIN (*height, natural))(((minimum) > ((((*height) < (natural)) ? (*height) : ( natural)))) ? (minimum) : ((((*height) < (natural)) ? (*height ) : (natural)))); | |||
| 6563 | } | |||
| 6564 | } | |||
| 6565 | ||||
| 6566 | static void | |||
| 6567 | ctk_window_get_remembered_size (CtkWindow *window, | |||
| 6568 | int *width, | |||
| 6569 | int *height) | |||
| 6570 | { | |||
| 6571 | CtkWindowGeometryInfo *info; | |||
| 6572 | CdkWindow *cdk_window; | |||
| 6573 | ||||
| 6574 | *width = 0; | |||
| 6575 | *height = 0; | |||
| 6576 | ||||
| 6577 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 6578 | if (cdk_window) | |||
| 6579 | { | |||
| 6580 | *width = cdk_window_get_width (cdk_window); | |||
| 6581 | *height = cdk_window_get_height (cdk_window); | |||
| 6582 | return; | |||
| 6583 | } | |||
| 6584 | ||||
| 6585 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 6586 | if (info) | |||
| 6587 | { | |||
| 6588 | /* MAX() works even if the last request is unset with -1 */ | |||
| 6589 | *width = MAX (*width, info->last.configure_request.width)(((*width) > (info->last.configure_request.width)) ? (* width) : (info->last.configure_request.width)); | |||
| 6590 | *height = MAX (*height, info->last.configure_request.height)(((*height) > (info->last.configure_request.height)) ? ( *height) : (info->last.configure_request.height)); | |||
| 6591 | } | |||
| 6592 | } | |||
| 6593 | ||||
| 6594 | static void | |||
| 6595 | popover_get_rect (CtkWindowPopover *popover, | |||
| 6596 | CtkWindow *window, | |||
| 6597 | cairo_rectangle_int_t *rect) | |||
| 6598 | { | |||
| 6599 | CtkAllocation win_alloc; | |||
| 6600 | CtkRequisition req; | |||
| 6601 | CtkBorder win_border; | |||
| 6602 | gdouble min, max; | |||
| 6603 | ||||
| 6604 | ctk_widget_get_preferred_size (popover->widget, NULL((void*)0), &req); | |||
| 6605 | _ctk_widget_get_allocation (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), &win_alloc); | |||
| 6606 | ||||
| 6607 | get_shadow_width (window, &win_border); | |||
| 6608 | win_alloc.x += win_border.left; | |||
| 6609 | win_alloc.y += win_border.top; | |||
| 6610 | win_alloc.width -= win_border.left + win_border.right; | |||
| 6611 | win_alloc.height -= win_border.top + win_border.bottom; | |||
| 6612 | ||||
| 6613 | rect->width = req.width; | |||
| 6614 | rect->height = req.height; | |||
| 6615 | ||||
| 6616 | if (popover->pos == CTK_POS_LEFT || popover->pos == CTK_POS_RIGHT) | |||
| 6617 | { | |||
| 6618 | if (req.height < win_alloc.height && | |||
| 6619 | ctk_widget_get_vexpand (popover->widget)) | |||
| 6620 | { | |||
| 6621 | rect->y = win_alloc.y; | |||
| 6622 | rect->height = win_alloc.height; | |||
| 6623 | } | |||
| 6624 | else | |||
| 6625 | { | |||
| 6626 | min = 0; | |||
| 6627 | max = win_alloc.y + win_alloc.height + win_border.bottom - req.height; | |||
| 6628 | ||||
| 6629 | if (popover->clamp_allocation) | |||
| 6630 | { | |||
| 6631 | min += win_border.top; | |||
| 6632 | max -= win_border.bottom; | |||
| 6633 | } | |||
| 6634 | ||||
| 6635 | rect->y = CLAMP (popover->rect.y + (popover->rect.height / 2) -(((popover->rect.y + (popover->rect.height / 2) - (req. height / 2)) > (max)) ? (max) : (((popover->rect.y + (popover ->rect.height / 2) - (req.height / 2)) < (min)) ? (min) : (popover->rect.y + (popover->rect.height / 2) - (req .height / 2)))) | |||
| 6636 | (req.height / 2), min, max)(((popover->rect.y + (popover->rect.height / 2) - (req. height / 2)) > (max)) ? (max) : (((popover->rect.y + (popover ->rect.height / 2) - (req.height / 2)) < (min)) ? (min) : (popover->rect.y + (popover->rect.height / 2) - (req .height / 2)))); | |||
| 6637 | } | |||
| 6638 | ||||
| 6639 | if ((popover->pos == CTK_POS_LEFT) == | |||
| 6640 | (ctk_widget_get_direction (popover->widget) == CTK_TEXT_DIR_LTR)) | |||
| 6641 | { | |||
| 6642 | rect->x = popover->rect.x - req.width; | |||
| 6643 | ||||
| 6644 | if (rect->x > win_alloc.x && ctk_widget_get_hexpand (popover->widget)) | |||
| 6645 | { | |||
| 6646 | rect->x = win_alloc.x; | |||
| 6647 | rect->width = popover->rect.x; | |||
| 6648 | } | |||
| 6649 | } | |||
| 6650 | else | |||
| 6651 | { | |||
| 6652 | rect->x = popover->rect.x + popover->rect.width; | |||
| 6653 | ||||
| 6654 | if (rect->x + rect->width < win_alloc.x + win_alloc.width && | |||
| 6655 | ctk_widget_get_hexpand (popover->widget)) | |||
| 6656 | rect->width = win_alloc.x + win_alloc.width - rect->x; | |||
| 6657 | } | |||
| 6658 | } | |||
| 6659 | else if (popover->pos == CTK_POS_TOP || popover->pos == CTK_POS_BOTTOM) | |||
| 6660 | { | |||
| 6661 | if (req.width < win_alloc.width && | |||
| 6662 | ctk_widget_get_hexpand (popover->widget)) | |||
| 6663 | { | |||
| 6664 | rect->x = win_alloc.x; | |||
| 6665 | rect->width = win_alloc.width; | |||
| 6666 | } | |||
| 6667 | else | |||
| 6668 | { | |||
| 6669 | min = 0; | |||
| 6670 | max = win_alloc.x + win_alloc.width + win_border.right - req.width; | |||
| 6671 | ||||
| 6672 | if (popover->clamp_allocation) | |||
| 6673 | { | |||
| 6674 | min += win_border.left; | |||
| 6675 | max -= win_border.right; | |||
| 6676 | } | |||
| 6677 | ||||
| 6678 | rect->x = CLAMP (popover->rect.x + (popover->rect.width / 2) -(((popover->rect.x + (popover->rect.width / 2) - (req.width / 2)) > (max)) ? (max) : (((popover->rect.x + (popover ->rect.width / 2) - (req.width / 2)) < (min)) ? (min) : (popover->rect.x + (popover->rect.width / 2) - (req.width / 2)))) | |||
| 6679 | (req.width / 2), min, max)(((popover->rect.x + (popover->rect.width / 2) - (req.width / 2)) > (max)) ? (max) : (((popover->rect.x + (popover ->rect.width / 2) - (req.width / 2)) < (min)) ? (min) : (popover->rect.x + (popover->rect.width / 2) - (req.width / 2)))); | |||
| 6680 | } | |||
| 6681 | ||||
| 6682 | if (popover->pos == CTK_POS_TOP) | |||
| 6683 | { | |||
| 6684 | rect->y = popover->rect.y - req.height; | |||
| 6685 | ||||
| 6686 | if (rect->y > win_alloc.y && | |||
| 6687 | ctk_widget_get_vexpand (popover->widget)) | |||
| 6688 | { | |||
| 6689 | rect->y = win_alloc.y; | |||
| 6690 | rect->height = popover->rect.y; | |||
| 6691 | } | |||
| 6692 | } | |||
| 6693 | else | |||
| 6694 | { | |||
| 6695 | rect->y = popover->rect.y + popover->rect.height; | |||
| 6696 | ||||
| 6697 | if (rect->y + rect->height < win_alloc.y + win_alloc.height && | |||
| 6698 | ctk_widget_get_vexpand (popover->widget)) | |||
| 6699 | rect->height = win_alloc.y + win_alloc.height - rect->y; | |||
| 6700 | } | |||
| 6701 | } | |||
| 6702 | } | |||
| 6703 | ||||
| 6704 | static void | |||
| 6705 | popover_realize (CtkWidget *widget, | |||
| 6706 | CtkWindowPopover *popover, | |||
| 6707 | CtkWindow *window) | |||
| 6708 | { | |||
| 6709 | cairo_rectangle_int_t rect; | |||
| 6710 | CdkWindow *parent_window; | |||
| 6711 | CdkWindowAttr attributes; | |||
| 6712 | gint attributes_mask; | |||
| 6713 | ||||
| 6714 | if (popover->window
| |||
| 6715 | return; | |||
| 6716 | ||||
| 6717 | popover_get_rect (popover, window, &rect); | |||
| 6718 | ||||
| 6719 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 6720 | if (CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (widget))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 6721 | { | |||
| 6722 | attributes.window_type = CDK_WINDOW_SUBSURFACE; | |||
| 6723 | parent_window = cdk_screen_get_root_window (_ctk_window_get_screen (window)); | |||
| 6724 | } | |||
| 6725 | else | |||
| 6726 | #endif | |||
| 6727 | { | |||
| 6728 | attributes.window_type = CDK_WINDOW_CHILD; | |||
| 6729 | parent_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 6730 | } | |||
| 6731 | ||||
| 6732 | attributes.wclass = CDK_INPUT_OUTPUT; | |||
| 6733 | attributes.x = rect.x; | |||
| ||||
| 6734 | attributes.y = rect.y; | |||
| 6735 | attributes.width = rect.width; | |||
| 6736 | attributes.height = rect.height; | |||
| 6737 | attributes.visual = ctk_widget_get_visual (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 6738 | attributes.event_mask = ctk_widget_get_events (popover->widget) | | |||
| 6739 | CDK_EXPOSURE_MASK; | |||
| 6740 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; | |||
| 6741 | ||||
| 6742 | popover->window = cdk_window_new (parent_window, &attributes, attributes_mask); | |||
| 6743 | ctk_widget_register_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), popover->window); | |||
| 6744 | ||||
| 6745 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 6746 | if (CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (widget))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 6747 | cdk_window_set_transient_for (popover->window, | |||
| 6748 | _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
| 6749 | #endif | |||
| 6750 | ||||
| 6751 | ctk_widget_set_parent_window (popover->widget, popover->window); | |||
| 6752 | } | |||
| 6753 | ||||
| 6754 | static void | |||
| 6755 | check_scale_changed (CtkWindow *window) | |||
| 6756 | { | |||
| 6757 | CtkWindowPrivate *priv = window->priv; | |||
| 6758 | CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 6759 | int old_scale; | |||
| 6760 | ||||
| 6761 | old_scale = priv->scale; | |||
| 6762 | priv->scale = ctk_widget_get_scale_factor (widget); | |||
| 6763 | if (old_scale != priv->scale) | |||
| 6764 | _ctk_widget_scale_changed (widget); | |||
| 6765 | } | |||
| 6766 | ||||
| 6767 | static void | |||
| 6768 | sum_borders (CtkBorder *one, | |||
| 6769 | CtkBorder *two) | |||
| 6770 | { | |||
| 6771 | one->top += two->top; | |||
| 6772 | one->right += two->right; | |||
| 6773 | one->bottom += two->bottom; | |||
| 6774 | one->left += two->left; | |||
| 6775 | } | |||
| 6776 | ||||
| 6777 | static void | |||
| 6778 | max_borders (CtkBorder *one, | |||
| 6779 | CtkBorder *two) | |||
| 6780 | { | |||
| 6781 | one->top = MAX (one->top, two->top)(((one->top) > (two->top)) ? (one->top) : (two-> top)); | |||
| 6782 | one->right = MAX (one->right, two->right)(((one->right) > (two->right)) ? (one->right) : ( two->right)); | |||
| 6783 | one->bottom = MAX (one->bottom, two->bottom)(((one->bottom) > (two->bottom)) ? (one->bottom) : (two->bottom)); | |||
| 6784 | one->left = MAX (one->left, two->left)(((one->left) > (two->left)) ? (one->left) : (two ->left)); | |||
| 6785 | } | |||
| 6786 | ||||
| 6787 | static void | |||
| 6788 | subtract_borders (CtkBorder *one, | |||
| 6789 | CtkBorder *two) | |||
| 6790 | { | |||
| 6791 | one->top -= two->top; | |||
| 6792 | one->right -= two->right; | |||
| 6793 | one->bottom -= two->bottom; | |||
| 6794 | one->left -= two->left; | |||
| 6795 | } | |||
| 6796 | ||||
| 6797 | static void | |||
| 6798 | get_shadow_width (CtkWindow *window, | |||
| 6799 | CtkBorder *shadow_width) | |||
| 6800 | { | |||
| 6801 | CtkWindowPrivate *priv = window->priv; | |||
| 6802 | CtkBorder border = { 0 }; | |||
| 6803 | CtkBorder d = { 0 }; | |||
| 6804 | CtkBorder margin; | |||
| 6805 | CtkStyleContext *context; | |||
| 6806 | CtkStateFlags s; | |||
| 6807 | CtkCssValue *shadows; | |||
| 6808 | ||||
| 6809 | *shadow_width = border; | |||
| 6810 | ||||
| 6811 | if (!priv->decorated) | |||
| 6812 | return; | |||
| 6813 | ||||
| 6814 | if (!priv->client_decorated && | |||
| 6815 | !(ctk_window_should_use_csd (window) && | |||
| 6816 | ctk_window_supports_client_shadow (window))) | |||
| 6817 | return; | |||
| 6818 | ||||
| 6819 | if (priv->maximized || | |||
| 6820 | priv->fullscreen) | |||
| 6821 | return; | |||
| 6822 | ||||
| 6823 | if (!_ctk_widget_is_toplevel (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 6824 | return; | |||
| 6825 | ||||
| 6826 | context = _ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 6827 | ||||
| 6828 | ctk_style_context_save_to_node (context, priv->decoration_node); | |||
| 6829 | s = ctk_style_context_get_state (context); | |||
| 6830 | ||||
| 6831 | /* Always sum border + padding */ | |||
| 6832 | ctk_style_context_get_border (context, s, &border); | |||
| 6833 | ctk_style_context_get_padding (context, s, &d); | |||
| 6834 | sum_borders (&d, &border); | |||
| 6835 | ||||
| 6836 | /* Calculate the size of the drop shadows ... */ | |||
| 6837 | shadows = _ctk_style_context_peek_property (context, CTK_CSS_PROPERTY_BOX_SHADOW); | |||
| 6838 | _ctk_css_shadows_value_get_extents (shadows, &border); | |||
| 6839 | ||||
| 6840 | if (priv->type != CTK_WINDOW_POPUP) | |||
| 6841 | { | |||
| 6842 | /* ... and compare it to the margin size, which we use for resize grips */ | |||
| 6843 | ctk_style_context_get_margin (context, s, &margin); | |||
| 6844 | max_borders (&border, &margin); | |||
| 6845 | } | |||
| 6846 | ||||
| 6847 | sum_borders (&d, &border); | |||
| 6848 | *shadow_width = d; | |||
| 6849 | ||||
| 6850 | ctk_style_context_restore (context); | |||
| 6851 | } | |||
| 6852 | ||||
| 6853 | static void | |||
| 6854 | update_corner_windows (CtkWindow *window, | |||
| 6855 | CtkBorder border, | |||
| 6856 | CtkBorder window_border, | |||
| 6857 | gint width, | |||
| 6858 | gint height, | |||
| 6859 | gint handle_h, | |||
| 6860 | gint handle_v, | |||
| 6861 | gboolean resize_n, | |||
| 6862 | gboolean resize_e, | |||
| 6863 | gboolean resize_s, | |||
| 6864 | gboolean resize_w) | |||
| 6865 | { | |||
| 6866 | CtkWindowPrivate *priv = window->priv; | |||
| 6867 | cairo_rectangle_int_t rect; | |||
| 6868 | cairo_region_t *region; | |||
| 6869 | ||||
| 6870 | /* North-West */ | |||
| 6871 | if (resize_n && resize_w) | |||
| 6872 | { | |||
| 6873 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_NORTH_WEST], | |||
| 6874 | window_border.left - border.left, window_border.top - border.top, | |||
| 6875 | border.left + handle_h, border.top + handle_v); | |||
| 6876 | ||||
| 6877 | rect.x = 0; | |||
| 6878 | rect.y = 0; | |||
| 6879 | rect.width = border.left + handle_h; | |||
| 6880 | rect.height = border.top + handle_v; | |||
| 6881 | region = cairo_region_create_rectangle (&rect); | |||
| 6882 | rect.x = border.left; | |||
| 6883 | rect.y = border.top; | |||
| 6884 | rect.width = handle_h; | |||
| 6885 | rect.height = handle_v; | |||
| 6886 | cairo_region_subtract_rectangle (region, &rect); | |||
| 6887 | cdk_window_shape_combine_region (priv->border_window[CDK_WINDOW_EDGE_NORTH_WEST], | |||
| 6888 | region, 0, 0); | |||
| 6889 | cairo_region_destroy (region); | |||
| 6890 | ||||
| 6891 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_NORTH_WEST]); | |||
| 6892 | } | |||
| 6893 | else | |||
| 6894 | { | |||
| 6895 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_NORTH_WEST]); | |||
| 6896 | } | |||
| 6897 | ||||
| 6898 | ||||
| 6899 | /* North-East */ | |||
| 6900 | if (resize_n && resize_e) | |||
| 6901 | { | |||
| 6902 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_NORTH_EAST], | |||
| 6903 | window_border.left + width - handle_h, window_border.top - border.top, | |||
| 6904 | border.right + handle_h, border.top + handle_v); | |||
| 6905 | ||||
| 6906 | rect.x = 0; | |||
| 6907 | rect.y = 0; | |||
| 6908 | rect.width = border.right + handle_h; | |||
| 6909 | rect.height = border.top + handle_v; | |||
| 6910 | region = cairo_region_create_rectangle (&rect); | |||
| 6911 | rect.x = 0; | |||
| 6912 | rect.y = border.top; | |||
| 6913 | rect.width = handle_h; | |||
| 6914 | rect.height = handle_v; | |||
| 6915 | cairo_region_subtract_rectangle (region, &rect); | |||
| 6916 | cdk_window_shape_combine_region (priv->border_window[CDK_WINDOW_EDGE_NORTH_EAST], | |||
| 6917 | region, 0, 0); | |||
| 6918 | cairo_region_destroy (region); | |||
| 6919 | ||||
| 6920 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_NORTH_EAST]); | |||
| 6921 | } | |||
| 6922 | else | |||
| 6923 | { | |||
| 6924 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_NORTH_EAST]); | |||
| 6925 | } | |||
| 6926 | ||||
| 6927 | /* South-West */ | |||
| 6928 | if (resize_s && resize_w) | |||
| 6929 | { | |||
| 6930 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_SOUTH_WEST], | |||
| 6931 | window_border.left - border.left, window_border.top + height - handle_v, | |||
| 6932 | border.left + handle_h, border.bottom + handle_v); | |||
| 6933 | ||||
| 6934 | rect.x = 0; | |||
| 6935 | rect.y = 0; | |||
| 6936 | rect.width = border.left + handle_h; | |||
| 6937 | rect.height = border.bottom + handle_v; | |||
| 6938 | region = cairo_region_create_rectangle (&rect); | |||
| 6939 | rect.x = border.left; | |||
| 6940 | rect.y = 0; | |||
| 6941 | rect.width = handle_h; | |||
| 6942 | rect.height = handle_v; | |||
| 6943 | cairo_region_subtract_rectangle (region, &rect); | |||
| 6944 | cdk_window_shape_combine_region (priv->border_window[CDK_WINDOW_EDGE_SOUTH_WEST], | |||
| 6945 | region, 0, 0); | |||
| 6946 | cairo_region_destroy (region); | |||
| 6947 | ||||
| 6948 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_SOUTH_WEST]); | |||
| 6949 | } | |||
| 6950 | else | |||
| 6951 | { | |||
| 6952 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_SOUTH_WEST]); | |||
| 6953 | } | |||
| 6954 | ||||
| 6955 | /* South-East */ | |||
| 6956 | if (resize_s && resize_e) | |||
| 6957 | { | |||
| 6958 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_SOUTH_EAST], | |||
| 6959 | window_border.left + width - handle_h, window_border.top + height - handle_v, | |||
| 6960 | border.right + handle_h, border.bottom + handle_v); | |||
| 6961 | ||||
| 6962 | rect.x = 0; | |||
| 6963 | rect.y = 0; | |||
| 6964 | rect.width = border.right + handle_h; | |||
| 6965 | rect.height = border.bottom + handle_v; | |||
| 6966 | region = cairo_region_create_rectangle (&rect); | |||
| 6967 | rect.x = 0; | |||
| 6968 | rect.y = 0; | |||
| 6969 | rect.width = handle_h; | |||
| 6970 | rect.height = handle_v; | |||
| 6971 | cairo_region_subtract_rectangle (region, &rect); | |||
| 6972 | cdk_window_shape_combine_region (priv->border_window[CDK_WINDOW_EDGE_SOUTH_EAST], | |||
| 6973 | region, 0, 0); | |||
| 6974 | cairo_region_destroy (region); | |||
| 6975 | ||||
| 6976 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_SOUTH_EAST]); | |||
| 6977 | } | |||
| 6978 | else | |||
| 6979 | { | |||
| 6980 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_SOUTH_EAST]); | |||
| 6981 | } | |||
| 6982 | } | |||
| 6983 | ||||
| 6984 | /* We're placing 8 input-only windows around | |||
| 6985 | * the window content as resize handles, as | |||
| 6986 | * follows: | |||
| 6987 | * | |||
| 6988 | * +-----------------------------------+ | |||
| 6989 | * | +------+-----------------+------+ | | |||
| 6990 | * | | | | | | | |||
| 6991 | * | | +--+-----------------+--+ | | | |||
| 6992 | * | | | | | | | |||
| 6993 | * | +---+ +---+ | | |||
| 6994 | * | | | | | | | |||
| 6995 | * | | | | | | | |||
| 6996 | * | | | | | | | |||
| 6997 | * | +---+ +---+ | | |||
| 6998 | * | | | | | | | |||
| 6999 | * | | +--+-----------------+--+ | | | |||
| 7000 | * | | | | | | | |||
| 7001 | * | +------+-----------------+------+ | | |||
| 7002 | * +-----------------------------------+ | |||
| 7003 | * | |||
| 7004 | * The corner windows are shaped to allow them | |||
| 7005 | * to extend into the edges. If the window is | |||
| 7006 | * not resizable in both dimensions, we hide | |||
| 7007 | * the corner windows and the edge windows in | |||
| 7008 | * the nonresizable dimension and make the | |||
| 7009 | * remaining edge window extend all the way. | |||
| 7010 | * | |||
| 7011 | * The border are where we place the resize handles | |||
| 7012 | * is also used to draw the window shadow, which may | |||
| 7013 | * extend out farther than the handles (or the other | |||
| 7014 | * way around). | |||
| 7015 | */ | |||
| 7016 | static void | |||
| 7017 | update_border_windows (CtkWindow *window) | |||
| 7018 | { | |||
| 7019 | CtkWidget *widget = (CtkWidget *)window; | |||
| 7020 | CtkWindowPrivate *priv = window->priv; | |||
| 7021 | gboolean resize_n, resize_e, resize_s, resize_w; | |||
| 7022 | gint handle, handle_h, handle_v; | |||
| 7023 | cairo_region_t *region; | |||
| 7024 | cairo_rectangle_int_t rect; | |||
| 7025 | gint width, height; | |||
| 7026 | gint x, w; | |||
| 7027 | gint y, h; | |||
| 7028 | CtkBorder border, tmp; | |||
| 7029 | CtkBorder window_border; | |||
| 7030 | CtkStyleContext *context; | |||
| 7031 | ||||
| 7032 | if (!priv->client_decorated) | |||
| 7033 | return; | |||
| 7034 | ||||
| 7035 | context = _ctk_widget_get_style_context (widget); | |||
| 7036 | ||||
| 7037 | ctk_style_context_save_to_node (context, priv->decoration_node); | |||
| 7038 | ctk_style_context_get_margin (context, ctk_style_context_get_state (context), &border); | |||
| 7039 | ctk_style_context_get_border (context, ctk_style_context_get_state (context), &tmp); | |||
| 7040 | sum_borders (&border, &tmp); | |||
| 7041 | ctk_style_context_get_padding (context, ctk_style_context_get_state (context), &tmp); | |||
| 7042 | sum_borders (&border, &tmp); | |||
| 7043 | ctk_widget_style_get (widget, | |||
| 7044 | "decoration-resize-handle", &handle, | |||
| 7045 | NULL((void*)0)); | |||
| 7046 | ctk_style_context_restore (context); | |||
| 7047 | get_shadow_width (window, &window_border); | |||
| 7048 | ||||
| 7049 | if (priv->border_window[0] == NULL((void*)0)) | |||
| 7050 | goto shape; | |||
| 7051 | ||||
| 7052 | if (!priv->resizable || | |||
| 7053 | priv->fullscreen || | |||
| 7054 | priv->maximized) | |||
| 7055 | { | |||
| 7056 | resize_n = resize_s = resize_e = resize_w = FALSE(0); | |||
| 7057 | } | |||
| 7058 | else if (priv->tiled || priv->edge_constraints) | |||
| 7059 | { | |||
| 7060 | /* Per-edge information is preferred when both priv->tiled and | |||
| 7061 | * priv->edge_constraints are set. | |||
| 7062 | */ | |||
| 7063 | if (priv->edge_constraints) | |||
| 7064 | { | |||
| 7065 | resize_n = priv->edge_constraints & CDK_WINDOW_STATE_TOP_RESIZABLE; | |||
| 7066 | resize_e = priv->edge_constraints & CDK_WINDOW_STATE_RIGHT_RESIZABLE; | |||
| 7067 | resize_s = priv->edge_constraints & CDK_WINDOW_STATE_BOTTOM_RESIZABLE; | |||
| 7068 | resize_w = priv->edge_constraints & CDK_WINDOW_STATE_LEFT_RESIZABLE; | |||
| 7069 | } | |||
| 7070 | else | |||
| 7071 | { | |||
| 7072 | resize_n = resize_s = resize_e = resize_w = FALSE(0); | |||
| 7073 | } | |||
| 7074 | } | |||
| 7075 | else | |||
| 7076 | { | |||
| 7077 | resize_n = resize_s = resize_e = resize_w = TRUE(!(0)); | |||
| 7078 | if (priv->geometry_info) | |||
| 7079 | { | |||
| 7080 | CdkGeometry *geometry = &priv->geometry_info->geometry; | |||
| 7081 | CdkWindowHints flags = priv->geometry_info->mask; | |||
| 7082 | ||||
| 7083 | if ((flags & CDK_HINT_MIN_SIZE) && (flags & CDK_HINT_MAX_SIZE)) | |||
| 7084 | { | |||
| 7085 | resize_e = resize_w = geometry->min_width != geometry->max_width; | |||
| 7086 | resize_n = resize_s = geometry->min_height != geometry->max_height; | |||
| 7087 | } | |||
| 7088 | } | |||
| 7089 | } | |||
| 7090 | ||||
| 7091 | width = ctk_widget_get_allocated_width (widget) - (window_border.left + window_border.right); | |||
| 7092 | height = ctk_widget_get_allocated_height (widget) - (window_border.top + window_border.bottom); | |||
| 7093 | ||||
| 7094 | handle_h = MIN (handle, width / 2)(((handle) < (width / 2)) ? (handle) : (width / 2)); | |||
| 7095 | handle_v = MIN (handle, height / 2)(((handle) < (height / 2)) ? (handle) : (height / 2)); | |||
| 7096 | ||||
| 7097 | /* | |||
| 7098 | * Taking the following abstract representation of the resizable | |||
| 7099 | * edges: | |||
| 7100 | * | |||
| 7101 | * +-------------------------------------------+ | |||
| 7102 | * | NW | North | NE | | |||
| 7103 | * |----+---------------------------------+----| | |||
| 7104 | * | | x | | | |||
| 7105 | * | | | | | |||
| 7106 | * | W | Window contents | E | | |||
| 7107 | * | | | | | |||
| 7108 | * | | | | | |||
| 7109 | * |----+---------------------------------+----| | |||
| 7110 | * | SW | South | SE | | |||
| 7111 | * +-------------------------------------------+ | |||
| 7112 | * | |||
| 7113 | * The idea behind the following math is if, say, the North edge is | |||
| 7114 | * resizable, East & West edges are moved down (i.e. y += North edge | |||
| 7115 | * size). If the South edge is resizable, only shrink East and West | |||
| 7116 | * heights. The same logic applies to the horizontal edges. | |||
| 7117 | * | |||
| 7118 | * The corner windows are only visible if both touching edges are | |||
| 7119 | * visible, for example, the NE window is visible if both N and E | |||
| 7120 | * edges are resizable. | |||
| 7121 | */ | |||
| 7122 | ||||
| 7123 | x = 0; | |||
| 7124 | y = 0; | |||
| 7125 | w = width + window_border.left + window_border.right; | |||
| 7126 | h = height + window_border.top + window_border.bottom; | |||
| 7127 | ||||
| 7128 | if (resize_n) | |||
| 7129 | { | |||
| 7130 | y += window_border.top + handle_v; | |||
| 7131 | h -= window_border.top + handle_v; | |||
| 7132 | } | |||
| 7133 | ||||
| 7134 | if (resize_w) | |||
| 7135 | { | |||
| 7136 | x += window_border.left + handle_h; | |||
| 7137 | w -= window_border.left + handle_h; | |||
| 7138 | } | |||
| 7139 | ||||
| 7140 | if (resize_s) | |||
| 7141 | h -= window_border.bottom + handle_v; | |||
| 7142 | ||||
| 7143 | if (resize_e) | |||
| 7144 | w -= window_border.right + handle_h; | |||
| 7145 | ||||
| 7146 | /* North */ | |||
| 7147 | if (resize_n) | |||
| 7148 | { | |||
| 7149 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_NORTH], | |||
| 7150 | x, window_border.top - border.top, | |||
| 7151 | w, border.top); | |||
| 7152 | ||||
| 7153 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_NORTH]); | |||
| 7154 | } | |||
| 7155 | else | |||
| 7156 | { | |||
| 7157 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_NORTH]); | |||
| 7158 | } | |||
| 7159 | ||||
| 7160 | /* South */ | |||
| 7161 | if (resize_s) | |||
| 7162 | { | |||
| 7163 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_SOUTH], | |||
| 7164 | x, window_border.top + height, | |||
| 7165 | w, border.bottom); | |||
| 7166 | ||||
| 7167 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_SOUTH]); | |||
| 7168 | } | |||
| 7169 | else | |||
| 7170 | { | |||
| 7171 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_SOUTH]); | |||
| 7172 | } | |||
| 7173 | ||||
| 7174 | /* East */ | |||
| 7175 | if (resize_e) | |||
| 7176 | { | |||
| 7177 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_EAST], | |||
| 7178 | window_border.left + width, y, | |||
| 7179 | border.right, h); | |||
| 7180 | ||||
| 7181 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_EAST]); | |||
| 7182 | } | |||
| 7183 | else | |||
| 7184 | { | |||
| 7185 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_EAST]); | |||
| 7186 | } | |||
| 7187 | ||||
| 7188 | /* West */ | |||
| 7189 | if (resize_w) | |||
| 7190 | { | |||
| 7191 | cdk_window_move_resize (priv->border_window[CDK_WINDOW_EDGE_WEST], | |||
| 7192 | window_border.left - border.left, y, | |||
| 7193 | border.left, h); | |||
| 7194 | ||||
| 7195 | cdk_window_show_unraised (priv->border_window[CDK_WINDOW_EDGE_WEST]); | |||
| 7196 | } | |||
| 7197 | else | |||
| 7198 | { | |||
| 7199 | cdk_window_hide (priv->border_window[CDK_WINDOW_EDGE_WEST]); | |||
| 7200 | } | |||
| 7201 | ||||
| 7202 | update_corner_windows (window, border, window_border, width, height, handle_h, handle_v, | |||
| 7203 | resize_n, resize_e, resize_s, resize_w); | |||
| 7204 | ||||
| 7205 | shape: | |||
| 7206 | /* we also update the input shape, which makes it so that clicks | |||
| 7207 | * outside the border windows go through | |||
| 7208 | */ | |||
| 7209 | ||||
| 7210 | if (priv->type != CTK_WINDOW_POPUP) | |||
| 7211 | subtract_borders (&window_border, &border); | |||
| 7212 | ||||
| 7213 | rect.x = window_border.left; | |||
| 7214 | rect.y = window_border.top; | |||
| 7215 | rect.width = ctk_widget_get_allocated_width (widget) - window_border.left - window_border.right; | |||
| 7216 | rect.height = ctk_widget_get_allocated_height (widget) - window_border.top - window_border.bottom; | |||
| 7217 | region = cairo_region_create_rectangle (&rect); | |||
| 7218 | ctk_widget_set_csd_input_shape (widget, region); | |||
| 7219 | cairo_region_destroy (region); | |||
| 7220 | } | |||
| 7221 | ||||
| 7222 | static void | |||
| 7223 | update_shadow_width (CtkWindow *window, | |||
| 7224 | CtkBorder *border) | |||
| 7225 | { | |||
| 7226 | CdkWindow *cdk_window; | |||
| 7227 | ||||
| 7228 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 7229 | ||||
| 7230 | if (cdk_window) | |||
| 7231 | cdk_window_set_shadow_width (cdk_window, | |||
| 7232 | border->left, | |||
| 7233 | border->right, | |||
| 7234 | border->top, | |||
| 7235 | border->bottom); | |||
| 7236 | } | |||
| 7237 | ||||
| 7238 | static void | |||
| 7239 | corner_rect (cairo_rectangle_int_t *rect, | |||
| 7240 | const CtkCssValue *value) | |||
| 7241 | { | |||
| 7242 | rect->width = _ctk_css_corner_value_get_x (value, 100); | |||
| 7243 | rect->height = _ctk_css_corner_value_get_y (value, 100); | |||
| 7244 | } | |||
| 7245 | ||||
| 7246 | static void | |||
| 7247 | subtract_decoration_corners_from_region (cairo_region_t *region, | |||
| 7248 | cairo_rectangle_int_t *extents, | |||
| 7249 | CtkStyleContext *context, | |||
| 7250 | CtkWindow *window) | |||
| 7251 | { | |||
| 7252 | CtkWindowPrivate *priv = window->priv; | |||
| 7253 | cairo_rectangle_int_t rect; | |||
| 7254 | ||||
| 7255 | if (!priv->client_decorated || | |||
| 7256 | !priv->decorated || | |||
| 7257 | priv->fullscreen || | |||
| 7258 | priv->maximized) | |||
| 7259 | return; | |||
| 7260 | ||||
| 7261 | ctk_style_context_save_to_node (context, window->priv->decoration_node); | |||
| 7262 | ||||
| 7263 | corner_rect (&rect, _ctk_style_context_peek_property (context, CTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS)); | |||
| 7264 | rect.x = extents->x; | |||
| 7265 | rect.y = extents->y; | |||
| 7266 | cairo_region_subtract_rectangle (region, &rect); | |||
| 7267 | ||||
| 7268 | corner_rect (&rect, _ctk_style_context_peek_property (context, CTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS)); | |||
| 7269 | rect.x = extents->x + extents->width - rect.width; | |||
| 7270 | rect.y = extents->y; | |||
| 7271 | cairo_region_subtract_rectangle (region, &rect); | |||
| 7272 | ||||
| 7273 | corner_rect (&rect, _ctk_style_context_peek_property (context, CTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS)); | |||
| 7274 | rect.x = extents->x; | |||
| 7275 | rect.y = extents->y + extents->height - rect.height; | |||
| 7276 | cairo_region_subtract_rectangle (region, &rect); | |||
| 7277 | ||||
| 7278 | corner_rect (&rect, _ctk_style_context_peek_property (context, CTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS)); | |||
| 7279 | rect.x = extents->x + extents->width - rect.width; | |||
| 7280 | rect.y = extents->y + extents->height - rect.height; | |||
| 7281 | cairo_region_subtract_rectangle (region, &rect); | |||
| 7282 | ||||
| 7283 | ctk_style_context_restore (context); | |||
| 7284 | } | |||
| 7285 | ||||
| 7286 | static void | |||
| 7287 | update_opaque_region (CtkWindow *window, | |||
| 7288 | const CtkBorder *border, | |||
| 7289 | const CtkAllocation *allocation) | |||
| 7290 | { | |||
| 7291 | CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 7292 | cairo_region_t *opaque_region; | |||
| 7293 | CtkStyleContext *context; | |||
| 7294 | gboolean is_opaque = FALSE(0); | |||
| 7295 | ||||
| 7296 | if (!_ctk_widget_get_realized (widget)) | |||
| 7297 | return; | |||
| 7298 | ||||
| 7299 | context = ctk_widget_get_style_context (widget); | |||
| 7300 | ||||
| 7301 | if (!ctk_widget_get_app_paintable (widget)) | |||
| 7302 | { | |||
| 7303 | const CdkRGBA *color; | |||
| 7304 | color = _ctk_css_rgba_value_get_rgba (_ctk_style_context_peek_property (context, CTK_CSS_PROPERTY_BACKGROUND_COLOR)); | |||
| 7305 | is_opaque = (color->alpha >= 1.0); | |||
| 7306 | } | |||
| 7307 | ||||
| 7308 | if (ctk_widget_get_opacity (widget) < 1.0) | |||
| 7309 | is_opaque = FALSE(0); | |||
| 7310 | ||||
| 7311 | if (is_opaque) | |||
| 7312 | { | |||
| 7313 | cairo_rectangle_int_t rect; | |||
| 7314 | ||||
| 7315 | rect.x = border->left; | |||
| 7316 | rect.y = border->top; | |||
| 7317 | rect.width = allocation->width - border->left - border->right; | |||
| 7318 | rect.height = allocation->height - border->top - border->bottom; | |||
| 7319 | ||||
| 7320 | opaque_region = cairo_region_create_rectangle (&rect); | |||
| 7321 | ||||
| 7322 | subtract_decoration_corners_from_region (opaque_region, &rect, context, window); | |||
| 7323 | } | |||
| 7324 | else | |||
| 7325 | { | |||
| 7326 | opaque_region = NULL((void*)0); | |||
| 7327 | } | |||
| 7328 | ||||
| 7329 | cdk_window_set_opaque_region (_ctk_widget_get_window (widget), opaque_region); | |||
| 7330 | ||||
| 7331 | cairo_region_destroy (opaque_region); | |||
| 7332 | } | |||
| 7333 | ||||
| 7334 | static void | |||
| 7335 | update_realized_window_properties (CtkWindow *window, | |||
| 7336 | CtkAllocation *child_allocation, | |||
| 7337 | CtkBorder *window_border) | |||
| 7338 | { | |||
| 7339 | CtkWindowPrivate *priv = window->priv; | |||
| 7340 | ||||
| 7341 | if (!_ctk_widget_is_toplevel (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 7342 | return; | |||
| 7343 | ||||
| 7344 | if (priv->client_decorated && priv->use_client_shadow) | |||
| 7345 | update_shadow_width (window, window_border); | |||
| 7346 | ||||
| 7347 | update_opaque_region (window, window_border, child_allocation); | |||
| 7348 | ||||
| 7349 | update_border_windows (window); | |||
| 7350 | } | |||
| 7351 | ||||
| 7352 | static void | |||
| 7353 | ctk_window_realize (CtkWidget *widget) | |||
| 7354 | { | |||
| 7355 | CtkAllocation allocation; | |||
| 7356 | CtkAllocation child_allocation; | |||
| 7357 | CtkWindow *window; | |||
| 7358 | CdkWindow *parent_window; | |||
| 7359 | CdkWindow *cdk_window; | |||
| 7360 | CdkWindowAttr attributes; | |||
| 7361 | CtkBorder window_border; | |||
| 7362 | gint attributes_mask; | |||
| 7363 | CtkWindowPrivate *priv; | |||
| 7364 | gint i; | |||
| 7365 | GList *link; | |||
| 7366 | ||||
| 7367 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 7368 | priv = window->priv; | |||
| 7369 | ||||
| 7370 | if (!priv->client_decorated && ctk_window_should_use_csd (window)) | |||
| 7371 | create_decoration (widget); | |||
| 7372 | ||||
| 7373 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 7374 | ||||
| 7375 | if (ctk_widget_get_parent_window (widget)) | |||
| 7376 | { | |||
| 7377 | ctk_container_set_default_resize_mode (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), CTK_RESIZE_PARENT); | |||
| 7378 | ||||
| 7379 | attributes.x = allocation.x; | |||
| 7380 | attributes.y = allocation.y; | |||
| 7381 | attributes.width = allocation.width; | |||
| 7382 | attributes.height = allocation.height; | |||
| 7383 | attributes.window_type = CDK_WINDOW_CHILD; | |||
| 7384 | ||||
| 7385 | attributes.event_mask = ctk_widget_get_events (widget) | CDK_EXPOSURE_MASK | CDK_STRUCTURE_MASK; | |||
| 7386 | ||||
| 7387 | attributes.visual = ctk_widget_get_visual (widget); | |||
| 7388 | attributes.wclass = CDK_INPUT_OUTPUT; | |||
| 7389 | ||||
| 7390 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; | |||
| 7391 | ||||
| 7392 | cdk_window = cdk_window_new (ctk_widget_get_parent_window (widget), | |||
| 7393 | &attributes, attributes_mask); | |||
| 7394 | ctk_widget_set_window (widget, cdk_window); | |||
| 7395 | ctk_widget_register_window (widget, cdk_window); | |||
| 7396 | ctk_widget_set_realized (widget, TRUE(!(0))); | |||
| 7397 | ||||
| 7398 | link = priv->popovers; | |||
| 7399 | ||||
| 7400 | while (link) | |||
| 7401 | { | |||
| 7402 | CtkWindowPopover *popover = link->data; | |||
| 7403 | link = link->next; | |||
| 7404 | popover_realize (popover->widget, popover, window); | |||
| 7405 | } | |||
| 7406 | ||||
| 7407 | return; | |||
| 7408 | } | |||
| 7409 | ||||
| 7410 | ctk_container_set_default_resize_mode (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), CTK_RESIZE_QUEUE); | |||
| 7411 | ||||
| 7412 | /* ensure widget tree is properly size allocated */ | |||
| 7413 | if (allocation.x == -1 && | |||
| 7414 | allocation.y == -1 && | |||
| 7415 | allocation.width == 1 && | |||
| 7416 | allocation.height == 1) | |||
| 7417 | { | |||
| 7418 | CdkRectangle request; | |||
| 7419 | ||||
| 7420 | ctk_window_compute_configure_request (window, &request, NULL((void*)0), NULL((void*)0)); | |||
| 7421 | ||||
| 7422 | allocation.x = 0; | |||
| 7423 | allocation.y = 0; | |||
| 7424 | allocation.width = request.width; | |||
| 7425 | allocation.height = request.height; | |||
| 7426 | ctk_widget_size_allocate (widget, &allocation); | |||
| 7427 | ||||
| 7428 | ctk_widget_queue_resize (widget); | |||
| 7429 | ||||
| 7430 | g_return_if_fail (!_ctk_widget_get_realized (widget))do { if ((!_ctk_widget_get_realized (widget))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!_ctk_widget_get_realized (widget)" ); return; } } while (0); | |||
| 7431 | } | |||
| 7432 | ||||
| 7433 | if (priv->hardcoded_window) | |||
| 7434 | { | |||
| 7435 | cdk_window = priv->hardcoded_window; | |||
| 7436 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 7437 | cdk_window_resize (cdk_window, allocation.width, allocation.height); | |||
| 7438 | } | |||
| 7439 | else | |||
| 7440 | { | |||
| 7441 | switch (priv->type) | |||
| 7442 | { | |||
| 7443 | case CTK_WINDOW_TOPLEVEL: | |||
| 7444 | attributes.window_type = CDK_WINDOW_TOPLEVEL; | |||
| 7445 | break; | |||
| 7446 | case CTK_WINDOW_POPUP: | |||
| 7447 | attributes.window_type = CDK_WINDOW_TEMP; | |||
| 7448 | break; | |||
| 7449 | default: | |||
| 7450 | g_warning (G_STRLOC"ctkwindow.c" ":" "7450"": Unknown window type %d!", priv->type); | |||
| 7451 | break; | |||
| 7452 | } | |||
| 7453 | ||||
| 7454 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 7455 | if (priv->use_subsurface && | |||
| 7456 | CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (widget))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 7457 | attributes.window_type = CDK_WINDOW_SUBSURFACE; | |||
| 7458 | #endif | |||
| 7459 | ||||
| 7460 | attributes.title = priv->title; | |||
| 7461 | attributes.wmclass_name = priv->wmclass_name; | |||
| 7462 | attributes.wmclass_class = priv->wmclass_class; | |||
| 7463 | attributes.wclass = CDK_INPUT_OUTPUT; | |||
| 7464 | attributes.visual = ctk_widget_get_visual (widget); | |||
| 7465 | ||||
| 7466 | attributes_mask = 0; | |||
| 7467 | parent_window = cdk_screen_get_root_window (_ctk_window_get_screen (window)); | |||
| 7468 | ||||
| 7469 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 7470 | attributes.width = allocation.width; | |||
| 7471 | attributes.height = allocation.height; | |||
| 7472 | attributes.event_mask = ctk_widget_get_events (widget); | |||
| 7473 | attributes.event_mask |= (CDK_EXPOSURE_MASK | | |||
| 7474 | CDK_BUTTON_PRESS_MASK | | |||
| 7475 | CDK_BUTTON_RELEASE_MASK | | |||
| 7476 | CDK_BUTTON_MOTION_MASK | | |||
| 7477 | CDK_KEY_PRESS_MASK | | |||
| 7478 | CDK_KEY_RELEASE_MASK | | |||
| 7479 | CDK_ENTER_NOTIFY_MASK | | |||
| 7480 | CDK_LEAVE_NOTIFY_MASK | | |||
| 7481 | CDK_FOCUS_CHANGE_MASK | | |||
| 7482 | CDK_STRUCTURE_MASK); | |||
| 7483 | ||||
| 7484 | if (priv->decorated && priv->client_decorated) | |||
| 7485 | attributes.event_mask |= CDK_POINTER_MOTION_MASK; | |||
| 7486 | ||||
| 7487 | attributes.type_hint = priv->type_hint; | |||
| 7488 | ||||
| 7489 | attributes_mask |= CDK_WA_VISUAL | CDK_WA_TYPE_HINT; | |||
| 7490 | attributes_mask |= (priv->title ? CDK_WA_TITLE : 0); | |||
| 7491 | attributes_mask |= (priv->wmclass_name ? CDK_WA_WMCLASS : 0); | |||
| 7492 | ||||
| 7493 | cdk_window = cdk_window_new (parent_window, &attributes, attributes_mask); | |||
| 7494 | } | |||
| 7495 | ||||
| 7496 | ctk_widget_set_window (widget, cdk_window); | |||
| 7497 | ctk_widget_register_window (widget, cdk_window); | |||
| 7498 | ctk_widget_set_realized (widget, TRUE(!(0))); | |||
| 7499 | ||||
| 7500 | attributes.x = allocation.x; | |||
| 7501 | attributes.y = allocation.y; | |||
| 7502 | attributes.width = allocation.width; | |||
| 7503 | attributes.height = allocation.height; | |||
| 7504 | attributes.window_type = CDK_WINDOW_CHILD; | |||
| 7505 | ||||
| 7506 | attributes.event_mask = ctk_widget_get_events (widget) | CDK_EXPOSURE_MASK | CDK_STRUCTURE_MASK; | |||
| 7507 | ||||
| 7508 | attributes.visual = ctk_widget_get_visual (widget); | |||
| 7509 | attributes.wclass = CDK_INPUT_OUTPUT; | |||
| 7510 | ||||
| 7511 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; | |||
| 7512 | ||||
| 7513 | if (priv->client_decorated && priv->type == CTK_WINDOW_TOPLEVEL) | |||
| 7514 | { | |||
| 7515 | const gchar *cursor[8] = { | |||
| 7516 | "nw-resize", "n-resize", "ne-resize", | |||
| 7517 | "w-resize", "e-resize", | |||
| 7518 | "sw-resize", "s-resize", "se-resize" | |||
| 7519 | }; | |||
| 7520 | ||||
| 7521 | attributes.wclass = CDK_INPUT_ONLY; | |||
| 7522 | attributes.width = 1; | |||
| 7523 | attributes.height = 1; | |||
| 7524 | attributes.event_mask = CDK_BUTTON_PRESS_MASK; | |||
| 7525 | attributes_mask = CDK_WA_CURSOR; | |||
| 7526 | ||||
| 7527 | for (i = 0; i < 8; i++) | |||
| 7528 | { | |||
| 7529 | attributes.cursor = cdk_cursor_new_from_name (ctk_widget_get_display (widget), cursor[i]); | |||
| 7530 | priv->border_window[i] = cdk_window_new (cdk_window, &attributes, attributes_mask); | |||
| 7531 | g_clear_object (&attributes.cursor)do { _Static_assert (sizeof *((&attributes.cursor)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &attributes.cursor))) _pp = ((&attributes.cursor)); __typeof__ (*((&attributes.cursor))) _ptr = *_pp; *_pp = ((void*)0) ; if (_ptr) (g_object_unref) (_ptr); } while (0); | |||
| 7532 | ||||
| 7533 | cdk_window_show (priv->border_window[i]); | |||
| 7534 | ctk_widget_register_window (widget, priv->border_window[i]); | |||
| 7535 | } | |||
| 7536 | } | |||
| 7537 | ||||
| 7538 | if (priv->transient_parent && | |||
| 7539 | _ctk_widget_get_realized (CTK_WIDGET (priv->transient_parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->transient_parent)), ((ctk_widget_get_type ()))) ))))) | |||
| 7540 | cdk_window_set_transient_for (cdk_window, | |||
| 7541 | _ctk_widget_get_window (CTK_WIDGET (priv->transient_parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->transient_parent)), ((ctk_widget_get_type ()))) ))))); | |||
| 7542 | ||||
| 7543 | if (priv->wm_role) | |||
| 7544 | cdk_window_set_role (cdk_window, priv->wm_role); | |||
| 7545 | ||||
| 7546 | if (!priv->decorated || priv->client_decorated) | |||
| 7547 | cdk_window_set_decorations (cdk_window, 0); | |||
| 7548 | ||||
| 7549 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 7550 | if (CDK_IS_WAYLAND_WINDOW (cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_wayland_window_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; }))))) | |||
| 7551 | { | |||
| 7552 | if (priv->client_decorated) | |||
| 7553 | cdk_wayland_window_announce_csd (cdk_window); | |||
| 7554 | else | |||
| 7555 | cdk_wayland_window_announce_ssd (cdk_window); | |||
| 7556 | } | |||
| 7557 | #endif | |||
| 7558 | ||||
| 7559 | if (!priv->deletable) | |||
| 7560 | cdk_window_set_functions (cdk_window, CDK_FUNC_ALL | CDK_FUNC_CLOSE); | |||
| 7561 | ||||
| 7562 | if (ctk_window_get_skip_pager_hint (window)) | |||
| 7563 | cdk_window_set_skip_pager_hint (cdk_window, TRUE(!(0))); | |||
| 7564 | ||||
| 7565 | if (ctk_window_get_skip_taskbar_hint (window)) | |||
| 7566 | cdk_window_set_skip_taskbar_hint (cdk_window, TRUE(!(0))); | |||
| 7567 | ||||
| 7568 | if (ctk_window_get_accept_focus (window)) | |||
| 7569 | cdk_window_set_accept_focus (cdk_window, TRUE(!(0))); | |||
| 7570 | else | |||
| 7571 | cdk_window_set_accept_focus (cdk_window, FALSE(0)); | |||
| 7572 | ||||
| 7573 | if (ctk_window_get_focus_on_map (window)) | |||
| 7574 | cdk_window_set_focus_on_map (cdk_window, TRUE(!(0))); | |||
| 7575 | else | |||
| 7576 | cdk_window_set_focus_on_map (cdk_window, FALSE(0)); | |||
| 7577 | ||||
| 7578 | if (priv->modal) | |||
| 7579 | cdk_window_set_modal_hint (cdk_window, TRUE(!(0))); | |||
| 7580 | else | |||
| 7581 | cdk_window_set_modal_hint (cdk_window, FALSE(0)); | |||
| 7582 | ||||
| 7583 | if (priv->startup_id) | |||
| 7584 | { | |||
| 7585 | #ifdef CDK_WINDOWING_X11 | |||
| 7586 | if (CDK_IS_X11_WINDOW (cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_x11_window_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; }))))) | |||
| 7587 | { | |||
| 7588 | guint32 timestamp = extract_time_from_startup_id (priv->startup_id); | |||
| 7589 | if (timestamp != CDK_CURRENT_TIME0L) | |||
| 7590 | cdk_x11_window_set_user_time (cdk_window, timestamp); | |||
| 7591 | } | |||
| 7592 | #endif | |||
| 7593 | if (!startup_id_is_fake (priv->startup_id)) | |||
| 7594 | cdk_window_set_startup_id (cdk_window, priv->startup_id); | |||
| 7595 | } | |||
| 7596 | ||||
| 7597 | #ifdef CDK_WINDOWING_X11 | |||
| 7598 | if (priv->initial_timestamp != CDK_CURRENT_TIME0L) | |||
| 7599 | { | |||
| 7600 | if (CDK_IS_X11_WINDOW (cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_x11_window_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; }))))) | |||
| 7601 | cdk_x11_window_set_user_time (cdk_window, priv->initial_timestamp); | |||
| 7602 | } | |||
| 7603 | #endif | |||
| 7604 | ||||
| 7605 | child_allocation.x = 0; | |||
| 7606 | child_allocation.y = 0; | |||
| 7607 | child_allocation.width = allocation.width; | |||
| 7608 | child_allocation.height = allocation.height; | |||
| 7609 | ||||
| 7610 | get_shadow_width (window, &window_border); | |||
| 7611 | ||||
| 7612 | update_realized_window_properties (window, &child_allocation, &window_border); | |||
| 7613 | ||||
| 7614 | if (priv->application) | |||
| 7615 | ctk_application_handle_window_realize (priv->application, window); | |||
| 7616 | ||||
| 7617 | /* Icons */ | |||
| 7618 | ctk_window_realize_icon (window); | |||
| 7619 | ||||
| 7620 | link = priv->popovers; | |||
| 7621 | ||||
| 7622 | while (link) | |||
| 7623 | { | |||
| 7624 | CtkWindowPopover *popover = link->data; | |||
| 7625 | link = link->next; | |||
| 7626 | popover_realize (popover->widget, popover, window); | |||
| 7627 | } | |||
| 7628 | ||||
| 7629 | check_scale_changed (window); | |||
| 7630 | } | |||
| 7631 | ||||
| 7632 | static void | |||
| 7633 | popover_unrealize (CtkWidget *widget, | |||
| 7634 | CtkWindowPopover *popover, | |||
| 7635 | CtkWindow *window) | |||
| 7636 | { | |||
| 7637 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 7638 | if (CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (widget))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 7639 | cdk_window_set_transient_for (popover->window, NULL((void*)0)); | |||
| 7640 | #endif | |||
| 7641 | ||||
| 7642 | ctk_widget_unregister_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), popover->window); | |||
| 7643 | ctk_widget_unrealize (popover->widget); | |||
| 7644 | cdk_window_destroy (popover->window); | |||
| 7645 | popover->window = NULL((void*)0); | |||
| 7646 | } | |||
| 7647 | ||||
| 7648 | static void | |||
| 7649 | ctk_window_unrealize (CtkWidget *widget) | |||
| 7650 | { | |||
| 7651 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 7652 | CtkWindowPrivate *priv = window->priv; | |||
| 7653 | CtkWindowGeometryInfo *info; | |||
| 7654 | GList *link; | |||
| 7655 | gint i; | |||
| 7656 | ||||
| 7657 | /* On unrealize, we reset the size of the window such | |||
| 7658 | * that we will re-apply the default sizing stuff | |||
| 7659 | * next time we show the window. | |||
| 7660 | * | |||
| 7661 | * Default positioning is reset on unmap, instead of unrealize. | |||
| 7662 | */ | |||
| 7663 | priv->need_default_size = TRUE(!(0)); | |||
| 7664 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 7665 | if (info) | |||
| 7666 | { | |||
| 7667 | info->resize_width = -1; | |||
| 7668 | info->resize_height = -1; | |||
| 7669 | info->last.configure_request.x = 0; | |||
| 7670 | info->last.configure_request.y = 0; | |||
| 7671 | info->last.configure_request.width = -1; | |||
| 7672 | info->last.configure_request.height = -1; | |||
| 7673 | /* be sure we reset geom hints on re-realize */ | |||
| 7674 | info->last.flags = 0; | |||
| 7675 | } | |||
| 7676 | ||||
| 7677 | if (priv->popup_menu) | |||
| 7678 | { | |||
| 7679 | ctk_widget_destroy (priv->popup_menu); | |||
| 7680 | priv->popup_menu = NULL((void*)0); | |||
| 7681 | } | |||
| 7682 | ||||
| 7683 | /* Icons */ | |||
| 7684 | ctk_window_unrealize_icon (window); | |||
| 7685 | ||||
| 7686 | if (priv->border_window[0] != NULL((void*)0)) | |||
| 7687 | { | |||
| 7688 | for (i = 0; i < 8; i++) | |||
| 7689 | { | |||
| 7690 | ctk_widget_unregister_window (widget, priv->border_window[i]); | |||
| 7691 | cdk_window_destroy (priv->border_window[i]); | |||
| 7692 | priv->border_window[i] = NULL((void*)0); | |||
| 7693 | } | |||
| 7694 | } | |||
| 7695 | ||||
| 7696 | link = priv->popovers; | |||
| 7697 | ||||
| 7698 | while (link) | |||
| 7699 | { | |||
| 7700 | CtkWindowPopover *popover = link->data; | |||
| 7701 | link = link->next; | |||
| 7702 | popover_unrealize (popover->widget, popover, window); | |||
| 7703 | } | |||
| 7704 | ||||
| 7705 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->unrealize (widget); | |||
| 7706 | ||||
| 7707 | priv->hardcoded_window = NULL((void*)0); | |||
| 7708 | } | |||
| 7709 | ||||
| 7710 | static void | |||
| 7711 | update_window_style_classes (CtkWindow *window) | |||
| 7712 | { | |||
| 7713 | CtkWindowPrivate *priv = window->priv; | |||
| 7714 | CtkStyleContext *context; | |||
| 7715 | ||||
| 7716 | context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 7717 | ||||
| 7718 | if (priv->tiled) | |||
| 7719 | ctk_style_context_add_class (context, "tiled"); | |||
| 7720 | else | |||
| 7721 | ctk_style_context_remove_class (context, "tiled"); | |||
| 7722 | ||||
| 7723 | if (priv->edge_constraints != 0) | |||
| 7724 | { | |||
| 7725 | guint edge_constraints = priv->edge_constraints; | |||
| 7726 | ||||
| 7727 | if (edge_constraints & CDK_WINDOW_STATE_TOP_TILED) | |||
| 7728 | ctk_style_context_add_class (context, "tiled-top"); | |||
| 7729 | else | |||
| 7730 | ctk_style_context_remove_class (context, "tiled-top"); | |||
| 7731 | ||||
| 7732 | if (edge_constraints & CDK_WINDOW_STATE_RIGHT_TILED) | |||
| 7733 | ctk_style_context_add_class (context, "tiled-right"); | |||
| 7734 | else | |||
| 7735 | ctk_style_context_remove_class (context, "tiled-right"); | |||
| 7736 | ||||
| 7737 | if (edge_constraints & CDK_WINDOW_STATE_BOTTOM_TILED) | |||
| 7738 | ctk_style_context_add_class (context, "tiled-bottom"); | |||
| 7739 | else | |||
| 7740 | ctk_style_context_remove_class (context, "tiled-bottom"); | |||
| 7741 | ||||
| 7742 | if (edge_constraints & CDK_WINDOW_STATE_LEFT_TILED) | |||
| 7743 | ctk_style_context_add_class (context, "tiled-left"); | |||
| 7744 | else | |||
| 7745 | ctk_style_context_remove_class (context, "tiled-left"); | |||
| 7746 | } | |||
| 7747 | ||||
| 7748 | if (priv->maximized) | |||
| 7749 | ctk_style_context_add_class (context, "maximized"); | |||
| 7750 | else | |||
| 7751 | ctk_style_context_remove_class (context, "maximized"); | |||
| 7752 | ||||
| 7753 | if (priv->fullscreen) | |||
| 7754 | ctk_style_context_add_class (context, "fullscreen"); | |||
| 7755 | else | |||
| 7756 | ctk_style_context_remove_class (context, "fullscreen"); | |||
| 7757 | } | |||
| 7758 | ||||
| 7759 | static void | |||
| 7760 | popover_size_allocate (CtkWidget *widget, | |||
| 7761 | CtkWindowPopover *popover, | |||
| 7762 | CtkWindow *window) | |||
| 7763 | { | |||
| 7764 | cairo_rectangle_int_t rect; | |||
| 7765 | ||||
| 7766 | if (!popover->window) | |||
| 7767 | return; | |||
| 7768 | ||||
| 7769 | if (CTK_IS_POPOVER (popover->widget)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (popover->widget)); GType _t = ((ctk_popover_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; }))))) | |||
| 7770 | ctk_popover_update_position (CTK_POPOVER (popover->widget)((((CtkPopover*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((popover->widget)), ((ctk_popover_get_type ()))))))); | |||
| 7771 | ||||
| 7772 | popover_get_rect (popover, window, &rect); | |||
| 7773 | cdk_window_move_resize (popover->window, rect.x, rect.y, | |||
| 7774 | rect.width, rect.height); | |||
| 7775 | rect.x = rect.y = 0; | |||
| 7776 | ctk_widget_size_allocate (widget, &rect); | |||
| 7777 | ||||
| 7778 | if (ctk_widget_is_drawable (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) && | |||
| 7779 | ctk_widget_is_visible (widget)) | |||
| 7780 | { | |||
| 7781 | if (!cdk_window_is_visible (popover->window)) | |||
| 7782 | cdk_window_show_unraised (popover->window); | |||
| 7783 | } | |||
| 7784 | else if (cdk_window_is_visible (popover->window)) | |||
| 7785 | cdk_window_hide (popover->window); | |||
| 7786 | } | |||
| 7787 | ||||
| 7788 | /* _ctk_window_set_allocation: | |||
| 7789 | * @window: a #CtkWindow | |||
| 7790 | * @allocation: the original allocation for the window | |||
| 7791 | * @allocation_out: @allocation taking decorations into | |||
| 7792 | * consideration | |||
| 7793 | * | |||
| 7794 | * This function is like ctk_widget_set_allocation() | |||
| 7795 | * but does the necessary extra work to update | |||
| 7796 | * the resize grip positioning, etc. | |||
| 7797 | * | |||
| 7798 | * Call this instead of ctk_widget_set_allocation() | |||
| 7799 | * when overriding ::size_allocate in a CtkWindow | |||
| 7800 | * subclass without chaining up. | |||
| 7801 | * | |||
| 7802 | * The @allocation parameter will be adjusted to | |||
| 7803 | * reflect any internal decorations that the window | |||
| 7804 | * may have. That revised allocation will then be | |||
| 7805 | * returned in the @allocation_out parameter. | |||
| 7806 | */ | |||
| 7807 | void | |||
| 7808 | _ctk_window_set_allocation (CtkWindow *window, | |||
| 7809 | const CtkAllocation *allocation, | |||
| 7810 | CtkAllocation *allocation_out) | |||
| 7811 | { | |||
| 7812 | CtkWidget *widget = (CtkWidget *)window; | |||
| 7813 | CtkWindowPrivate *priv = window->priv; | |||
| 7814 | CtkAllocation child_allocation; | |||
| 7815 | gint border_width; | |||
| 7816 | CtkBorder window_border = { 0 }; | |||
| 7817 | GList *link; | |||
| 7818 | ||||
| 7819 | g_assert (allocation != NULL)do { if (allocation != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c", 7819, ((const char*) (__func__)), "allocation != NULL" ); } while (0); | |||
| 7820 | g_assert (allocation_out != NULL)do { if (allocation_out != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c", 7820, ((const char*) (__func__)), "allocation_out != NULL" ); } while (0); | |||
| 7821 | ||||
| 7822 | ctk_widget_set_allocation (widget, allocation); | |||
| 7823 | ||||
| 7824 | child_allocation.x = 0; | |||
| 7825 | child_allocation.y = 0; | |||
| 7826 | child_allocation.width = allocation->width; | |||
| 7827 | child_allocation.height = allocation->height; | |||
| 7828 | ||||
| 7829 | get_shadow_width (window, &window_border); | |||
| 7830 | ||||
| 7831 | if (_ctk_widget_get_realized (widget)) | |||
| 7832 | update_realized_window_properties (window, &child_allocation, &window_border); | |||
| 7833 | ||||
| 7834 | priv->title_height = 0; | |||
| 7835 | ||||
| 7836 | if (priv->title_box != NULL((void*)0) && | |||
| 7837 | ctk_widget_get_visible (priv->title_box) && | |||
| 7838 | ctk_widget_get_child_visible (priv->title_box) && | |||
| 7839 | priv->decorated && | |||
| 7840 | !priv->fullscreen) | |||
| 7841 | { | |||
| 7842 | CtkAllocation title_allocation; | |||
| 7843 | ||||
| 7844 | title_allocation.x = window_border.left; | |||
| 7845 | title_allocation.y = window_border.top; | |||
| 7846 | title_allocation.width = | |||
| 7847 | MAX (1, (gint) allocation->width -(((1) > ((gint) allocation->width - window_border.left - window_border.right)) ? (1) : ((gint) allocation->width - window_border.left - window_border.right)) | |||
| 7848 | window_border.left - window_border.right)(((1) > ((gint) allocation->width - window_border.left - window_border.right)) ? (1) : ((gint) allocation->width - window_border.left - window_border.right)); | |||
| 7849 | ||||
| 7850 | ctk_widget_get_preferred_height_for_width (priv->title_box, | |||
| 7851 | title_allocation.width, | |||
| 7852 | NULL((void*)0), | |||
| 7853 | &priv->title_height); | |||
| 7854 | ||||
| 7855 | title_allocation.height = priv->title_height; | |||
| 7856 | ||||
| 7857 | ctk_widget_size_allocate (priv->title_box, &title_allocation); | |||
| 7858 | } | |||
| 7859 | ||||
| 7860 | if (priv->decorated && | |||
| 7861 | !priv->fullscreen) | |||
| 7862 | { | |||
| 7863 | child_allocation.x += window_border.left; | |||
| 7864 | child_allocation.y += window_border.top + priv->title_height; | |||
| 7865 | child_allocation.width -= window_border.left + window_border.right; | |||
| 7866 | child_allocation.height -= window_border.top + window_border.bottom + | |||
| 7867 | priv->title_height; | |||
| 7868 | } | |||
| 7869 | ||||
| 7870 | if (!_ctk_widget_is_toplevel (widget) && _ctk_widget_get_realized (widget)) | |||
| 7871 | { | |||
| 7872 | cdk_window_move_resize (_ctk_widget_get_window (widget), | |||
| 7873 | allocation->x, allocation->y, | |||
| 7874 | allocation->width, allocation->height); | |||
| 7875 | } | |||
| 7876 | ||||
| 7877 | border_width = ctk_container_get_border_width (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ()))))))); | |||
| 7878 | child_allocation.x += border_width; | |||
| 7879 | child_allocation.y += border_width; | |||
| 7880 | child_allocation.width = MAX (1, child_allocation.width - border_width * 2)(((1) > (child_allocation.width - border_width * 2)) ? (1) : (child_allocation.width - border_width * 2)); | |||
| 7881 | child_allocation.height = MAX (1, child_allocation.height - border_width * 2)(((1) > (child_allocation.height - border_width * 2)) ? (1 ) : (child_allocation.height - border_width * 2)); | |||
| 7882 | ||||
| 7883 | *allocation_out = child_allocation; | |||
| 7884 | ||||
| 7885 | link = priv->popovers; | |||
| 7886 | while (link) | |||
| 7887 | { | |||
| 7888 | CtkWindowPopover *popover = link->data; | |||
| 7889 | link = link->next; | |||
| 7890 | popover_size_allocate (popover->widget, popover, window); | |||
| 7891 | } | |||
| 7892 | ||||
| 7893 | } | |||
| 7894 | ||||
| 7895 | static void | |||
| 7896 | ctk_window_restack_popovers (CtkWindow *window) | |||
| 7897 | { | |||
| 7898 | CtkWindowPrivate *priv = window->priv; | |||
| 7899 | GList *link = priv->popovers; | |||
| 7900 | ||||
| 7901 | while (link) | |||
| 7902 | { | |||
| 7903 | CtkWindowPopover *popover = link->data; | |||
| 7904 | link = link->next; | |||
| 7905 | ||||
| 7906 | if (popover->window) | |||
| 7907 | cdk_window_raise (popover->window); | |||
| 7908 | } | |||
| 7909 | } | |||
| 7910 | ||||
| 7911 | static void | |||
| 7912 | ctk_window_size_allocate (CtkWidget *widget, | |||
| 7913 | CtkAllocation *allocation) | |||
| 7914 | { | |||
| 7915 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 7916 | CtkWidget *child; | |||
| 7917 | CtkAllocation child_allocation; | |||
| 7918 | ||||
| 7919 | _ctk_window_set_allocation (window, allocation, &child_allocation); | |||
| 7920 | ||||
| 7921 | child = ctk_bin_get_child (CTK_BIN (window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_bin_get_type ()))))))); | |||
| 7922 | if (child && ctk_widget_get_visible (child)) | |||
| 7923 | ctk_widget_size_allocate (child, &child_allocation); | |||
| 7924 | ||||
| 7925 | ctk_window_restack_popovers (window); | |||
| 7926 | } | |||
| 7927 | ||||
| 7928 | static gint | |||
| 7929 | ctk_window_configure_event (CtkWidget *widget, | |||
| 7930 | CdkEventConfigure *event) | |||
| 7931 | { | |||
| 7932 | CtkAllocation allocation; | |||
| 7933 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 7934 | CtkWindowPrivate *priv = window->priv; | |||
| 7935 | ||||
| 7936 | check_scale_changed (window); | |||
| 7937 | ||||
| 7938 | if (!_ctk_widget_is_toplevel (widget)) | |||
| 7939 | return FALSE(0); | |||
| 7940 | ||||
| 7941 | if (_ctk_widget_get_window (widget) != event->window) | |||
| 7942 | return TRUE(!(0)); | |||
| 7943 | ||||
| 7944 | /* If this is a gratuitous ConfigureNotify that's already | |||
| 7945 | * the same as our allocation, then we can fizzle it out. | |||
| 7946 | * This is the case for dragging windows around. | |||
| 7947 | * | |||
| 7948 | * We can't do this for a ConfigureRequest, since it might | |||
| 7949 | * have been a queued resize from child widgets, and so we | |||
| 7950 | * need to reallocate our children in case *they* changed. | |||
| 7951 | */ | |||
| 7952 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 7953 | if (priv->configure_request_count == 0 && | |||
| 7954 | (allocation.width == event->width && | |||
| 7955 | allocation.height == event->height)) | |||
| 7956 | { | |||
| 7957 | return TRUE(!(0)); | |||
| 7958 | } | |||
| 7959 | ||||
| 7960 | /* priv->configure_request_count incremented for each | |||
| 7961 | * configure request, and decremented to a min of 0 for | |||
| 7962 | * each configure notify. | |||
| 7963 | * | |||
| 7964 | * All it means is that we know we will get at least | |||
| 7965 | * priv->configure_request_count more configure notifies. | |||
| 7966 | * We could get more configure notifies than that; some | |||
| 7967 | * of the configure notifies we get may be unrelated to | |||
| 7968 | * the configure requests. But we will get at least | |||
| 7969 | * priv->configure_request_count notifies. | |||
| 7970 | */ | |||
| 7971 | ||||
| 7972 | if (priv->configure_request_count > 0) | |||
| 7973 | { | |||
| 7974 | priv->configure_request_count -= 1; | |||
| 7975 | ||||
| 7976 | CDK_PRIVATE_CALL (cdk_window_thaw_toplevel_updates)(cdk__private__ ()->cdk_window_thaw_toplevel_updates) (_ctk_widget_get_window (widget)); | |||
| 7977 | } | |||
| 7978 | ||||
| 7979 | /* | |||
| 7980 | * If we do need to resize, we do that by: | |||
| 7981 | * - setting configure_notify_received to TRUE | |||
| 7982 | * for use in ctk_window_move_resize() | |||
| 7983 | * - queueing a resize, leading to invocation of | |||
| 7984 | * ctk_window_move_resize() in an idle handler | |||
| 7985 | * | |||
| 7986 | */ | |||
| 7987 | ||||
| 7988 | priv->configure_notify_received = TRUE(!(0)); | |||
| 7989 | ||||
| 7990 | ctk_widget_queue_allocate (widget); | |||
| 7991 | ctk_container_queue_resize_handler (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); | |||
| 7992 | ||||
| 7993 | return TRUE(!(0)); | |||
| 7994 | } | |||
| 7995 | ||||
| 7996 | static void | |||
| 7997 | update_edge_constraints (CtkWindow *window, | |||
| 7998 | CdkEventWindowState *event) | |||
| 7999 | { | |||
| 8000 | CtkWindowPrivate *priv = window->priv; | |||
| 8001 | CdkWindowState state = event->new_window_state; | |||
| 8002 | ||||
| 8003 | priv->edge_constraints = (state & CDK_WINDOW_STATE_TOP_TILED) | | |||
| 8004 | (state & CDK_WINDOW_STATE_TOP_RESIZABLE) | | |||
| 8005 | (state & CDK_WINDOW_STATE_RIGHT_TILED) | | |||
| 8006 | (state & CDK_WINDOW_STATE_RIGHT_RESIZABLE) | | |||
| 8007 | (state & CDK_WINDOW_STATE_BOTTOM_TILED) | | |||
| 8008 | (state & CDK_WINDOW_STATE_BOTTOM_RESIZABLE) | | |||
| 8009 | (state & CDK_WINDOW_STATE_LEFT_TILED) | | |||
| 8010 | (state & CDK_WINDOW_STATE_LEFT_RESIZABLE); | |||
| 8011 | ||||
| 8012 | priv->tiled = (state & CDK_WINDOW_STATE_TILED) ? 1 : 0; | |||
| 8013 | } | |||
| 8014 | ||||
| 8015 | static gboolean | |||
| 8016 | ctk_window_state_event (CtkWidget *widget, | |||
| 8017 | CdkEventWindowState *event) | |||
| 8018 | { | |||
| 8019 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8020 | CtkWindowPrivate *priv = window->priv; | |||
| 8021 | ||||
| 8022 | if (event->changed_mask & CDK_WINDOW_STATE_FOCUSED) | |||
| 8023 | ensure_state_flag_backdrop (widget); | |||
| 8024 | ||||
| 8025 | if (event->changed_mask & CDK_WINDOW_STATE_FULLSCREEN) | |||
| 8026 | { | |||
| 8027 | priv->fullscreen = | |||
| 8028 | (event->new_window_state & CDK_WINDOW_STATE_FULLSCREEN) ? 1 : 0; | |||
| 8029 | } | |||
| 8030 | ||||
| 8031 | if (event->changed_mask & CDK_WINDOW_STATE_MAXIMIZED) | |||
| 8032 | { | |||
| 8033 | priv->maximized = | |||
| 8034 | (event->new_window_state & CDK_WINDOW_STATE_MAXIMIZED) ? 1 : 0; | |||
| 8035 | g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), (((GType) ((20) << (2)))))))), window_props[PROP_IS_MAXIMIZED]); | |||
| 8036 | } | |||
| 8037 | ||||
| 8038 | update_edge_constraints (window, event); | |||
| 8039 | ||||
| 8040 | if (event->changed_mask & (CDK_WINDOW_STATE_FULLSCREEN | | |||
| 8041 | CDK_WINDOW_STATE_MAXIMIZED | | |||
| 8042 | CDK_WINDOW_STATE_TILED | | |||
| 8043 | CDK_WINDOW_STATE_TOP_TILED | | |||
| 8044 | CDK_WINDOW_STATE_RIGHT_TILED | | |||
| 8045 | CDK_WINDOW_STATE_BOTTOM_TILED | | |||
| 8046 | CDK_WINDOW_STATE_LEFT_TILED)) | |||
| 8047 | { | |||
| 8048 | update_window_style_classes (window); | |||
| 8049 | update_window_buttons (window); | |||
| 8050 | ctk_widget_queue_resize (widget); | |||
| 8051 | } | |||
| 8052 | ||||
| 8053 | return FALSE(0); | |||
| 8054 | } | |||
| 8055 | ||||
| 8056 | /** | |||
| 8057 | * ctk_window_set_has_resize_grip: | |||
| 8058 | * @window: a #CtkWindow | |||
| 8059 | * @value: %TRUE to allow a resize grip | |||
| 8060 | * | |||
| 8061 | * Sets whether @window has a corner resize grip. | |||
| 8062 | * | |||
| 8063 | * Note that the resize grip is only shown if the window | |||
| 8064 | * is actually resizable and not maximized. Use | |||
| 8065 | * ctk_window_resize_grip_is_visible() to find out if the | |||
| 8066 | * resize grip is currently shown. | |||
| 8067 | * | |||
| 8068 | * Since: 3.0 | |||
| 8069 | * | |||
| 8070 | * Deprecated: 3.14: Resize grips have been removed. | |||
| 8071 | */ | |||
| 8072 | void | |||
| 8073 | ctk_window_set_has_resize_grip (CtkWindow *window, | |||
| 8074 | gboolean value G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 8075 | { | |||
| 8076 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 8077 | } | |||
| 8078 | ||||
| 8079 | /** | |||
| 8080 | * ctk_window_resize_grip_is_visible: | |||
| 8081 | * @window: a #CtkWindow | |||
| 8082 | * | |||
| 8083 | * Determines whether a resize grip is visible for the specified window. | |||
| 8084 | * | |||
| 8085 | * Returns: %TRUE if a resize grip exists and is visible | |||
| 8086 | * | |||
| 8087 | * Since: 3.0 | |||
| 8088 | * | |||
| 8089 | * Deprecated: 3.14: Resize grips have been removed. | |||
| 8090 | */ | |||
| 8091 | gboolean | |||
| 8092 | ctk_window_resize_grip_is_visible (CtkWindow *window) | |||
| 8093 | { | |||
| 8094 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 8095 | ||||
| 8096 | return FALSE(0); | |||
| 8097 | } | |||
| 8098 | ||||
| 8099 | /** | |||
| 8100 | * ctk_window_get_has_resize_grip: | |||
| 8101 | * @window: a #CtkWindow | |||
| 8102 | * | |||
| 8103 | * Determines whether the window may have a resize grip. | |||
| 8104 | * | |||
| 8105 | * Returns: %TRUE if the window has a resize grip | |||
| 8106 | * | |||
| 8107 | * Since: 3.0 | |||
| 8108 | * | |||
| 8109 | * Deprecated: 3.14: Resize grips have been removed. | |||
| 8110 | */ | |||
| 8111 | gboolean | |||
| 8112 | ctk_window_get_has_resize_grip (CtkWindow *window) | |||
| 8113 | ||||
| 8114 | { | |||
| 8115 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 8116 | ||||
| 8117 | return FALSE(0); | |||
| 8118 | } | |||
| 8119 | ||||
| 8120 | /** | |||
| 8121 | * ctk_window_get_resize_grip_area: | |||
| 8122 | * @window: a #CtkWindow | |||
| 8123 | * @rect: (out): a pointer to a #CdkRectangle which we should store | |||
| 8124 | * the resize grip area | |||
| 8125 | * | |||
| 8126 | * If a window has a resize grip, this will retrieve the grip | |||
| 8127 | * position, width and height into the specified #CdkRectangle. | |||
| 8128 | * | |||
| 8129 | * Returns: %TRUE if the resize grip’s area was retrieved | |||
| 8130 | * | |||
| 8131 | * Since: 3.0 | |||
| 8132 | * | |||
| 8133 | * Deprecated: 3.14: Resize grips have been removed. | |||
| 8134 | */ | |||
| 8135 | gboolean | |||
| 8136 | ctk_window_get_resize_grip_area (CtkWindow *window, | |||
| 8137 | CdkRectangle *rect G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 8138 | { | |||
| 8139 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 8140 | ||||
| 8141 | return FALSE(0); | |||
| 8142 | } | |||
| 8143 | ||||
| 8144 | /* the accel_key and accel_mods fields of the key have to be setup | |||
| 8145 | * upon calling this function. it’ll then return whether that key | |||
| 8146 | * is at all used as accelerator, and if so will OR in the | |||
| 8147 | * accel_flags member of the key. | |||
| 8148 | */ | |||
| 8149 | gboolean | |||
| 8150 | _ctk_window_query_nonaccels (CtkWindow *window, | |||
| 8151 | guint accel_key, | |||
| 8152 | CdkModifierType accel_mods) | |||
| 8153 | { | |||
| 8154 | CtkWindowPrivate *priv; | |||
| 8155 | ||||
| 8156 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 8157 | ||||
| 8158 | priv = window->priv; | |||
| 8159 | ||||
| 8160 | /* movement keys are considered locked accels */ | |||
| 8161 | if (!accel_mods) | |||
| 8162 | { | |||
| 8163 | static const guint bindings[] = { | |||
| 8164 | CDK_KEY_space0x020, CDK_KEY_KP_Space0xff80, CDK_KEY_Return0xff0d, CDK_KEY_ISO_Enter0xfe34, CDK_KEY_KP_Enter0xff8d, CDK_KEY_Up0xff52, CDK_KEY_KP_Up0xff97, CDK_KEY_Down0xff54, CDK_KEY_KP_Down0xff99, | |||
| 8165 | CDK_KEY_Left0xff51, CDK_KEY_KP_Left0xff96, CDK_KEY_Right0xff53, CDK_KEY_KP_Right0xff98, CDK_KEY_Tab0xff09, CDK_KEY_KP_Tab0xff89, CDK_KEY_ISO_Left_Tab0xfe20, | |||
| 8166 | }; | |||
| 8167 | guint i; | |||
| 8168 | ||||
| 8169 | for (i = 0; i < G_N_ELEMENTS (bindings)(sizeof (bindings) / sizeof ((bindings)[0])); i++) | |||
| 8170 | if (bindings[i] == accel_key) | |||
| 8171 | return TRUE(!(0)); | |||
| 8172 | } | |||
| 8173 | ||||
| 8174 | /* mnemonics are considered locked accels */ | |||
| 8175 | if (accel_mods == priv->mnemonic_modifier) | |||
| 8176 | { | |||
| 8177 | CtkMnemonicHash *mnemonic_hash = ctk_window_get_mnemonic_hash (window, FALSE(0)); | |||
| 8178 | if (mnemonic_hash && _ctk_mnemonic_hash_lookup (mnemonic_hash, accel_key)) | |||
| 8179 | return TRUE(!(0)); | |||
| 8180 | } | |||
| 8181 | ||||
| 8182 | return FALSE(0); | |||
| 8183 | } | |||
| 8184 | ||||
| 8185 | /** | |||
| 8186 | * ctk_window_propagate_key_event: | |||
| 8187 | * @window: a #CtkWindow | |||
| 8188 | * @event: a #CdkEventKey | |||
| 8189 | * | |||
| 8190 | * Propagate a key press or release event to the focus widget and | |||
| 8191 | * up the focus container chain until a widget handles @event. | |||
| 8192 | * This is normally called by the default ::key_press_event and | |||
| 8193 | * ::key_release_event handlers for toplevel windows, | |||
| 8194 | * however in some cases it may be useful to call this directly when | |||
| 8195 | * overriding the standard key handling for a toplevel window. | |||
| 8196 | * | |||
| 8197 | * Returns: %TRUE if a widget in the focus chain handled the event. | |||
| 8198 | * | |||
| 8199 | * Since: 2.4 | |||
| 8200 | */ | |||
| 8201 | gboolean | |||
| 8202 | ctk_window_propagate_key_event (CtkWindow *window, | |||
| 8203 | CdkEventKey *event) | |||
| 8204 | { | |||
| 8205 | CtkWindowPrivate *priv = window->priv; | |||
| 8206 | gboolean handled = FALSE(0); | |||
| 8207 | CtkWidget *widget, *focus; | |||
| 8208 | ||||
| 8209 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 8210 | ||||
| 8211 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 8212 | ||||
| 8213 | focus = priv->focus_widget; | |||
| 8214 | if (focus) | |||
| 8215 | g_object_ref (focus)((__typeof__ (focus)) (g_object_ref) (focus)); | |||
| 8216 | ||||
| 8217 | while (!handled && | |||
| 8218 | focus && focus != widget && | |||
| 8219 | ctk_widget_get_toplevel (focus) == widget) | |||
| 8220 | { | |||
| 8221 | CtkWidget *parent; | |||
| 8222 | ||||
| 8223 | if (ctk_widget_is_sensitive (focus)) | |||
| 8224 | { | |||
| 8225 | handled = ctk_widget_event (focus, (CdkEvent*) event); | |||
| 8226 | if (handled) | |||
| 8227 | break; | |||
| 8228 | } | |||
| 8229 | ||||
| 8230 | parent = _ctk_widget_get_parent (focus); | |||
| 8231 | if (parent) | |||
| 8232 | g_object_ref (parent)((__typeof__ (parent)) (g_object_ref) (parent)); | |||
| 8233 | ||||
| 8234 | g_object_unref (focus); | |||
| 8235 | ||||
| 8236 | focus = parent; | |||
| 8237 | } | |||
| 8238 | ||||
| 8239 | if (focus) | |||
| 8240 | g_object_unref (focus); | |||
| 8241 | ||||
| 8242 | return handled; | |||
| 8243 | } | |||
| 8244 | ||||
| 8245 | /** | |||
| 8246 | * ctk_window_set_interactive_search_open: | |||
| 8247 | * @window: a toplevel #CtkWindow | |||
| 8248 | * @open: whether an interactive search is active for @window | |||
| 8249 | * | |||
| 8250 | * Marks @window as having an interactive (typeahead) search popup open. | |||
| 8251 | * While the flag is set, key events delivered to @window no longer | |||
| 8252 | * activate its accelerators nor its toplevel key bindings: the search | |||
| 8253 | * popup owns the keyboard. Key events still reach the focus widget, | |||
| 8254 | * which forwards them to the search popup (see for instance | |||
| 8255 | * ctk_tree_view_key_press()). | |||
| 8256 | * | |||
| 8257 | * CtkTreeView sets this flag automatically for its built-in interactive | |||
| 8258 | * search popup. Applications that implement their own interactive search | |||
| 8259 | * popup should set it while their popup is mapped and unset it | |||
| 8260 | * when the popup is hidden or destroyed. | |||
| 8261 | * | |||
| 8262 | * Since: 3.27 | |||
| 8263 | */ | |||
| 8264 | void | |||
| 8265 | ctk_window_set_interactive_search_open (CtkWindow *window, | |||
| 8266 | gboolean open) | |||
| 8267 | { | |||
| 8268 | CtkWindowPrivate *priv; | |||
| 8269 | ||||
| 8270 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 8271 | ||||
| 8272 | priv = window->priv; | |||
| 8273 | open = open != FALSE(0); | |||
| 8274 | ||||
| 8275 | if (priv->interactive_search_open == open) | |||
| 8276 | return; | |||
| 8277 | ||||
| 8278 | priv->interactive_search_open = open; | |||
| 8279 | } | |||
| 8280 | ||||
| 8281 | /** | |||
| 8282 | * ctk_window_get_interactive_search_open: | |||
| 8283 | * @window: a toplevel #CtkWindow | |||
| 8284 | * | |||
| 8285 | * Returns whether an interactive search popup is currently marked as open | |||
| 8286 | * for @window (see ctk_window_set_interactive_search_open()). | |||
| 8287 | * | |||
| 8288 | * Returns: %TRUE if an interactive search is active for @window. | |||
| 8289 | * | |||
| 8290 | * Since: 3.27 | |||
| 8291 | */ | |||
| 8292 | gboolean | |||
| 8293 | ctk_window_get_interactive_search_open (CtkWindow *window) | |||
| 8294 | { | |||
| 8295 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 8296 | ||||
| 8297 | return window->priv->interactive_search_open; | |||
| 8298 | } | |||
| 8299 | ||||
| 8300 | static gint | |||
| 8301 | ctk_window_key_press_event (CtkWidget *widget, | |||
| 8302 | CdkEventKey *event) | |||
| 8303 | { | |||
| 8304 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8305 | gboolean handled = FALSE(0); | |||
| 8306 | ||||
| 8307 | /* While an interactive search popup is open (see | |||
| 8308 | * ctk_window_set_interactive_search_open()), the search owns the | |||
| 8309 | * keyboard: the window accelerators and the toplevel binding set | |||
| 8310 | * (BackSpace bound to "go up", for instance) must not fire while the | |||
| 8311 | * user is editing the search text. The focus widget, and through it | |||
| 8312 | * the search popup, still sees the event below. */ | |||
| 8313 | if (!window->priv->interactive_search_open) | |||
| 8314 | handled = ctk_window_activate_key (window, event); | |||
| 8315 | ||||
| 8316 | /* handle focus widget key events */ | |||
| 8317 | if (!handled) | |||
| 8318 | handled = ctk_window_propagate_key_event (window, event); | |||
| 8319 | ||||
| 8320 | /* Chain up, invokes binding set */ | |||
| 8321 | if (!handled && !window->priv->interactive_search_open) | |||
| 8322 | handled = CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->key_press_event (widget, event); | |||
| 8323 | ||||
| 8324 | return handled; | |||
| 8325 | } | |||
| 8326 | ||||
| 8327 | static gint | |||
| 8328 | ctk_window_key_release_event (CtkWidget *widget, | |||
| 8329 | CdkEventKey *event) | |||
| 8330 | { | |||
| 8331 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8332 | gboolean handled = FALSE(0); | |||
| 8333 | ||||
| 8334 | /* handle focus widget key events */ | |||
| 8335 | if (!handled) | |||
| 8336 | handled = ctk_window_propagate_key_event (window, event); | |||
| 8337 | ||||
| 8338 | /* Chain up, invokes binding set */ | |||
| 8339 | if (!handled) | |||
| 8340 | handled = CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->key_release_event (widget, event); | |||
| 8341 | ||||
| 8342 | return handled; | |||
| 8343 | } | |||
| 8344 | ||||
| 8345 | static CtkWindowRegion | |||
| 8346 | get_active_region_type (CtkWindow *window, CdkEventAny *event, gint x, gint y) | |||
| 8347 | { | |||
| 8348 | CtkWindowPrivate *priv = window->priv; | |||
| 8349 | CtkAllocation allocation; | |||
| 8350 | gint i; | |||
| 8351 | ||||
| 8352 | for (i = 0; i < 8; i++) | |||
| 8353 | { | |||
| 8354 | if (event->window == priv->border_window[i]) | |||
| 8355 | return i; | |||
| 8356 | } | |||
| 8357 | ||||
| 8358 | if (priv->title_box != NULL((void*)0) && | |||
| 8359 | ctk_widget_get_visible (priv->title_box) && | |||
| 8360 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 8361 | { | |||
| 8362 | _ctk_widget_get_allocation (priv->title_box, &allocation); | |||
| 8363 | if (allocation.x <= x && allocation.x + allocation.width > x && | |||
| 8364 | allocation.y <= y && allocation.y + allocation.height > y) | |||
| 8365 | return CTK_WINDOW_REGION_TITLE; | |||
| 8366 | } | |||
| 8367 | ||||
| 8368 | return CTK_WINDOW_REGION_CONTENT; | |||
| 8369 | } | |||
| 8370 | ||||
| 8371 | static gboolean | |||
| 8372 | controller_handle_wm_event (CtkGesture *gesture, | |||
| 8373 | const CdkEvent *event) | |||
| 8374 | { | |||
| 8375 | CdkEventSequence *seq; | |||
| 8376 | gboolean retval; | |||
| 8377 | ||||
| 8378 | seq = cdk_event_get_event_sequence (event); | |||
| 8379 | retval = ctk_event_controller_handle_event (CTK_EVENT_CONTROLLER (gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((gesture)), ((ctk_event_controller_get_type ())))))), | |||
| 8380 | event); | |||
| 8381 | ||||
| 8382 | /* Reset immediately the gestures, here we don't get many guarantees | |||
| 8383 | * about whether the target window event mask will be complete enough | |||
| 8384 | * to keep gestures consistent, or whether any widget across the | |||
| 8385 | * hierarchy will be inconsistent about event handler return values. | |||
| 8386 | */ | |||
| 8387 | if (ctk_gesture_get_sequence_state (gesture, seq) == CTK_EVENT_SEQUENCE_DENIED) | |||
| 8388 | ctk_event_controller_reset (CTK_EVENT_CONTROLLER (gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((gesture)), ((ctk_event_controller_get_type ()))))))); | |||
| 8389 | ||||
| 8390 | return retval; | |||
| 8391 | } | |||
| 8392 | ||||
| 8393 | static gboolean | |||
| 8394 | ctk_window_handle_wm_event (CtkWindow *window, | |||
| 8395 | CdkEvent *event, | |||
| 8396 | gboolean run_drag) | |||
| 8397 | { | |||
| 8398 | gboolean retval = CDK_EVENT_PROPAGATE((0)); | |||
| 8399 | CtkWindowPrivate *priv; | |||
| 8400 | ||||
| 8401 | if (event->type == CDK_BUTTON_PRESS || event->type == CDK_BUTTON_RELEASE || | |||
| 8402 | event->type == CDK_TOUCH_BEGIN || event->type == CDK_TOUCH_UPDATE || | |||
| 8403 | event->type == CDK_MOTION_NOTIFY || event->type == CDK_TOUCH_END) | |||
| 8404 | { | |||
| 8405 | priv = window->priv; | |||
| 8406 | ||||
| 8407 | if (run_drag && priv->drag_gesture) | |||
| 8408 | retval |= controller_handle_wm_event (priv->drag_gesture, | |||
| 8409 | (const CdkEvent*) event); | |||
| 8410 | ||||
| 8411 | if (priv->multipress_gesture) | |||
| 8412 | retval |= controller_handle_wm_event (priv->multipress_gesture, | |||
| 8413 | (const CdkEvent*) event); | |||
| 8414 | } | |||
| 8415 | ||||
| 8416 | return retval; | |||
| 8417 | } | |||
| 8418 | ||||
| 8419 | gboolean | |||
| 8420 | _ctk_window_check_handle_wm_event (CdkEvent *event) | |||
| 8421 | { | |||
| 8422 | CtkWindowPrivate *priv; | |||
| 8423 | CtkWidget *widget; | |||
| 8424 | ||||
| 8425 | widget = ctk_get_event_widget (event); | |||
| 8426 | ||||
| 8427 | if (!CTK_IS_WINDOW (widget)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (widget)); GType _t = ((ctk_window_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; }))))) | |||
| 8428 | widget = ctk_widget_get_toplevel (widget); | |||
| 8429 | ||||
| 8430 | if (!CTK_IS_WINDOW (widget)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (widget)); GType _t = ((ctk_window_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; }))))) | |||
| 8431 | return CDK_EVENT_PROPAGATE((0)); | |||
| 8432 | ||||
| 8433 | priv = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ()))))))->priv; | |||
| 8434 | ||||
| 8435 | if (!priv->multipress_gesture) | |||
| 8436 | return CDK_EVENT_PROPAGATE((0)); | |||
| 8437 | ||||
| 8438 | if (event->type != CDK_BUTTON_PRESS && event->type != CDK_BUTTON_RELEASE && | |||
| 8439 | event->type != CDK_MOTION_NOTIFY && event->type != CDK_TOUCH_BEGIN && | |||
| 8440 | event->type != CDK_TOUCH_END && event->type != CDK_TOUCH_UPDATE) | |||
| 8441 | return CDK_EVENT_PROPAGATE((0)); | |||
| 8442 | ||||
| 8443 | if (ctk_widget_event (widget, event)) | |||
| 8444 | return CDK_EVENT_STOP((!(0))); | |||
| 8445 | ||||
| 8446 | return ctk_window_handle_wm_event (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))), event, TRUE(!(0))); | |||
| 8447 | } | |||
| 8448 | ||||
| 8449 | static gboolean | |||
| 8450 | ctk_window_event (CtkWidget *widget, | |||
| 8451 | CdkEvent *event) | |||
| 8452 | { | |||
| 8453 | if (widget != ctk_get_event_widget (event)) | |||
| 8454 | return ctk_window_handle_wm_event (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))), event, FALSE(0)); | |||
| 8455 | ||||
| 8456 | return CDK_EVENT_PROPAGATE((0)); | |||
| 8457 | } | |||
| 8458 | ||||
| 8459 | static void | |||
| 8460 | ctk_window_real_activate_default (CtkWindow *window) | |||
| 8461 | { | |||
| 8462 | ctk_window_activate_default (window); | |||
| 8463 | } | |||
| 8464 | ||||
| 8465 | static void | |||
| 8466 | ctk_window_real_activate_focus (CtkWindow *window) | |||
| 8467 | { | |||
| 8468 | ctk_window_activate_focus (window); | |||
| 8469 | } | |||
| 8470 | ||||
| 8471 | static void | |||
| 8472 | do_focus_change (CtkWidget *widget, | |||
| 8473 | gboolean in) | |||
| 8474 | { | |||
| 8475 | CdkWindow *window; | |||
| 8476 | CdkDeviceManager *device_manager; | |||
| 8477 | GList *devices, *d; | |||
| 8478 | ||||
| 8479 | g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget)); | |||
| 8480 | ||||
| 8481 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" ; | |||
| 8482 | device_manager = cdk_display_get_device_manager (ctk_widget_get_display (widget)); | |||
| 8483 | devices = cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_MASTER); | |||
| 8484 | devices = g_list_concat (devices, cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_SLAVE)); | |||
| 8485 | devices = g_list_concat (devices, cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_FLOATING)); | |||
| 8486 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ; | |||
| 8487 | ||||
| 8488 | for (d = devices; d; d = d->next) | |||
| 8489 | { | |||
| 8490 | CdkDevice *dev = d->data; | |||
| 8491 | CdkEvent *fevent; | |||
| 8492 | ||||
| 8493 | if (cdk_device_get_source (dev) != CDK_SOURCE_KEYBOARD) | |||
| 8494 | continue; | |||
| 8495 | ||||
| 8496 | /* Skip non-master keyboards that haven't | |||
| 8497 | * selected for events from this window | |||
| 8498 | */ | |||
| 8499 | window = _ctk_widget_get_window (widget); | |||
| 8500 | if (cdk_device_get_device_type (dev) != CDK_DEVICE_TYPE_MASTER && | |||
| 8501 | window && !cdk_window_get_device_events (window, dev)) | |||
| 8502 | continue; | |||
| 8503 | ||||
| 8504 | fevent = cdk_event_new (CDK_FOCUS_CHANGE); | |||
| 8505 | ||||
| 8506 | fevent->focus_change.type = CDK_FOCUS_CHANGE; | |||
| 8507 | fevent->focus_change.window = window; | |||
| 8508 | if (window) | |||
| 8509 | g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window)); | |||
| 8510 | fevent->focus_change.in = in; | |||
| 8511 | cdk_event_set_device (fevent, dev); | |||
| 8512 | ||||
| 8513 | ctk_widget_send_focus_change (widget, fevent); | |||
| 8514 | ||||
| 8515 | cdk_event_free (fevent); | |||
| 8516 | } | |||
| 8517 | ||||
| 8518 | g_list_free (devices); | |||
| 8519 | g_object_unref (widget); | |||
| 8520 | } | |||
| 8521 | ||||
| 8522 | static gboolean | |||
| 8523 | ctk_window_has_mnemonic_modifier_pressed (CtkWindow *window) | |||
| 8524 | { | |||
| 8525 | GList *seats, *s; | |||
| 8526 | gboolean retval = FALSE(0); | |||
| 8527 | ||||
| 8528 | if (!window->priv->mnemonic_modifier) | |||
| 8529 | return FALSE(0); | |||
| 8530 | ||||
| 8531 | seats = cdk_display_list_seats (ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
| 8532 | ||||
| 8533 | for (s = seats; s; s = s->next) | |||
| 8534 | { | |||
| 8535 | CdkDevice *dev = cdk_seat_get_pointer (s->data); | |||
| 8536 | CdkModifierType mask; | |||
| 8537 | ||||
| 8538 | cdk_device_get_state (dev, _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 8539 | NULL((void*)0), &mask); | |||
| 8540 | if (window->priv->mnemonic_modifier == (mask & ctk_accelerator_get_default_mod_mask ())) | |||
| 8541 | { | |||
| 8542 | retval = TRUE(!(0)); | |||
| 8543 | break; | |||
| 8544 | } | |||
| 8545 | } | |||
| 8546 | ||||
| 8547 | g_list_free (seats); | |||
| 8548 | ||||
| 8549 | return retval; | |||
| 8550 | } | |||
| 8551 | ||||
| 8552 | static gint | |||
| 8553 | ctk_window_focus_in_event (CtkWidget *widget, | |||
| 8554 | CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 8555 | { | |||
| 8556 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8557 | ||||
| 8558 | /* It appears spurious focus in events can occur when | |||
| 8559 | * the window is hidden. So we'll just check to see if | |||
| 8560 | * the window is visible before actually handling the | |||
| 8561 | * event | |||
| 8562 | */ | |||
| 8563 | if (ctk_widget_get_visible (widget)) | |||
| 8564 | { | |||
| 8565 | _ctk_window_set_has_toplevel_focus (window, TRUE(!(0))); | |||
| 8566 | _ctk_window_set_is_active (window, TRUE(!(0))); | |||
| 8567 | ||||
| 8568 | if (ctk_window_has_mnemonic_modifier_pressed (window)) | |||
| 8569 | _ctk_window_schedule_mnemonics_visible (window); | |||
| 8570 | } | |||
| 8571 | ||||
| 8572 | return FALSE(0); | |||
| 8573 | } | |||
| 8574 | ||||
| 8575 | static gint | |||
| 8576 | ctk_window_focus_out_event (CtkWidget *widget, | |||
| 8577 | CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 8578 | { | |||
| 8579 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8580 | ||||
| 8581 | _ctk_window_set_has_toplevel_focus (window, FALSE(0)); | |||
| 8582 | _ctk_window_set_is_active (window, FALSE(0)); | |||
| 8583 | ||||
| 8584 | /* set the mnemonic-visible property to false */ | |||
| 8585 | ctk_window_set_mnemonics_visible (window, FALSE(0)); | |||
| 8586 | ||||
| 8587 | return FALSE(0); | |||
| 8588 | } | |||
| 8589 | ||||
| 8590 | static CtkWindowPopover * | |||
| 8591 | _ctk_window_has_popover (CtkWindow *window, | |||
| 8592 | CtkWidget *widget) | |||
| 8593 | { | |||
| 8594 | CtkWindowPrivate *priv = window->priv; | |||
| 8595 | GList *link; | |||
| 8596 | ||||
| 8597 | for (link = priv->popovers; link; link = link->next) | |||
| 8598 | { | |||
| 8599 | CtkWindowPopover *popover = link->data; | |||
| 8600 | ||||
| 8601 | if (popover->widget == widget) | |||
| 8602 | return popover; | |||
| 8603 | } | |||
| 8604 | ||||
| 8605 | return NULL((void*)0); | |||
| 8606 | } | |||
| 8607 | ||||
| 8608 | static void | |||
| 8609 | ctk_window_remove (CtkContainer *container, | |||
| 8610 | CtkWidget *widget) | |||
| 8611 | { | |||
| 8612 | CtkWindow *window = CTK_WINDOW (container)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_window_get_type ())))))); | |||
| 8613 | ||||
| 8614 | if (widget == window->priv->title_box) | |||
| 8615 | unset_titlebar (window); | |||
| 8616 | else if (_ctk_window_has_popover (window, widget)) | |||
| 8617 | _ctk_window_remove_popover (window, widget); | |||
| 8618 | else | |||
| 8619 | CTK_CONTAINER_CLASS (ctk_window_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_container_get_type ())) ))))->remove (container, widget); | |||
| 8620 | } | |||
| 8621 | ||||
| 8622 | static void | |||
| 8623 | ctk_window_check_resize (CtkContainer *container) | |||
| 8624 | { | |||
| 8625 | /* If the window is not toplevel anymore than it's embedded somewhere, | |||
| 8626 | * so handle it like a normal window */ | |||
| 8627 | if (!_ctk_widget_is_toplevel (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) | |||
| 8628 | CTK_CONTAINER_CLASS (ctk_window_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_container_get_type ())) ))))->check_resize (container); | |||
| 8629 | else if (!_ctk_widget_get_alloc_needed (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) | |||
| 8630 | CTK_CONTAINER_CLASS (ctk_window_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_container_get_type ())) ))))->check_resize (container); | |||
| 8631 | else if (ctk_widget_get_visible (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) | |||
| 8632 | ctk_window_move_resize (CTK_WINDOW (container)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_window_get_type ()))))))); | |||
| 8633 | } | |||
| 8634 | ||||
| 8635 | static void | |||
| 8636 | ctk_window_forall (CtkContainer *container, | |||
| 8637 | gboolean include_internals, | |||
| 8638 | CtkCallback callback, | |||
| 8639 | gpointer callback_data) | |||
| 8640 | { | |||
| 8641 | CtkWindow *window = CTK_WINDOW (container)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_window_get_type ())))))); | |||
| 8642 | CtkWindowPrivate *priv = window->priv; | |||
| 8643 | CtkWidget *child; | |||
| 8644 | ||||
| 8645 | if (include_internals) | |||
| 8646 | { | |||
| 8647 | GList *l; | |||
| 8648 | ||||
| 8649 | for (l = priv->popovers; l; l = l->next) | |||
| 8650 | { | |||
| 8651 | CtkWindowPopover *data = l->data; | |||
| 8652 | (* callback) (data->widget, callback_data); | |||
| 8653 | } | |||
| 8654 | } | |||
| 8655 | ||||
| 8656 | child = ctk_bin_get_child (CTK_BIN (container)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_bin_get_type ()))))))); | |||
| 8657 | if (child != NULL((void*)0)) | |||
| 8658 | (* callback) (child, callback_data); | |||
| 8659 | ||||
| 8660 | if (priv->title_box != NULL((void*)0) && | |||
| 8661 | (priv->titlebar == NULL((void*)0) || include_internals)) | |||
| 8662 | (* callback) (priv->title_box, callback_data); | |||
| 8663 | } | |||
| 8664 | ||||
| 8665 | static gboolean | |||
| 8666 | ctk_window_focus (CtkWidget *widget, | |||
| 8667 | CtkDirectionType direction) | |||
| 8668 | { | |||
| 8669 | CtkWindowPrivate *priv; | |||
| 8670 | CtkBin *bin; | |||
| 8671 | CtkWindow *window; | |||
| 8672 | CtkContainer *container; | |||
| 8673 | CtkWidget *child; | |||
| 8674 | CtkWidget *old_focus_child; | |||
| 8675 | CtkWidget *parent; | |||
| 8676 | ||||
| 8677 | if (!_ctk_widget_is_toplevel (widget)) | |||
| 8678 | return CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->focus (widget, direction); | |||
| 8679 | ||||
| 8680 | container = CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))); | |||
| 8681 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8682 | priv = window->priv; | |||
| 8683 | bin = CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ())))))); | |||
| 8684 | ||||
| 8685 | old_focus_child = ctk_container_get_focus_child (container); | |||
| 8686 | ||||
| 8687 | /* We need a special implementation here to deal properly with wrapping | |||
| 8688 | * around in the tab chain without the danger of going into an | |||
| 8689 | * infinite loop. | |||
| 8690 | */ | |||
| 8691 | if (old_focus_child) | |||
| 8692 | { | |||
| 8693 | if (ctk_widget_child_focus (old_focus_child, direction)) | |||
| 8694 | return TRUE(!(0)); | |||
| 8695 | } | |||
| 8696 | ||||
| 8697 | if (priv->focus_widget) | |||
| 8698 | { | |||
| 8699 | if (direction == CTK_DIR_LEFT || | |||
| 8700 | direction == CTK_DIR_RIGHT || | |||
| 8701 | direction == CTK_DIR_UP || | |||
| 8702 | direction == CTK_DIR_DOWN) | |||
| 8703 | { | |||
| 8704 | return FALSE(0); | |||
| 8705 | } | |||
| 8706 | ||||
| 8707 | /* Wrapped off the end, clear the focus setting for the toplpevel */ | |||
| 8708 | parent = _ctk_widget_get_parent (priv->focus_widget); | |||
| 8709 | while (parent) | |||
| 8710 | { | |||
| 8711 | ctk_container_set_focus_child (CTK_CONTAINER (parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_container_get_type ())))))), NULL((void*)0)); | |||
| 8712 | parent = _ctk_widget_get_parent (parent); | |||
| 8713 | } | |||
| 8714 | ||||
| 8715 | ctk_window_set_focus (CTK_WINDOW (container)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_window_get_type ())))))), NULL((void*)0)); | |||
| 8716 | } | |||
| 8717 | ||||
| 8718 | /* Now try to focus the first widget in the window, | |||
| 8719 | * taking care to hook titlebar widgets into the | |||
| 8720 | * focus chain. | |||
| 8721 | */ | |||
| 8722 | if (priv->title_box != NULL((void*)0) && | |||
| 8723 | old_focus_child != NULL((void*)0) && | |||
| 8724 | priv->title_box != old_focus_child) | |||
| 8725 | child = priv->title_box; | |||
| 8726 | else | |||
| 8727 | child = ctk_bin_get_child (bin); | |||
| 8728 | ||||
| 8729 | if (child) | |||
| 8730 | { | |||
| 8731 | if (ctk_widget_child_focus (child, direction)) | |||
| 8732 | return TRUE(!(0)); | |||
| 8733 | else if (priv->title_box != NULL((void*)0) && | |||
| 8734 | priv->title_box != child && | |||
| 8735 | ctk_widget_child_focus (priv->title_box, direction)) | |||
| 8736 | return TRUE(!(0)); | |||
| 8737 | else if (priv->title_box == child && | |||
| 8738 | ctk_widget_child_focus (ctk_bin_get_child (bin), direction)) | |||
| 8739 | return TRUE(!(0)); | |||
| 8740 | } | |||
| 8741 | ||||
| 8742 | return FALSE(0); | |||
| 8743 | } | |||
| 8744 | ||||
| 8745 | static void | |||
| 8746 | ctk_window_move_focus (CtkWidget *widget, | |||
| 8747 | CtkDirectionType dir) | |||
| 8748 | { | |||
| 8749 | if (!_ctk_widget_is_toplevel (widget)) | |||
| 8750 | { | |||
| 8751 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->move_focus (widget, dir); | |||
| 8752 | return; | |||
| 8753 | } | |||
| 8754 | ||||
| 8755 | ctk_widget_child_focus (widget, dir); | |||
| 8756 | ||||
| 8757 | if (! ctk_container_get_focus_child (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))))) | |||
| 8758 | ctk_window_set_focus (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))), NULL((void*)0)); | |||
| 8759 | } | |||
| 8760 | ||||
| 8761 | static void | |||
| 8762 | ctk_window_real_set_focus (CtkWindow *window, | |||
| 8763 | CtkWidget *focus) | |||
| 8764 | { | |||
| 8765 | CtkWindowPrivate *priv = window->priv; | |||
| 8766 | CtkWidget *old_focus = priv->focus_widget; | |||
| 8767 | gboolean had_default = FALSE(0); | |||
| 8768 | gboolean focus_had_default = FALSE(0); | |||
| 8769 | gboolean old_focus_had_default = FALSE(0); | |||
| 8770 | ||||
| 8771 | if (old_focus) | |||
| 8772 | { | |||
| 8773 | g_object_ref (old_focus)((__typeof__ (old_focus)) (g_object_ref) (old_focus)); | |||
| 8774 | g_object_freeze_notify (G_OBJECT (old_focus)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((old_focus)), (((GType) ((20) << (2))))))))); | |||
| 8775 | old_focus_had_default = ctk_widget_has_default (old_focus); | |||
| 8776 | } | |||
| 8777 | if (focus) | |||
| 8778 | { | |||
| 8779 | g_object_ref (focus)((__typeof__ (focus)) (g_object_ref) (focus)); | |||
| 8780 | g_object_freeze_notify (G_OBJECT (focus)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((focus)), (((GType) ((20) << (2))))))))); | |||
| 8781 | focus_had_default = ctk_widget_has_default (focus); | |||
| 8782 | } | |||
| 8783 | ||||
| 8784 | if (priv->default_widget) | |||
| 8785 | had_default = ctk_widget_has_default (priv->default_widget); | |||
| 8786 | ||||
| 8787 | if (priv->focus_widget) | |||
| 8788 | { | |||
| 8789 | if (ctk_widget_get_receives_default (priv->focus_widget) && | |||
| 8790 | (priv->focus_widget != priv->default_widget)) | |||
| 8791 | { | |||
| 8792 | _ctk_widget_set_has_default (priv->focus_widget, FALSE(0)); | |||
| 8793 | ctk_widget_queue_draw (priv->focus_widget); | |||
| 8794 | ||||
| 8795 | if (priv->default_widget) | |||
| 8796 | _ctk_widget_set_has_default (priv->default_widget, TRUE(!(0))); | |||
| 8797 | } | |||
| 8798 | ||||
| 8799 | priv->focus_widget = NULL((void*)0); | |||
| 8800 | ||||
| 8801 | if (priv->has_focus) | |||
| 8802 | do_focus_change (old_focus, FALSE(0)); | |||
| 8803 | ||||
| 8804 | g_object_notify (G_OBJECT (old_focus)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((old_focus)), (((GType) ((20) << (2)))))))), "is-focus"); | |||
| 8805 | } | |||
| 8806 | ||||
| 8807 | /* The above notifications may have set a new focus widget, | |||
| 8808 | * if so, we don't want to override it. | |||
| 8809 | */ | |||
| 8810 | if (focus && !priv->focus_widget) | |||
| 8811 | { | |||
| 8812 | priv->focus_widget = focus; | |||
| 8813 | ||||
| 8814 | if (ctk_widget_get_receives_default (priv->focus_widget) && | |||
| 8815 | (priv->focus_widget != priv->default_widget)) | |||
| 8816 | { | |||
| 8817 | if (ctk_widget_get_can_default (priv->focus_widget)) | |||
| 8818 | _ctk_widget_set_has_default (priv->focus_widget, TRUE(!(0))); | |||
| 8819 | ||||
| 8820 | if (priv->default_widget) | |||
| 8821 | _ctk_widget_set_has_default (priv->default_widget, FALSE(0)); | |||
| 8822 | } | |||
| 8823 | ||||
| 8824 | if (priv->has_focus) | |||
| 8825 | do_focus_change (priv->focus_widget, TRUE(!(0))); | |||
| 8826 | ||||
| 8827 | /* It's possible for do_focus_change() above to have callbacks | |||
| 8828 | * that clear priv->focus_widget here. | |||
| 8829 | */ | |||
| 8830 | if (priv->focus_widget) | |||
| 8831 | g_object_notify (G_OBJECT (priv->focus_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->focus_widget)), (((GType) ((20) << (2)))) )))), "is-focus"); | |||
| 8832 | } | |||
| 8833 | ||||
| 8834 | /* If the default widget changed, a redraw will have been queued | |||
| 8835 | * on the old and new default widgets by ctk_window_set_default(), so | |||
| 8836 | * we only have to worry about the case where it didn't change. | |||
| 8837 | * We'll sometimes queue a draw twice on the new widget but that | |||
| 8838 | * is harmless. | |||
| 8839 | */ | |||
| 8840 | if (priv->default_widget && | |||
| 8841 | (had_default != ctk_widget_has_default (priv->default_widget))) | |||
| 8842 | ctk_widget_queue_draw (priv->default_widget); | |||
| 8843 | ||||
| 8844 | if (old_focus) | |||
| 8845 | { | |||
| 8846 | if (old_focus_had_default != ctk_widget_has_default (old_focus)) | |||
| 8847 | ctk_widget_queue_draw (old_focus); | |||
| 8848 | ||||
| 8849 | g_object_thaw_notify (G_OBJECT (old_focus)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((old_focus)), (((GType) ((20) << (2))))))))); | |||
| 8850 | g_object_unref (old_focus); | |||
| 8851 | } | |||
| 8852 | if (focus) | |||
| 8853 | { | |||
| 8854 | if (focus_had_default != ctk_widget_has_default (focus)) | |||
| 8855 | ctk_widget_queue_draw (focus); | |||
| 8856 | ||||
| 8857 | g_object_thaw_notify (G_OBJECT (focus)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((focus)), (((GType) ((20) << (2))))))))); | |||
| 8858 | g_object_unref (focus); | |||
| 8859 | } | |||
| 8860 | } | |||
| 8861 | ||||
| 8862 | static void | |||
| 8863 | ctk_window_get_preferred_width (CtkWidget *widget, | |||
| 8864 | gint *minimum_size, | |||
| 8865 | gint *natural_size) | |||
| 8866 | { | |||
| 8867 | CtkWindow *window; | |||
| 8868 | CtkWidget *child; | |||
| 8869 | CtkWindowPrivate *priv; | |||
| 8870 | guint border_width; | |||
| 8871 | gint title_min = 0, title_nat = 0; | |||
| 8872 | gint child_min = 0, child_nat = 0; | |||
| 8873 | CtkBorder window_border = { 0 }; | |||
| 8874 | gboolean has_size_request; | |||
| 8875 | ||||
| 8876 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8877 | priv = window->priv; | |||
| 8878 | child = ctk_bin_get_child (CTK_BIN (window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_bin_get_type ()))))))); | |||
| 8879 | has_size_request = ctk_widget_has_size_request (widget); | |||
| 8880 | ||||
| 8881 | border_width = ctk_container_get_border_width (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ()))))))); | |||
| 8882 | ||||
| 8883 | if (priv->decorated && | |||
| 8884 | !priv->fullscreen) | |||
| 8885 | { | |||
| 8886 | get_shadow_width (window, &window_border); | |||
| 8887 | ||||
| 8888 | if (priv->title_box != NULL((void*)0) && | |||
| 8889 | ctk_widget_get_visible (priv->title_box) && | |||
| 8890 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 8891 | ctk_widget_get_preferred_width (priv->title_box, | |||
| 8892 | &title_min, &title_nat); | |||
| 8893 | ||||
| 8894 | title_min += window_border.left + window_border.right; | |||
| 8895 | title_nat += window_border.left + window_border.right; | |||
| 8896 | } | |||
| 8897 | ||||
| 8898 | if (child && ctk_widget_get_visible (child)) | |||
| 8899 | { | |||
| 8900 | ctk_widget_get_preferred_width (child, &child_min, &child_nat); | |||
| 8901 | ||||
| 8902 | if (child_nat == 0 && !has_size_request) | |||
| 8903 | child_nat = NO_CONTENT_CHILD_NAT200; | |||
| 8904 | child_min += border_width * 2 + | |||
| 8905 | window_border.left + window_border.right; | |||
| 8906 | child_nat += border_width * 2 + | |||
| 8907 | window_border.left + window_border.right; | |||
| 8908 | } | |||
| 8909 | else if (!has_size_request) | |||
| 8910 | { | |||
| 8911 | child_nat = NO_CONTENT_CHILD_NAT200; | |||
| 8912 | } | |||
| 8913 | ||||
| 8914 | *minimum_size = MAX (title_min, child_min)(((title_min) > (child_min)) ? (title_min) : (child_min)); | |||
| 8915 | *natural_size = MAX (title_nat, child_nat)(((title_nat) > (child_nat)) ? (title_nat) : (child_nat)); | |||
| 8916 | } | |||
| 8917 | ||||
| 8918 | ||||
| 8919 | static void | |||
| 8920 | ctk_window_get_preferred_width_for_height (CtkWidget *widget, | |||
| 8921 | gint height, | |||
| 8922 | gint *minimum_size, | |||
| 8923 | gint *natural_size) | |||
| 8924 | { | |||
| 8925 | CtkWindow *window; | |||
| 8926 | CtkWidget *child; | |||
| 8927 | CtkWindowPrivate *priv; | |||
| 8928 | guint border_width; | |||
| 8929 | gint title_min = 0, title_nat = 0; | |||
| 8930 | gint child_min = 0, child_nat = 0; | |||
| 8931 | gint title_height = 0; | |||
| 8932 | CtkBorder window_border = { 0 }; | |||
| 8933 | gboolean has_size_request; | |||
| 8934 | ||||
| 8935 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 8936 | priv = window->priv; | |||
| 8937 | child = ctk_bin_get_child (CTK_BIN (window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_bin_get_type ()))))))); | |||
| 8938 | has_size_request = ctk_widget_has_size_request (widget); | |||
| 8939 | ||||
| 8940 | border_width = ctk_container_get_border_width (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ()))))))); | |||
| 8941 | ||||
| 8942 | height -= 2 * border_width; | |||
| 8943 | ||||
| 8944 | if (priv->decorated && | |||
| 8945 | !priv->fullscreen) | |||
| 8946 | { | |||
| 8947 | get_shadow_width (window, &window_border); | |||
| 8948 | ||||
| 8949 | height -= window_border.top + window_border.bottom; | |||
| 8950 | ||||
| 8951 | if (priv->title_box != NULL((void*)0) && | |||
| 8952 | ctk_widget_get_visible (priv->title_box) && | |||
| 8953 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 8954 | { | |||
| 8955 | ctk_widget_get_preferred_height (priv->title_box, | |||
| 8956 | NULL((void*)0), &title_height); | |||
| 8957 | ctk_widget_get_preferred_width_for_height (priv->title_box, | |||
| 8958 | title_height, | |||
| 8959 | &title_min, &title_nat); | |||
| 8960 | height -= title_height; | |||
| 8961 | } | |||
| 8962 | ||||
| 8963 | title_min += window_border.left + window_border.right; | |||
| 8964 | title_nat += window_border.left + window_border.right; | |||
| 8965 | } | |||
| 8966 | ||||
| 8967 | if (child && ctk_widget_get_visible (child)) | |||
| 8968 | { | |||
| 8969 | ctk_widget_get_preferred_width_for_height (child, | |||
| 8970 | MAX (height, 0)(((height) > (0)) ? (height) : (0)), | |||
| 8971 | &child_min, &child_nat); | |||
| 8972 | ||||
| 8973 | if (child_nat == 0 && height == 0 && !has_size_request) | |||
| 8974 | child_nat = NO_CONTENT_CHILD_NAT200; | |||
| 8975 | child_min += border_width * 2 + | |||
| 8976 | window_border.left + window_border.right; | |||
| 8977 | child_nat += border_width * 2 + | |||
| 8978 | window_border.left + window_border.right; | |||
| 8979 | } | |||
| 8980 | else if (!has_size_request) | |||
| 8981 | { | |||
| 8982 | child_nat = NO_CONTENT_CHILD_NAT200; | |||
| 8983 | } | |||
| 8984 | ||||
| 8985 | *minimum_size = MAX (title_min, child_min)(((title_min) > (child_min)) ? (title_min) : (child_min)); | |||
| 8986 | *natural_size = MAX (title_nat, child_nat)(((title_nat) > (child_nat)) ? (title_nat) : (child_nat)); | |||
| 8987 | } | |||
| 8988 | ||||
| 8989 | static void | |||
| 8990 | ctk_window_get_preferred_height (CtkWidget *widget, | |||
| 8991 | gint *minimum_size, | |||
| 8992 | gint *natural_size) | |||
| 8993 | { | |||
| 8994 | CtkWindow *window; | |||
| 8995 | CtkWindowPrivate *priv; | |||
| 8996 | CtkWidget *child; | |||
| 8997 | guint border_width; | |||
| 8998 | int title_min = 0; | |||
| 8999 | int title_height = 0; | |||
| 9000 | CtkBorder window_border = { 0 }; | |||
| 9001 | gboolean has_size_request; | |||
| 9002 | ||||
| 9003 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 9004 | priv = window->priv; | |||
| 9005 | child = ctk_bin_get_child (CTK_BIN (window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_bin_get_type ()))))))); | |||
| 9006 | has_size_request = ctk_widget_has_size_request (widget); | |||
| 9007 | ||||
| 9008 | *minimum_size = 0; | |||
| 9009 | *natural_size = 0; | |||
| 9010 | ||||
| 9011 | border_width = ctk_container_get_border_width (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ()))))))); | |||
| 9012 | ||||
| 9013 | if (priv->decorated && | |||
| 9014 | !priv->fullscreen) | |||
| 9015 | { | |||
| 9016 | get_shadow_width (window, &window_border); | |||
| 9017 | ||||
| 9018 | if (priv->title_box != NULL((void*)0) && | |||
| 9019 | ctk_widget_get_visible (priv->title_box) && | |||
| 9020 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 9021 | ctk_widget_get_preferred_height (priv->title_box, | |||
| 9022 | &title_min, | |||
| 9023 | &title_height); | |||
| 9024 | ||||
| 9025 | *minimum_size = title_min + | |||
| 9026 | window_border.top + window_border.bottom; | |||
| 9027 | ||||
| 9028 | *natural_size = title_height + | |||
| 9029 | window_border.top + window_border.bottom; | |||
| 9030 | } | |||
| 9031 | ||||
| 9032 | if (child && ctk_widget_get_visible (child)) | |||
| 9033 | { | |||
| 9034 | gint child_min, child_nat; | |||
| 9035 | ctk_widget_get_preferred_height (child, &child_min, &child_nat); | |||
| 9036 | ||||
| 9037 | if (child_nat == 0 && !has_size_request) | |||
| 9038 | child_nat = NO_CONTENT_CHILD_NAT200; | |||
| 9039 | *minimum_size += child_min + 2 * border_width; | |||
| 9040 | *natural_size += child_nat + 2 * border_width; | |||
| 9041 | } | |||
| 9042 | else if (!has_size_request) | |||
| 9043 | { | |||
| 9044 | *natural_size += NO_CONTENT_CHILD_NAT200; | |||
| 9045 | } | |||
| 9046 | } | |||
| 9047 | ||||
| 9048 | ||||
| 9049 | static void | |||
| 9050 | ctk_window_get_preferred_height_for_width (CtkWidget *widget, | |||
| 9051 | gint width, | |||
| 9052 | gint *minimum_size, | |||
| 9053 | gint *natural_size) | |||
| 9054 | { | |||
| 9055 | CtkWindow *window; | |||
| 9056 | CtkWindowPrivate *priv; | |||
| 9057 | CtkWidget *child; | |||
| 9058 | guint border_width; | |||
| 9059 | int title_min = 0; | |||
| 9060 | int title_height = 0; | |||
| 9061 | CtkBorder window_border = { 0 }; | |||
| 9062 | gboolean has_size_request; | |||
| 9063 | ||||
| 9064 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 9065 | priv = window->priv; | |||
| 9066 | child = ctk_bin_get_child (CTK_BIN (window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_bin_get_type ()))))))); | |||
| 9067 | has_size_request = ctk_widget_has_size_request (widget); | |||
| 9068 | ||||
| 9069 | *minimum_size = 0; | |||
| 9070 | *natural_size = 0; | |||
| 9071 | ||||
| 9072 | border_width = ctk_container_get_border_width (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ()))))))); | |||
| 9073 | ||||
| 9074 | width -= 2 * border_width; | |||
| 9075 | ||||
| 9076 | if (priv->decorated && | |||
| 9077 | !priv->fullscreen) | |||
| 9078 | { | |||
| 9079 | get_shadow_width (window, &window_border); | |||
| 9080 | ||||
| 9081 | width -= window_border.left + window_border.right; | |||
| 9082 | ||||
| 9083 | if (priv->title_box != NULL((void*)0) && | |||
| 9084 | ctk_widget_get_visible (priv->title_box) && | |||
| 9085 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 9086 | ctk_widget_get_preferred_height_for_width (priv->title_box, | |||
| 9087 | MAX (width, 0)(((width) > (0)) ? (width) : (0)), | |||
| 9088 | &title_min, | |||
| 9089 | &title_height); | |||
| 9090 | ||||
| 9091 | *minimum_size = title_min + | |||
| 9092 | window_border.top + window_border.bottom; | |||
| 9093 | ||||
| 9094 | *natural_size = title_height + | |||
| 9095 | window_border.top + window_border.bottom; | |||
| 9096 | } | |||
| 9097 | ||||
| 9098 | if (child && ctk_widget_get_visible (child)) | |||
| 9099 | { | |||
| 9100 | gint child_min, child_nat; | |||
| 9101 | ctk_widget_get_preferred_height_for_width (child, MAX (width, 0)(((width) > (0)) ? (width) : (0)), | |||
| 9102 | &child_min, &child_nat); | |||
| 9103 | ||||
| 9104 | if (child_nat == 0 && width == 0 && !has_size_request) | |||
| 9105 | child_nat = NO_CONTENT_CHILD_NAT200; | |||
| 9106 | *minimum_size += child_min + 2 * border_width; | |||
| 9107 | *natural_size += child_nat + 2 * border_width; | |||
| 9108 | } | |||
| 9109 | else if (!has_size_request) | |||
| 9110 | { | |||
| 9111 | *natural_size += NO_CONTENT_CHILD_NAT200; | |||
| 9112 | } | |||
| 9113 | } | |||
| 9114 | ||||
| 9115 | static void | |||
| 9116 | ctk_window_state_flags_changed (CtkWidget *widget, | |||
| 9117 | CtkStateFlags previous_state) | |||
| 9118 | { | |||
| 9119 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 9120 | CtkWindowPrivate *priv = window->priv; | |||
| 9121 | CtkStateFlags state; | |||
| 9122 | ||||
| 9123 | state = ctk_widget_get_state_flags (widget); | |||
| 9124 | ctk_css_node_set_state (priv->decoration_node, state); | |||
| 9125 | ||||
| 9126 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->state_flags_changed (widget, previous_state); | |||
| 9127 | } | |||
| 9128 | ||||
| 9129 | static void | |||
| 9130 | ctk_window_style_updated (CtkWidget *widget) | |||
| 9131 | { | |||
| 9132 | CtkCssStyleChange *change = ctk_style_context_get_change (ctk_widget_get_style_context (widget)); | |||
| 9133 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
| 9134 | ||||
| 9135 | CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->style_updated (widget); | |||
| 9136 | ||||
| 9137 | if (!_ctk_widget_get_alloc_needed (widget) && | |||
| 9138 | (change == NULL((void*)0) || ctk_css_style_change_changes_property (change, CTK_CSS_PROPERTY_BACKGROUND_COLOR))) | |||
| 9139 | { | |||
| 9140 | CtkAllocation allocation; | |||
| 9141 | CtkBorder window_border; | |||
| 9142 | ||||
| 9143 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 9144 | get_shadow_width (window, &window_border); | |||
| 9145 | ||||
| 9146 | update_opaque_region (window, &window_border, &allocation); | |||
| 9147 | } | |||
| 9148 | ||||
| 9149 | if (change == NULL((void*)0) || ctk_css_style_change_changes_property (change, CTK_CSS_PROPERTY_ICON_THEME)) | |||
| 9150 | update_themed_icon (window); | |||
| 9151 | } | |||
| 9152 | ||||
| 9153 | /** | |||
| 9154 | * _ctk_window_unset_focus_and_default: | |||
| 9155 | * @window: a #CtkWindow | |||
| 9156 | * @widget: a widget inside of @window | |||
| 9157 | * | |||
| 9158 | * Checks whether the focus and default widgets of @window are | |||
| 9159 | * @widget or a descendent of @widget, and if so, unset them. | |||
| 9160 | * | |||
| 9161 | * If @widget is a #CtkPopover then nothing will be done with | |||
| 9162 | * respect to the default widget of @window, the reason being that | |||
| 9163 | * popovers already have specific logic for clearing/restablishing | |||
| 9164 | * the default widget of its enclosing window. | |||
| 9165 | **/ | |||
| 9166 | void | |||
| 9167 | _ctk_window_unset_focus_and_default (CtkWindow *window, | |||
| 9168 | CtkWidget *widget) | |||
| 9169 | ||||
| 9170 | { | |||
| 9171 | CtkWindowPrivate *priv = window->priv; | |||
| 9172 | CtkWidget *child; | |||
| 9173 | CtkWidget *parent; | |||
| 9174 | ||||
| 9175 | g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window)); | |||
| 9176 | g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget)); | |||
| 9177 | ||||
| 9178 | parent = _ctk_widget_get_parent (widget); | |||
| 9179 | if (ctk_container_get_focus_child (CTK_CONTAINER (parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_container_get_type ()))))))) == widget) | |||
| 9180 | { | |||
| 9181 | child = priv->focus_widget; | |||
| 9182 | ||||
| 9183 | while (child && child != widget) | |||
| 9184 | child = _ctk_widget_get_parent (child); | |||
| 9185 | ||||
| 9186 | if (child == widget) | |||
| 9187 | ctk_window_set_focus (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), NULL((void*)0)); | |||
| 9188 | } | |||
| 9189 | ||||
| 9190 | if (!CTK_IS_POPOVER (widget)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (widget)); GType _t = ((ctk_popover_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; }))))) | |||
| 9191 | { | |||
| 9192 | child = priv->default_widget; | |||
| 9193 | ||||
| 9194 | while (child && child != widget) | |||
| 9195 | child = _ctk_widget_get_parent (child); | |||
| 9196 | ||||
| 9197 | if (child == widget) | |||
| 9198 | ctk_window_set_default (window, NULL((void*)0)); | |||
| 9199 | } | |||
| 9200 | ||||
| 9201 | g_object_unref (widget); | |||
| 9202 | g_object_unref (window); | |||
| 9203 | } | |||
| 9204 | ||||
| 9205 | static void | |||
| 9206 | popup_menu_detach (CtkWidget *widget, | |||
| 9207 | CtkMenu *menu G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 9208 | { | |||
| 9209 | CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ()))))))->priv->popup_menu = NULL((void*)0); | |||
| 9210 | } | |||
| 9211 | ||||
| 9212 | static CdkWindowState | |||
| 9213 | ctk_window_get_state (CtkWindow *window) | |||
| 9214 | { | |||
| 9215 | CdkWindowState state; | |||
| 9216 | CdkWindow *cdk_window; | |||
| 9217 | ||||
| 9218 | cdk_window = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 9219 | ||||
| 9220 | state = 0; | |||
| 9221 | ||||
| 9222 | if (cdk_window) | |||
| 9223 | state = cdk_window_get_state (cdk_window); | |||
| 9224 | ||||
| 9225 | return state; | |||
| 9226 | } | |||
| 9227 | ||||
| 9228 | static void | |||
| 9229 | restore_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9230 | gpointer user_data) | |||
| 9231 | { | |||
| 9232 | CtkWindow *window = CTK_WINDOW (user_data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_window_get_type ())))))); | |||
| 9233 | CtkWindowPrivate *priv = window->priv; | |||
| 9234 | CdkWindowState state; | |||
| 9235 | ||||
| 9236 | if (priv->maximized) | |||
| 9237 | { | |||
| 9238 | ctk_window_unmaximize (window); | |||
| 9239 | ||||
| 9240 | return; | |||
| 9241 | } | |||
| 9242 | ||||
| 9243 | state = ctk_window_get_state (window); | |||
| 9244 | ||||
| 9245 | if (state & CDK_WINDOW_STATE_ICONIFIED) | |||
| 9246 | ctk_window_deiconify (window); | |||
| 9247 | } | |||
| 9248 | ||||
| 9249 | static void | |||
| 9250 | move_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9251 | gpointer user_data) | |||
| 9252 | { | |||
| 9253 | CtkWindow *window = CTK_WINDOW (user_data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_window_get_type ())))))); | |||
| 9254 | ||||
| 9255 | ctk_window_begin_move_drag (window, | |||
| 9256 | 0, /* 0 means "use keyboard" */ | |||
| 9257 | 0, 0, | |||
| 9258 | CDK_CURRENT_TIME0L); | |||
| 9259 | } | |||
| 9260 | ||||
| 9261 | static void | |||
| 9262 | resize_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9263 | gpointer user_data) | |||
| 9264 | { | |||
| 9265 | CtkWindow *window = CTK_WINDOW (user_data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_window_get_type ())))))); | |||
| 9266 | ||||
| 9267 | ctk_window_begin_resize_drag (window, | |||
| 9268 | 0, | |||
| 9269 | 0, /* 0 means "use keyboard" */ | |||
| 9270 | 0, 0, | |||
| 9271 | CDK_CURRENT_TIME0L); | |||
| 9272 | } | |||
| 9273 | ||||
| 9274 | static void | |||
| 9275 | minimize_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9276 | gpointer user_data) | |||
| 9277 | { | |||
| 9278 | CtkWindow *window = CTK_WINDOW (user_data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_window_get_type ())))))); | |||
| 9279 | CtkWindowPrivate *priv = window->priv; | |||
| 9280 | ||||
| 9281 | /* Turns out, we can't iconify a maximized window */ | |||
| 9282 | if (priv->maximized) | |||
| 9283 | ctk_window_unmaximize (window); | |||
| 9284 | ||||
| 9285 | ctk_window_iconify (window); | |||
| 9286 | } | |||
| 9287 | ||||
| 9288 | static void | |||
| 9289 | maximize_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9290 | gpointer user_data) | |||
| 9291 | { | |||
| 9292 | CtkWindow *window = CTK_WINDOW (user_data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_window_get_type ())))))); | |||
| 9293 | CdkWindowState state; | |||
| 9294 | ||||
| 9295 | state = ctk_window_get_state (window); | |||
| 9296 | ||||
| 9297 | if (state & CDK_WINDOW_STATE_ICONIFIED) | |||
| 9298 | ctk_window_deiconify (window); | |||
| 9299 | ||||
| 9300 | ctk_window_maximize (window); | |||
| 9301 | } | |||
| 9302 | ||||
| 9303 | static void | |||
| 9304 | ontop_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9305 | gpointer user_data) | |||
| 9306 | { | |||
| 9307 | CtkWindow *window = (CtkWindow *)user_data; | |||
| 9308 | ||||
| 9309 | ctk_window_set_keep_above (window, !window->priv->above_initially); | |||
| 9310 | } | |||
| 9311 | ||||
| 9312 | static void | |||
| 9313 | close_window_clicked (CtkMenuItem *menuitem G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 9314 | gpointer user_data) | |||
| 9315 | { | |||
| 9316 | CtkWindow *window = (CtkWindow *)user_data; | |||
| 9317 | ||||
| 9318 | if (window->priv->delete_event_handler == 0) | |||
| 9319 | send_delete_event (window); | |||
| 9320 | } | |||
| 9321 | ||||
| 9322 | static void | |||
| 9323 | ctk_window_do_popup_fallback (CtkWindow *window, | |||
| 9324 | CdkEventButton *event) | |||
| 9325 | { | |||
| 9326 | CtkWindowPrivate *priv = window->priv; | |||
| 9327 | CtkWidget *menuitem; | |||
| 9328 | CdkWindowState state; | |||
| 9329 | gboolean maximized, iconified; | |||
| 9330 | ||||
| 9331 | if (priv->popup_menu) | |||
| 9332 | ctk_widget_destroy (priv->popup_menu); | |||
| 9333 | ||||
| 9334 | state = ctk_window_get_state (window); | |||
| 9335 | ||||
| 9336 | iconified = (state & CDK_WINDOW_STATE_ICONIFIED) == CDK_WINDOW_STATE_ICONIFIED; | |||
| 9337 | maximized = priv->maximized && !iconified; | |||
| 9338 | ||||
| 9339 | priv->popup_menu = ctk_menu_new (); | |||
| 9340 | ctk_style_context_add_class (ctk_widget_get_style_context (priv->popup_menu), | |||
| 9341 | CTK_STYLE_CLASS_CONTEXT_MENU"context-menu"); | |||
| 9342 | ||||
| 9343 | ctk_menu_attach_to_widget (CTK_MENU (priv->popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_get_type ())))))), | |||
| 9344 | CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), | |||
| 9345 | popup_menu_detach); | |||
| 9346 | ||||
| 9347 | menuitem = ctk_menu_item_new_with_label (_("Restore")((char *) g_dgettext ("ctk30", "Restore"))); | |||
| 9348 | ctk_widget_show (menuitem); | |||
| 9349 | /* "Restore" means "Unmaximize" or "Unminimize" | |||
| 9350 | * (yes, some WMs allow window menu to be shown for minimized windows). | |||
| 9351 | * Not restorable: | |||
| 9352 | * - visible windows that are not maximized or minimized | |||
| 9353 | * - non-resizable windows that are not minimized | |||
| 9354 | * - non-normal windows | |||
| 9355 | */ | |||
| 9356 | if ((ctk_widget_is_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) && | |||
| 9357 | !(maximized || iconified)) || | |||
| 9358 | (!iconified && !priv->resizable) || | |||
| 9359 | priv->type_hint != CDK_WINDOW_TYPE_HINT_NORMAL) | |||
| 9360 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9361 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (restore_window_clicked ))), (window), ((void*)0), (GConnectFlags) 0) | |||
| 9362 | G_CALLBACK (restore_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (restore_window_clicked ))), (window), ((void*)0), (GConnectFlags) 0); | |||
| 9363 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9364 | ||||
| 9365 | menuitem = ctk_menu_item_new_with_label (_("Move")((char *) g_dgettext ("ctk30", "Move"))); | |||
| 9366 | ctk_widget_show (menuitem); | |||
| 9367 | if (maximized || iconified) | |||
| 9368 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9369 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (move_window_clicked))) , (window), ((void*)0), (GConnectFlags) 0) | |||
| 9370 | G_CALLBACK (move_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (move_window_clicked))) , (window), ((void*)0), (GConnectFlags) 0); | |||
| 9371 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9372 | ||||
| 9373 | menuitem = ctk_menu_item_new_with_label (_("Resize")((char *) g_dgettext ("ctk30", "Resize"))); | |||
| 9374 | ctk_widget_show (menuitem); | |||
| 9375 | if (!priv->resizable || maximized || iconified) | |||
| 9376 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9377 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (resize_window_clicked) )), (window), ((void*)0), (GConnectFlags) 0) | |||
| 9378 | G_CALLBACK (resize_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (resize_window_clicked) )), (window), ((void*)0), (GConnectFlags) 0); | |||
| 9379 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9380 | ||||
| 9381 | menuitem = ctk_menu_item_new_with_label (_("Minimize")((char *) g_dgettext ("ctk30", "Minimize"))); | |||
| 9382 | ctk_widget_show (menuitem); | |||
| 9383 | if (iconified || | |||
| 9384 | priv->type_hint != CDK_WINDOW_TYPE_HINT_NORMAL) | |||
| 9385 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9386 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (minimize_window_clicked ))), (window), ((void*)0), (GConnectFlags) 0) | |||
| 9387 | G_CALLBACK (minimize_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (minimize_window_clicked ))), (window), ((void*)0), (GConnectFlags) 0); | |||
| 9388 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9389 | ||||
| 9390 | menuitem = ctk_menu_item_new_with_label (_("Maximize")((char *) g_dgettext ("ctk30", "Maximize"))); | |||
| 9391 | ctk_widget_show (menuitem); | |||
| 9392 | if (maximized || | |||
| 9393 | !priv->resizable || | |||
| 9394 | priv->type_hint != CDK_WINDOW_TYPE_HINT_NORMAL) | |||
| 9395 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9396 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (maximize_window_clicked ))), (window), ((void*)0), (GConnectFlags) 0) | |||
| 9397 | G_CALLBACK (maximize_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (maximize_window_clicked ))), (window), ((void*)0), (GConnectFlags) 0); | |||
| 9398 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9399 | ||||
| 9400 | menuitem = ctk_separator_menu_item_new (); | |||
| 9401 | ctk_widget_show (menuitem); | |||
| 9402 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9403 | ||||
| 9404 | menuitem = ctk_check_menu_item_new_with_label (_("Always on Top")((char *) g_dgettext ("ctk30", "Always on Top"))); | |||
| 9405 | ctk_check_menu_item_set_active (CTK_CHECK_MENU_ITEM (menuitem)((((CtkCheckMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_check_menu_item_get_type ( ))))))), priv->above_initially); | |||
| 9406 | if (maximized) | |||
| 9407 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9408 | ctk_widget_show (menuitem); | |||
| 9409 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (ontop_window_clicked)) ), (window), ((void*)0), (GConnectFlags) 0) | |||
| 9410 | G_CALLBACK (ontop_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (ontop_window_clicked)) ), (window), ((void*)0), (GConnectFlags) 0); | |||
| 9411 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9412 | ||||
| 9413 | menuitem = ctk_separator_menu_item_new (); | |||
| 9414 | ctk_widget_show (menuitem); | |||
| 9415 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9416 | ||||
| 9417 | menuitem = ctk_menu_item_new_with_label (_("Close")((char *) g_dgettext ("ctk30", "Close"))); | |||
| 9418 | ctk_widget_show (menuitem); | |||
| 9419 | if (!priv->deletable) | |||
| 9420 | ctk_widget_set_sensitive (menuitem, FALSE(0)); | |||
| 9421 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (close_window_clicked)) ), (window), ((void*)0), (GConnectFlags) 0) | |||
| 9422 | G_CALLBACK (close_window_clicked), window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (close_window_clicked)) ), (window), ((void*)0), (GConnectFlags) 0); | |||
| 9423 | ctk_menu_shell_append (CTK_MENU_SHELL (priv->popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_shell_get_type ()))))) ), menuitem); | |||
| 9424 | ctk_menu_popup_at_pointer (CTK_MENU (priv->popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->popup_menu)), ((ctk_menu_get_type ())))))), (CdkEvent *) event); | |||
| 9425 | } | |||
| 9426 | ||||
| 9427 | static void | |||
| 9428 | ctk_window_do_popup (CtkWindow *window, | |||
| 9429 | CdkEventButton *event) | |||
| 9430 | { | |||
| 9431 | if (!cdk_window_show_window_menu (_ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 9432 | (CdkEvent *) event)) | |||
| 9433 | ctk_window_do_popup_fallback (window, event); | |||
| 9434 | } | |||
| 9435 | ||||
| 9436 | /********************************* | |||
| 9437 | * Functions related to resizing * | |||
| 9438 | *********************************/ | |||
| 9439 | ||||
| 9440 | static void | |||
| 9441 | geometry_size_to_pixels (CdkGeometry *geometry, | |||
| 9442 | guint flags, | |||
| 9443 | gint *width, | |||
| 9444 | gint *height) | |||
| 9445 | { | |||
| 9446 | gint base_width = 0; | |||
| 9447 | gint base_height = 0; | |||
| 9448 | gint min_width = 0; | |||
| 9449 | gint min_height = 0; | |||
| 9450 | gint width_inc = 1; | |||
| 9451 | gint height_inc = 1; | |||
| 9452 | ||||
| 9453 | if (flags & CDK_HINT_BASE_SIZE) | |||
| 9454 | { | |||
| 9455 | base_width = geometry->base_width; | |||
| 9456 | base_height = geometry->base_height; | |||
| 9457 | } | |||
| 9458 | if (flags & CDK_HINT_MIN_SIZE) | |||
| 9459 | { | |||
| 9460 | min_width = geometry->min_width; | |||
| 9461 | min_height = geometry->min_height; | |||
| 9462 | } | |||
| 9463 | if (flags & CDK_HINT_RESIZE_INC) | |||
| 9464 | { | |||
| 9465 | width_inc = geometry->width_inc; | |||
| 9466 | height_inc = geometry->height_inc; | |||
| 9467 | } | |||
| 9468 | ||||
| 9469 | if (width) | |||
| 9470 | *width = MAX (*width * width_inc + base_width, min_width)(((*width * width_inc + base_width) > (min_width)) ? (*width * width_inc + base_width) : (min_width)); | |||
| 9471 | if (height) | |||
| 9472 | *height = MAX (*height * height_inc + base_height, min_height)(((*height * height_inc + base_height) > (min_height)) ? ( *height * height_inc + base_height) : (min_height)); | |||
| 9473 | } | |||
| 9474 | ||||
| 9475 | /* This function doesn't constrain to geometry hints */ | |||
| 9476 | static void | |||
| 9477 | ctk_window_compute_configure_request_size (CtkWindow *window, | |||
| 9478 | CdkGeometry *geometry, | |||
| 9479 | guint flags, | |||
| 9480 | gint *width, | |||
| 9481 | gint *height) | |||
| 9482 | { | |||
| 9483 | CtkWindowPrivate *priv = window->priv; | |||
| 9484 | CtkWindowGeometryInfo *info; | |||
| 9485 | int w, h; | |||
| 9486 | ||||
| 9487 | /* Preconditions: | |||
| 9488 | * - we've done a size request | |||
| 9489 | */ | |||
| 9490 | ||||
| 9491 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 9492 | ||||
| 9493 | if ((priv->need_default_size || priv->force_resize) && | |||
| 9494 | !priv->maximized && | |||
| 9495 | !priv->fullscreen) | |||
| 9496 | { | |||
| 9497 | ctk_window_guess_default_size (window, width, height); | |||
| 9498 | ctk_window_get_remembered_size (window, &w, &h); | |||
| 9499 | *width = MAX (*width, w)(((*width) > (w)) ? (*width) : (w)); | |||
| 9500 | *height = MAX (*height, h)(((*height) > (h)) ? (*height) : (h)); | |||
| 9501 | ||||
| 9502 | /* Override with default size */ | |||
| 9503 | if (info) | |||
| 9504 | { | |||
| 9505 | /* Take width of shadows/headerbar into account. We want to set the | |||
| 9506 | * default size of the content area and not the window area. | |||
| 9507 | */ | |||
| 9508 | gint default_width_csd = info->default_width; | |||
| 9509 | gint default_height_csd = info->default_height; | |||
| 9510 | ctk_window_update_csd_size (window, | |||
| 9511 | &default_width_csd, &default_height_csd, | |||
| 9512 | INCLUDE_CSD_SIZE); | |||
| 9513 | ||||
| 9514 | if (info->default_width > 0) | |||
| 9515 | *width = default_width_csd; | |||
| 9516 | if (info->default_height > 0) | |||
| 9517 | *height = default_height_csd; | |||
| 9518 | ||||
| 9519 | if (info->default_is_geometry) | |||
| 9520 | geometry_size_to_pixels (geometry, flags, | |||
| 9521 | info->default_width > 0 ? width : NULL((void*)0), | |||
| 9522 | info->default_height > 0 ? height : NULL((void*)0)); | |||
| 9523 | } | |||
| 9524 | } | |||
| 9525 | else | |||
| 9526 | { | |||
| 9527 | /* Default to keeping current size */ | |||
| 9528 | ctk_window_get_remembered_size (window, width, height); | |||
| 9529 | } | |||
| 9530 | ||||
| 9531 | if (info) | |||
| 9532 | { | |||
| 9533 | gint resize_width_csd = info->resize_width; | |||
| 9534 | gint resize_height_csd = info->resize_height; | |||
| 9535 | ctk_window_update_csd_size (window, | |||
| 9536 | &resize_width_csd, &resize_height_csd, | |||
| 9537 | INCLUDE_CSD_SIZE); | |||
| 9538 | ||||
| 9539 | if (info->resize_width > 0) | |||
| 9540 | *width = resize_width_csd; | |||
| 9541 | if (info->resize_height > 0) | |||
| 9542 | *height = resize_height_csd; | |||
| 9543 | } | |||
| 9544 | ||||
| 9545 | /* Don't ever request zero width or height, it's not supported by | |||
| 9546 | cdk. The size allocation code will round it to 1 anyway but if | |||
| 9547 | we do it then the value returned from this function will is | |||
| 9548 | not comparable to the size allocation read from the CtkWindow. */ | |||
| 9549 | *width = MAX (*width, 1)(((*width) > (1)) ? (*width) : (1)); | |||
| 9550 | *height = MAX (*height, 1)(((*height) > (1)) ? (*height) : (1)); | |||
| 9551 | } | |||
| 9552 | ||||
| 9553 | static CtkWindowPosition | |||
| 9554 | get_effective_position (CtkWindow *window) | |||
| 9555 | { | |||
| 9556 | CtkWindowPrivate *priv = window->priv; | |||
| 9557 | CtkWindowPosition pos = priv->position; | |||
| 9558 | ||||
| 9559 | if (pos == CTK_WIN_POS_CENTER_ON_PARENT && | |||
| 9560 | (priv->transient_parent == NULL((void*)0) || | |||
| 9561 | !_ctk_widget_get_mapped (CTK_WIDGET (priv->transient_parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->transient_parent)), ((ctk_widget_get_type ()))) )))))) | |||
| 9562 | pos = CTK_WIN_POS_NONE; | |||
| 9563 | ||||
| 9564 | return pos; | |||
| 9565 | } | |||
| 9566 | ||||
| 9567 | static CdkMonitor * | |||
| 9568 | get_center_monitor_of_window (CtkWindow *window) | |||
| 9569 | { | |||
| 9570 | CdkDisplay *display; | |||
| 9571 | ||||
| 9572 | /* We could try to sort out the relative positions of the monitors and | |||
| 9573 | * stuff, or we could just be losers and assume you have a row | |||
| 9574 | * or column of monitors. | |||
| 9575 | */ | |||
| 9576 | display = cdk_screen_get_display (ctk_window_check_screen (window)); | |||
| 9577 | return cdk_display_get_monitor (display, cdk_display_get_n_monitors (display) / 2); | |||
| 9578 | } | |||
| 9579 | ||||
| 9580 | static CdkMonitor * | |||
| 9581 | get_monitor_containing_pointer (CtkWindow *window) | |||
| 9582 | { | |||
| 9583 | gint px, py; | |||
| 9584 | CdkDisplay *display; | |||
| 9585 | CdkDevice *pointer; | |||
| 9586 | ||||
| 9587 | display = cdk_screen_get_display (ctk_window_check_screen (window)); | |||
| 9588 | pointer = cdk_seat_get_pointer (cdk_display_get_default_seat (display)); | |||
| 9589 | cdk_device_get_position (pointer, NULL((void*)0), &px, &py); | |||
| 9590 | ||||
| 9591 | return cdk_display_get_monitor_at_point (display, px, py); | |||
| 9592 | } | |||
| 9593 | ||||
| 9594 | static void | |||
| 9595 | center_window_on_monitor (CtkWindow *window, | |||
| 9596 | gint w, | |||
| 9597 | gint h, | |||
| 9598 | gint *x, | |||
| 9599 | gint *y) | |||
| 9600 | { | |||
| 9601 | CdkRectangle area; | |||
| 9602 | CdkMonitor *monitor; | |||
| 9603 | ||||
| 9604 | monitor = get_monitor_containing_pointer (window); | |||
| 9605 | ||||
| 9606 | if (monitor == NULL((void*)0)) | |||
| 9607 | monitor = get_center_monitor_of_window (window); | |||
| 9608 | ||||
| 9609 | cdk_monitor_get_workarea (monitor, &area); | |||
| 9610 | ||||
| 9611 | *x = (area.width - w) / 2 + area.x; | |||
| 9612 | *y = (area.height - h) / 2 + area.y; | |||
| 9613 | ||||
| 9614 | /* Be sure we aren't off the monitor, ignoring _NET_WM_STRUT | |||
| 9615 | * and WM decorations. | |||
| 9616 | */ | |||
| 9617 | if (*x < area.x) | |||
| 9618 | *x = area.x; | |||
| 9619 | if (*y < area.y) | |||
| 9620 | *y = area.y; | |||
| 9621 | } | |||
| 9622 | ||||
| 9623 | static void | |||
| 9624 | clamp (gint *base, | |||
| 9625 | gint extent, | |||
| 9626 | gint clamp_base, | |||
| 9627 | gint clamp_extent) | |||
| 9628 | { | |||
| 9629 | if (extent > clamp_extent) | |||
| 9630 | /* Center */ | |||
| 9631 | *base = clamp_base + clamp_extent/2 - extent/2; | |||
| 9632 | else if (*base < clamp_base) | |||
| 9633 | *base = clamp_base; | |||
| 9634 | else if (*base + extent > clamp_base + clamp_extent) | |||
| 9635 | *base = clamp_base + clamp_extent - extent; | |||
| 9636 | } | |||
| 9637 | ||||
| 9638 | static void | |||
| 9639 | clamp_window_to_rectangle (gint *x, | |||
| 9640 | gint *y, | |||
| 9641 | gint w, | |||
| 9642 | gint h, | |||
| 9643 | const CdkRectangle *rect) | |||
| 9644 | { | |||
| 9645 | /* If it is too large, center it. If it fits on the monitor but is | |||
| 9646 | * partially outside, move it to the closest edge. Do this | |||
| 9647 | * separately in x and y directions. | |||
| 9648 | */ | |||
| 9649 | clamp (x, w, rect->x, rect->width); | |||
| 9650 | clamp (y, h, rect->y, rect->height); | |||
| 9651 | } | |||
| 9652 | ||||
| 9653 | ||||
| 9654 | static void | |||
| 9655 | ctk_window_compute_configure_request (CtkWindow *window, | |||
| 9656 | CdkRectangle *request, | |||
| 9657 | CdkGeometry *geometry, | |||
| 9658 | guint *flags) | |||
| 9659 | { | |||
| 9660 | CtkWindowPrivate *priv = window->priv; | |||
| 9661 | CdkGeometry new_geometry; | |||
| 9662 | guint new_flags; | |||
| 9663 | int w, h; | |||
| 9664 | CtkWindowPosition pos; | |||
| 9665 | CtkWidget *parent_widget; | |||
| 9666 | CtkWindowGeometryInfo *info; | |||
| 9667 | CdkScreen *screen; | |||
| 9668 | int x, y; | |||
| 9669 | ||||
| 9670 | screen = ctk_window_check_screen (window); | |||
| 9671 | ||||
| 9672 | ctk_window_compute_hints (window, &new_geometry, &new_flags); | |||
| 9673 | ctk_window_compute_configure_request_size (window, | |||
| 9674 | &new_geometry, new_flags, | |||
| 9675 | &w, &h); | |||
| 9676 | ctk_window_update_fixed_size (window, &new_geometry, w, h); | |||
| 9677 | ctk_window_constrain_size (window, | |||
| 9678 | &new_geometry, new_flags, | |||
| 9679 | w, h, | |||
| 9680 | &w, &h); | |||
| 9681 | ||||
| 9682 | parent_widget = (CtkWidget*) priv->transient_parent; | |||
| 9683 | ||||
| 9684 | pos = get_effective_position (window); | |||
| 9685 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 9686 | ||||
| 9687 | /* by default, don't change position requested */ | |||
| 9688 | if (info) | |||
| 9689 | { | |||
| 9690 | x = info->last.configure_request.x; | |||
| 9691 | y = info->last.configure_request.y; | |||
| 9692 | } | |||
| 9693 | else | |||
| 9694 | { | |||
| 9695 | x = 0; | |||
| 9696 | y = 0; | |||
| 9697 | } | |||
| 9698 | ||||
| 9699 | ||||
| 9700 | if (priv->need_default_position) | |||
| 9701 | { | |||
| 9702 | ||||
| 9703 | /* FIXME this all interrelates with window gravity. | |||
| 9704 | * For most of them I think we want to set GRAVITY_CENTER. | |||
| 9705 | * | |||
| 9706 | * Not sure how to go about that. | |||
| 9707 | */ | |||
| 9708 | switch (pos) | |||
| 9709 | { | |||
| 9710 | /* here we are only handling CENTER_ALWAYS | |||
| 9711 | * as it relates to default positioning, | |||
| 9712 | * where it's equivalent to simply CENTER | |||
| 9713 | */ | |||
| 9714 | case CTK_WIN_POS_CENTER_ALWAYS: | |||
| 9715 | case CTK_WIN_POS_CENTER: | |||
| 9716 | center_window_on_monitor (window, w, h, &x, &y); | |||
| 9717 | break; | |||
| 9718 | ||||
| 9719 | case CTK_WIN_POS_CENTER_ON_PARENT: | |||
| 9720 | { | |||
| 9721 | CdkDisplay *display; | |||
| 9722 | CtkAllocation allocation; | |||
| 9723 | CdkWindow *cdk_window; | |||
| 9724 | CdkMonitor *monitor; | |||
| 9725 | CdkRectangle area; | |||
| 9726 | gint ox, oy; | |||
| 9727 | ||||
| 9728 | g_assert (_ctk_widget_get_mapped (parent_widget))do { if (_ctk_widget_get_mapped (parent_widget)) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c", 9728, ((const char*) (__func__)), "_ctk_widget_get_mapped (parent_widget)" ); } while (0); /* established earlier */ | |||
| 9729 | ||||
| 9730 | display = cdk_screen_get_display (screen); | |||
| 9731 | cdk_window = _ctk_widget_get_window (parent_widget); | |||
| 9732 | monitor = cdk_display_get_monitor_at_window (display, cdk_window); | |||
| 9733 | ||||
| 9734 | cdk_window_get_origin (cdk_window, &ox, &oy); | |||
| 9735 | ||||
| 9736 | _ctk_widget_get_allocation (parent_widget, &allocation); | |||
| 9737 | x = ox + (allocation.width - w) / 2; | |||
| 9738 | y = oy + (allocation.height - h) / 2; | |||
| 9739 | ||||
| 9740 | /* Clamp onto current monitor, ignoring _NET_WM_STRUT and | |||
| 9741 | * WM decorations. If parent wasn't on a monitor, just | |||
| 9742 | * give up. | |||
| 9743 | */ | |||
| 9744 | if (monitor != NULL((void*)0)) | |||
| 9745 | { | |||
| 9746 | cdk_monitor_get_geometry (monitor, &area); | |||
| 9747 | clamp_window_to_rectangle (&x, &y, w, h, &area); | |||
| 9748 | } | |||
| 9749 | } | |||
| 9750 | break; | |||
| 9751 | ||||
| 9752 | case CTK_WIN_POS_MOUSE: | |||
| 9753 | { | |||
| 9754 | CdkRectangle area; | |||
| 9755 | CdkDisplay *display; | |||
| 9756 | CdkDevice *pointer; | |||
| 9757 | CdkMonitor *monitor; | |||
| 9758 | gint px, py; | |||
| 9759 | ||||
| 9760 | display = cdk_screen_get_display (screen); | |||
| 9761 | pointer = cdk_seat_get_pointer (cdk_display_get_default_seat (display)); | |||
| 9762 | ||||
| 9763 | cdk_device_get_position (pointer, NULL((void*)0), &px, &py); | |||
| 9764 | monitor = cdk_display_get_monitor_at_point (display, px, py); | |||
| 9765 | ||||
| 9766 | x = px - w / 2; | |||
| 9767 | y = py - h / 2; | |||
| 9768 | ||||
| 9769 | /* Clamp onto current monitor, ignoring _NET_WM_STRUT and | |||
| 9770 | * WM decorations. | |||
| 9771 | */ | |||
| 9772 | cdk_monitor_get_geometry (monitor, &area); | |||
| 9773 | clamp_window_to_rectangle (&x, &y, w, h, &area); | |||
| 9774 | } | |||
| 9775 | break; | |||
| 9776 | ||||
| 9777 | default: | |||
| 9778 | break; | |||
| 9779 | } | |||
| 9780 | } /* if (priv->need_default_position) */ | |||
| 9781 | ||||
| 9782 | if (priv->need_default_position && info && | |||
| 9783 | info->initial_pos_set) | |||
| 9784 | { | |||
| 9785 | x = info->initial_x; | |||
| 9786 | y = info->initial_y; | |||
| 9787 | ctk_window_constrain_position (window, w, h, &x, &y); | |||
| 9788 | } | |||
| 9789 | ||||
| 9790 | request->x = x; | |||
| 9791 | request->y = y; | |||
| 9792 | request->width = w; | |||
| 9793 | request->height = h; | |||
| 9794 | ||||
| 9795 | if (geometry) | |||
| 9796 | *geometry = new_geometry; | |||
| 9797 | if (flags) | |||
| 9798 | *flags = new_flags; | |||
| 9799 | } | |||
| 9800 | ||||
| 9801 | static void | |||
| 9802 | ctk_window_constrain_position (CtkWindow *window, | |||
| 9803 | gint new_width, | |||
| 9804 | gint new_height, | |||
| 9805 | gint *x, | |||
| 9806 | gint *y) | |||
| 9807 | { | |||
| 9808 | CtkWindowPrivate *priv = window->priv; | |||
| 9809 | ||||
| 9810 | /* See long comments in ctk_window_move_resize() | |||
| 9811 | * on when it's safe to call this function. | |||
| 9812 | */ | |||
| 9813 | if (priv->position == CTK_WIN_POS_CENTER_ALWAYS) | |||
| 9814 | { | |||
| 9815 | gint center_x, center_y; | |||
| 9816 | ||||
| 9817 | center_window_on_monitor (window, new_width, new_height, ¢er_x, ¢er_y); | |||
| 9818 | ||||
| 9819 | *x = center_x; | |||
| 9820 | *y = center_y; | |||
| 9821 | } | |||
| 9822 | } | |||
| 9823 | ||||
| 9824 | void | |||
| 9825 | ctk_window_move_resize (CtkWindow *window) | |||
| 9826 | { | |||
| 9827 | /* Overview: | |||
| 9828 | * | |||
| 9829 | * First we determine whether any information has changed that would | |||
| 9830 | * cause us to revise our last configure request. If we would send | |||
| 9831 | * a different configure request from last time, then | |||
| 9832 | * configure_request_size_changed = TRUE or | |||
| 9833 | * configure_request_pos_changed = TRUE. configure_request_size_changed | |||
| 9834 | * may be true due to new hints, a ctk_window_resize(), or whatever. | |||
| 9835 | * configure_request_pos_changed may be true due to ctk_window_set_position() | |||
| 9836 | * or ctk_window_move(). | |||
| 9837 | * | |||
| 9838 | * If the configure request has changed, we send off a new one. To | |||
| 9839 | * ensure CTK+ invariants are maintained (resize queue does what it | |||
| 9840 | * should), we go ahead and size_allocate the requested size in this | |||
| 9841 | * function. | |||
| 9842 | * | |||
| 9843 | * If the configure request has not changed, we don't ever resend | |||
| 9844 | * it, because it could mean fighting the user or window manager. | |||
| 9845 | * | |||
| 9846 | * To prepare the configure request, we come up with a base size/pos: | |||
| 9847 | * - the one from ctk_window_move()/ctk_window_resize() | |||
| 9848 | * - else default_width, default_height if we haven't ever | |||
| 9849 | * been mapped | |||
| 9850 | * - else the size request if we haven't ever been mapped, | |||
| 9851 | * as a substitute default size | |||
| 9852 | * - else the current size of the window, as received from | |||
| 9853 | * configure notifies (i.e. the current allocation) | |||
| 9854 | * | |||
| 9855 | * If CTK_WIN_POS_CENTER_ALWAYS is active, we constrain | |||
| 9856 | * the position request to be centered. | |||
| 9857 | */ | |||
| 9858 | CtkWindowPrivate *priv = window->priv; | |||
| 9859 | CtkWidget *widget; | |||
| 9860 | CtkContainer *container; | |||
| 9861 | CtkWindowGeometryInfo *info; | |||
| 9862 | CdkGeometry new_geometry; | |||
| 9863 | CdkWindow *cdk_window; | |||
| 9864 | guint new_flags; | |||
| 9865 | CdkRectangle new_request; | |||
| 9866 | gboolean configure_request_size_changed; | |||
| 9867 | gboolean configure_request_pos_changed; | |||
| 9868 | gboolean hints_changed; /* do we need to send these again */ | |||
| 9869 | CtkWindowLastGeometryInfo saved_last_info; | |||
| 9870 | int current_width, current_height; | |||
| 9871 | ||||
| 9872 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 9873 | ||||
| 9874 | cdk_window = _ctk_widget_get_window (widget); | |||
| 9875 | container = CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))); | |||
| 9876 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 9877 | ||||
| 9878 | configure_request_size_changed = FALSE(0); | |||
| 9879 | configure_request_pos_changed = FALSE(0); | |||
| 9880 | ||||
| 9881 | ctk_window_compute_configure_request (window, &new_request, | |||
| 9882 | &new_geometry, &new_flags); | |||
| 9883 | ||||
| 9884 | /* This check implies the invariant that we never set info->last | |||
| 9885 | * without setting the hints and sending off a configure request. | |||
| 9886 | * | |||
| 9887 | * If we change info->last without sending the request, we may | |||
| 9888 | * miss a request. | |||
| 9889 | */ | |||
| 9890 | if (info->last.configure_request.x != new_request.x || | |||
| 9891 | info->last.configure_request.y != new_request.y) | |||
| 9892 | configure_request_pos_changed = TRUE(!(0)); | |||
| 9893 | ||||
| 9894 | if (priv->force_resize || | |||
| 9895 | (info->last.configure_request.width != new_request.width || | |||
| 9896 | info->last.configure_request.height != new_request.height)) | |||
| 9897 | { | |||
| 9898 | priv->force_resize = FALSE(0); | |||
| 9899 | configure_request_size_changed = TRUE(!(0)); | |||
| 9900 | } | |||
| 9901 | ||||
| 9902 | hints_changed = FALSE(0); | |||
| 9903 | ||||
| 9904 | if (!ctk_window_compare_hints (&info->last.geometry, info->last.flags, | |||
| 9905 | &new_geometry, new_flags)) | |||
| 9906 | { | |||
| 9907 | hints_changed = TRUE(!(0)); | |||
| 9908 | } | |||
| 9909 | ||||
| 9910 | /* Position Constraints | |||
| 9911 | * ==================== | |||
| 9912 | * | |||
| 9913 | * POS_CENTER_ALWAYS is conceptually a constraint rather than | |||
| 9914 | * a default. The other POS_ values are used only when the | |||
| 9915 | * window is shown, not after that. | |||
| 9916 | * | |||
| 9917 | * However, we can't implement a position constraint as | |||
| 9918 | * "anytime the window size changes, center the window" | |||
| 9919 | * because this may well end up fighting the WM or user. In | |||
| 9920 | * fact it gets in an infinite loop with at least one WM. | |||
| 9921 | * | |||
| 9922 | * Basically, applications are in no way in a position to | |||
| 9923 | * constrain the position of a window, with one exception: | |||
| 9924 | * override redirect windows. (Really the intended purpose | |||
| 9925 | * of CENTER_ALWAYS anyhow, I would think.) | |||
| 9926 | * | |||
| 9927 | * So the way we implement this "constraint" is to say that when WE | |||
| 9928 | * cause a move or resize, i.e. we make a configure request changing | |||
| 9929 | * window size, we recompute the CENTER_ALWAYS position to reflect | |||
| 9930 | * the new window size, and include it in our request. Also, if we | |||
| 9931 | * just turned on CENTER_ALWAYS we snap to center with a new | |||
| 9932 | * request. Otherwise, if we are just NOTIFIED of a move or resize | |||
| 9933 | * done by someone else e.g. the window manager, we do NOT send a | |||
| 9934 | * new configure request. | |||
| 9935 | * | |||
| 9936 | * For override redirect windows, this works fine; all window | |||
| 9937 | * sizes are from our configure requests. For managed windows, | |||
| 9938 | * it is at least semi-sane, though who knows what the | |||
| 9939 | * app author is thinking. | |||
| 9940 | */ | |||
| 9941 | ||||
| 9942 | /* This condition should be kept in sync with the condition later on | |||
| 9943 | * that determines whether we send a configure request. i.e. we | |||
| 9944 | * should do this position constraining anytime we were going to | |||
| 9945 | * send a configure request anyhow, plus when constraints have | |||
| 9946 | * changed. | |||
| 9947 | */ | |||
| 9948 | if (configure_request_pos_changed || | |||
| 9949 | configure_request_size_changed || | |||
| 9950 | hints_changed || | |||
| 9951 | info->position_constraints_changed) | |||
| 9952 | { | |||
| 9953 | /* We request the constrained position if: | |||
| 9954 | * - we were changing position, and need to clamp | |||
| 9955 | * the change to the constraint | |||
| 9956 | * - we're changing the size anyway | |||
| 9957 | * - set_position() was called to toggle CENTER_ALWAYS on | |||
| 9958 | */ | |||
| 9959 | ||||
| 9960 | ctk_window_constrain_position (window, | |||
| 9961 | new_request.width, | |||
| 9962 | new_request.height, | |||
| 9963 | &new_request.x, | |||
| 9964 | &new_request.y); | |||
| 9965 | ||||
| 9966 | /* Update whether we need to request a move */ | |||
| 9967 | if (info->last.configure_request.x != new_request.x || | |||
| 9968 | info->last.configure_request.y != new_request.y) | |||
| 9969 | configure_request_pos_changed = TRUE(!(0)); | |||
| 9970 | else | |||
| 9971 | configure_request_pos_changed = FALSE(0); | |||
| 9972 | } | |||
| 9973 | ||||
| 9974 | #if 0 | |||
| 9975 | if (priv->type == CTK_WINDOW_TOPLEVEL) | |||
| 9976 | { | |||
| 9977 | CtkAllocation alloc; | |||
| 9978 | ||||
| 9979 | ctk_widget_get_allocation (widget, &alloc); | |||
| 9980 | ||||
| 9981 | g_message ("--- %s ---\n" | |||
| 9982 | "last : %d,%d\t%d x %d\n" | |||
| 9983 | "this : %d,%d\t%d x %d\n" | |||
| 9984 | "alloc : %d,%d\t%d x %d\n" | |||
| 9985 | "resize: \t%d x %d\n" | |||
| 9986 | "size_changed: %d pos_changed: %d hints_changed: %d\n" | |||
| 9987 | "configure_notify_received: %d\n" | |||
| 9988 | "configure_request_count: %d\n" | |||
| 9989 | "position_constraints_changed: %d", | |||
| 9990 | priv->title ? priv->title : "(no title)", | |||
| 9991 | info->last.configure_request.x, | |||
| 9992 | info->last.configure_request.y, | |||
| 9993 | info->last.configure_request.width, | |||
| 9994 | info->last.configure_request.height, | |||
| 9995 | new_request.x, | |||
| 9996 | new_request.y, | |||
| 9997 | new_request.width, | |||
| 9998 | new_request.height, | |||
| 9999 | alloc.x, | |||
| 10000 | alloc.y, | |||
| 10001 | alloc.width, | |||
| 10002 | alloc.height, | |||
| 10003 | info->resize_width, | |||
| 10004 | info->resize_height, | |||
| 10005 | configure_request_size_changed, | |||
| 10006 | configure_request_pos_changed, | |||
| 10007 | hints_changed, | |||
| 10008 | priv->configure_notify_received, | |||
| 10009 | priv->configure_request_count, | |||
| 10010 | info->position_constraints_changed); | |||
| 10011 | } | |||
| 10012 | #endif | |||
| 10013 | ||||
| 10014 | saved_last_info = info->last; | |||
| 10015 | info->last.geometry = new_geometry; | |||
| 10016 | info->last.flags = new_flags; | |||
| 10017 | info->last.configure_request = new_request; | |||
| 10018 | ||||
| 10019 | /* need to set PPosition so the WM will look at our position, | |||
| 10020 | * but we don't want to count PPosition coming and going as a hints | |||
| 10021 | * change for future iterations. So we saved info->last prior to | |||
| 10022 | * this. | |||
| 10023 | */ | |||
| 10024 | ||||
| 10025 | /* Also, if the initial position was explicitly set, then we always | |||
| 10026 | * toggle on PPosition. This makes ctk_window_move(window, 0, 0) | |||
| 10027 | * work. | |||
| 10028 | */ | |||
| 10029 | ||||
| 10030 | /* Also, we toggle on PPosition if CTK_WIN_POS_ is in use and | |||
| 10031 | * this is an initial map | |||
| 10032 | */ | |||
| 10033 | ||||
| 10034 | if ((configure_request_pos_changed || | |||
| 10035 | info->initial_pos_set || | |||
| 10036 | (priv->need_default_position && | |||
| 10037 | get_effective_position (window) != CTK_WIN_POS_NONE)) && | |||
| 10038 | (new_flags & CDK_HINT_POS) == 0) | |||
| 10039 | { | |||
| 10040 | new_flags |= CDK_HINT_POS; | |||
| 10041 | hints_changed = TRUE(!(0)); | |||
| 10042 | } | |||
| 10043 | ||||
| 10044 | /* Set hints if necessary | |||
| 10045 | */ | |||
| 10046 | if (hints_changed) | |||
| 10047 | cdk_window_set_geometry_hints (cdk_window, | |||
| 10048 | &new_geometry, | |||
| 10049 | new_flags); | |||
| 10050 | ||||
| 10051 | current_width = cdk_window_get_width (cdk_window); | |||
| 10052 | current_height = cdk_window_get_height (cdk_window); | |||
| 10053 | ||||
| 10054 | /* handle resizing/moving and widget tree allocation | |||
| 10055 | */ | |||
| 10056 | if (priv->configure_notify_received) | |||
| 10057 | { | |||
| 10058 | CtkAllocation allocation; | |||
| 10059 | ||||
| 10060 | /* If we have received a configure event since | |||
| 10061 | * the last time in this function, we need to | |||
| 10062 | * accept our new size and size_allocate child widgets. | |||
| 10063 | * (see ctk_window_configure_event() for more details). | |||
| 10064 | * | |||
| 10065 | * 1 or more configure notifies may have been received. | |||
| 10066 | * Also, configure_notify_received will only be TRUE | |||
| 10067 | * if all expected configure notifies have been received | |||
| 10068 | * (one per configure request), as an optimization. | |||
| 10069 | * | |||
| 10070 | */ | |||
| 10071 | priv->configure_notify_received = FALSE(0); | |||
| 10072 | ||||
| 10073 | allocation.x = 0; | |||
| 10074 | allocation.y = 0; | |||
| 10075 | allocation.width = current_width; | |||
| 10076 | allocation.height = current_height; | |||
| 10077 | ||||
| 10078 | ctk_widget_size_allocate (widget, &allocation); | |||
| 10079 | ||||
| 10080 | /* If the configure request changed, it means that | |||
| 10081 | * we either: | |||
| 10082 | * 1) coincidentally changed hints or widget properties | |||
| 10083 | * impacting the configure request before getting | |||
| 10084 | * a configure notify, or | |||
| 10085 | * 2) some broken widget is changing its size request | |||
| 10086 | * during size allocation, resulting in | |||
| 10087 | * a false appearance of changed configure request. | |||
| 10088 | * | |||
| 10089 | * For 1), we could just go ahead and ask for the | |||
| 10090 | * new size right now, but doing that for 2) | |||
| 10091 | * might well be fighting the user (and can even | |||
| 10092 | * trigger a loop). Since we really don't want to | |||
| 10093 | * do that, we requeue a resize in hopes that | |||
| 10094 | * by the time it gets handled, the child has seen | |||
| 10095 | * the light and is willing to go along with the | |||
| 10096 | * new size. (this happens for the zvt widget, since | |||
| 10097 | * the size_allocate() above will have stored the | |||
| 10098 | * requisition corresponding to the new size in the | |||
| 10099 | * zvt widget) | |||
| 10100 | * | |||
| 10101 | * This doesn't buy us anything for 1), but it shouldn't | |||
| 10102 | * hurt us too badly, since it is what would have | |||
| 10103 | * happened if we had gotten the configure event before | |||
| 10104 | * the new size had been set. | |||
| 10105 | */ | |||
| 10106 | ||||
| 10107 | if (configure_request_size_changed || | |||
| 10108 | configure_request_pos_changed) | |||
| 10109 | { | |||
| 10110 | /* Don't change the recorded last info after all, because we | |||
| 10111 | * haven't actually updated to the new info yet - we decided | |||
| 10112 | * to postpone our configure request until later. | |||
| 10113 | */ | |||
| 10114 | info->last = saved_last_info; | |||
| 10115 | ctk_widget_queue_resize_no_redraw (widget); /* might recurse for CTK_RESIZE_IMMEDIATE */ | |||
| 10116 | } | |||
| 10117 | ||||
| 10118 | return; /* Bail out, we didn't really process the move/resize */ | |||
| 10119 | } | |||
| 10120 | else if ((configure_request_size_changed || hints_changed) && | |||
| 10121 | (current_width != new_request.width || current_height != new_request.height)) | |||
| 10122 | { | |||
| 10123 | /* We are in one of the following situations: | |||
| 10124 | * A. configure_request_size_changed | |||
| 10125 | * our requisition has changed and we need a different window size, | |||
| 10126 | * so we request it from the window manager. | |||
| 10127 | * B. !configure_request_size_changed && hints_changed | |||
| 10128 | * the window manager rejects our size, but we have just changed the | |||
| 10129 | * window manager hints, so there's a chance our request will | |||
| 10130 | * be honoured this time, so we try again. | |||
| 10131 | * | |||
| 10132 | * However, if the new requisition is the same as the current allocation, | |||
| 10133 | * we don't request it again, since we won't get a ConfigureNotify back from | |||
| 10134 | * the window manager unless it decides to change our requisition. If | |||
| 10135 | * we don't get the ConfigureNotify back, the resize queue will never be run. | |||
| 10136 | */ | |||
| 10137 | ||||
| 10138 | /* Now send the configure request */ | |||
| 10139 | if (configure_request_pos_changed) | |||
| 10140 | { | |||
| 10141 | cdk_window_move_resize (cdk_window, | |||
| 10142 | new_request.x, new_request.y, | |||
| 10143 | new_request.width, new_request.height); | |||
| 10144 | } | |||
| 10145 | else /* only size changed */ | |||
| 10146 | { | |||
| 10147 | cdk_window_resize (cdk_window, | |||
| 10148 | new_request.width, new_request.height); | |||
| 10149 | } | |||
| 10150 | ||||
| 10151 | if (priv->type == CTK_WINDOW_POPUP) | |||
| 10152 | { | |||
| 10153 | CtkAllocation allocation; | |||
| 10154 | ||||
| 10155 | /* Directly size allocate for override redirect (popup) windows. */ | |||
| 10156 | allocation.x = 0; | |||
| 10157 | allocation.y = 0; | |||
| 10158 | allocation.width = new_request.width; | |||
| 10159 | allocation.height = new_request.height; | |||
| 10160 | ||||
| 10161 | ctk_widget_size_allocate (widget, &allocation); | |||
| 10162 | ||||
| 10163 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" ; | |||
| 10164 | if (ctk_container_get_resize_mode (container) == CTK_RESIZE_QUEUE) | |||
| 10165 | ctk_widget_queue_draw (widget); | |||
| 10166 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ; | |||
| 10167 | } | |||
| 10168 | else | |||
| 10169 | { | |||
| 10170 | /* Increment the number of have-not-yet-received-notify requests */ | |||
| 10171 | priv->configure_request_count += 1; | |||
| 10172 | ||||
| 10173 | CDK_PRIVATE_CALL (cdk_window_freeze_toplevel_updates)(cdk__private__ ()->cdk_window_freeze_toplevel_updates) (cdk_window); | |||
| 10174 | ||||
| 10175 | /* for CTK_RESIZE_QUEUE toplevels, we are now awaiting a new | |||
| 10176 | * configure event in response to our resizing request. | |||
| 10177 | * the configure event will cause a new resize with | |||
| 10178 | * ->configure_notify_received=TRUE. | |||
| 10179 | * until then, we want to | |||
| 10180 | * - discard expose events | |||
| 10181 | * - coalesce resizes for our children | |||
| 10182 | * - defer any window resizes until the configure event arrived | |||
| 10183 | * to achieve this, we queue a resize for the window, but remove its | |||
| 10184 | * resizing handler, so resizing will not be handled from the next | |||
| 10185 | * idle handler but when the configure event arrives. | |||
| 10186 | * | |||
| 10187 | * FIXME: we should also dequeue the pending redraws here, since | |||
| 10188 | * we handle those ourselves upon ->configure_notify_received==TRUE. | |||
| 10189 | */ | |||
| 10190 | } | |||
| 10191 | } | |||
| 10192 | else | |||
| 10193 | { | |||
| 10194 | CtkAllocation allocation; | |||
| 10195 | ||||
| 10196 | /* Handle any position changes. | |||
| 10197 | */ | |||
| 10198 | if (configure_request_pos_changed) | |||
| 10199 | { | |||
| 10200 | cdk_window_move (cdk_window, | |||
| 10201 | new_request.x, new_request.y); | |||
| 10202 | } | |||
| 10203 | ||||
| 10204 | /* Our configure request didn't change size, but maybe some of | |||
| 10205 | * our child widgets have. Run a size allocate with our current | |||
| 10206 | * size to make sure that we re-layout our child widgets. */ | |||
| 10207 | allocation.x = 0; | |||
| 10208 | allocation.y = 0; | |||
| 10209 | allocation.width = current_width; | |||
| 10210 | allocation.height = current_height; | |||
| 10211 | ||||
| 10212 | ctk_widget_size_allocate (widget, &allocation); | |||
| 10213 | } | |||
| 10214 | ||||
| 10215 | /* We have now processed a move/resize since the last position | |||
| 10216 | * constraint change, setting of the initial position, or resize. | |||
| 10217 | * (Not resetting these flags here can lead to infinite loops for | |||
| 10218 | * CTK_RESIZE_IMMEDIATE containers) | |||
| 10219 | */ | |||
| 10220 | info->position_constraints_changed = FALSE(0); | |||
| 10221 | info->initial_pos_set = FALSE(0); | |||
| 10222 | info->resize_width = -1; | |||
| 10223 | info->resize_height = -1; | |||
| 10224 | } | |||
| 10225 | ||||
| 10226 | /* Compare two sets of Geometry hints for equality. | |||
| 10227 | */ | |||
| 10228 | static gboolean | |||
| 10229 | ctk_window_compare_hints (CdkGeometry *geometry_a, | |||
| 10230 | guint flags_a, | |||
| 10231 | CdkGeometry *geometry_b, | |||
| 10232 | guint flags_b) | |||
| 10233 | { | |||
| 10234 | if (flags_a != flags_b) | |||
| 10235 | return FALSE(0); | |||
| 10236 | ||||
| 10237 | if ((flags_a & CDK_HINT_MIN_SIZE) && | |||
| 10238 | (geometry_a->min_width != geometry_b->min_width || | |||
| 10239 | geometry_a->min_height != geometry_b->min_height)) | |||
| 10240 | return FALSE(0); | |||
| 10241 | ||||
| 10242 | if ((flags_a & CDK_HINT_MAX_SIZE) && | |||
| 10243 | (geometry_a->max_width != geometry_b->max_width || | |||
| 10244 | geometry_a->max_height != geometry_b->max_height)) | |||
| 10245 | return FALSE(0); | |||
| 10246 | ||||
| 10247 | if ((flags_a & CDK_HINT_BASE_SIZE) && | |||
| 10248 | (geometry_a->base_width != geometry_b->base_width || | |||
| 10249 | geometry_a->base_height != geometry_b->base_height)) | |||
| 10250 | return FALSE(0); | |||
| 10251 | ||||
| 10252 | if ((flags_a & CDK_HINT_ASPECT) && | |||
| 10253 | (geometry_a->min_aspect != geometry_b->min_aspect || | |||
| 10254 | geometry_a->max_aspect != geometry_b->max_aspect)) | |||
| 10255 | return FALSE(0); | |||
| 10256 | ||||
| 10257 | if ((flags_a & CDK_HINT_RESIZE_INC) && | |||
| 10258 | (geometry_a->width_inc != geometry_b->width_inc || | |||
| 10259 | geometry_a->height_inc != geometry_b->height_inc)) | |||
| 10260 | return FALSE(0); | |||
| 10261 | ||||
| 10262 | if ((flags_a & CDK_HINT_WIN_GRAVITY) && | |||
| 10263 | geometry_a->win_gravity != geometry_b->win_gravity) | |||
| 10264 | return FALSE(0); | |||
| 10265 | ||||
| 10266 | return TRUE(!(0)); | |||
| 10267 | } | |||
| 10268 | ||||
| 10269 | static void | |||
| 10270 | ctk_window_constrain_size (CtkWindow *window, | |||
| 10271 | CdkGeometry *geometry, | |||
| 10272 | guint flags, | |||
| 10273 | gint width, | |||
| 10274 | gint height, | |||
| 10275 | gint *new_width, | |||
| 10276 | gint *new_height) | |||
| 10277 | { | |||
| 10278 | CtkWindowPrivate *priv = window->priv; | |||
| 10279 | guint geometry_flags; | |||
| 10280 | ||||
| 10281 | /* ignore size increments for windows that fit in a fixed space */ | |||
| 10282 | if (priv->maximized || priv->fullscreen || priv->tiled) | |||
| 10283 | geometry_flags = flags & ~CDK_HINT_RESIZE_INC; | |||
| 10284 | else | |||
| 10285 | geometry_flags = flags; | |||
| 10286 | ||||
| 10287 | cdk_window_constrain_size (geometry, geometry_flags, width, height, | |||
| 10288 | new_width, new_height); | |||
| 10289 | } | |||
| 10290 | ||||
| 10291 | /* For non-resizable windows, make sure the given width/height fits | |||
| 10292 | * in the geometry contrains and update the geometry hints to match | |||
| 10293 | * the given width/height if not. | |||
| 10294 | * This is to make sure that non-resizable windows get the default | |||
| 10295 | * width/height if set, but can still grow if their content requires. | |||
| 10296 | * | |||
| 10297 | * Note: Fixed size windows with a default size set will not shrink | |||
| 10298 | * smaller than the default size when their content requires less size. | |||
| 10299 | */ | |||
| 10300 | static void | |||
| 10301 | ctk_window_update_fixed_size (CtkWindow *window, | |||
| 10302 | CdkGeometry *new_geometry, | |||
| 10303 | gint new_width, | |||
| 10304 | gint new_height) | |||
| 10305 | { | |||
| 10306 | CtkWindowPrivate *priv = window->priv; | |||
| 10307 | CtkWindowGeometryInfo *info; | |||
| 10308 | gboolean has_size_request; | |||
| 10309 | ||||
| 10310 | /* Adjust the geometry hints for non-resizable windows only */ | |||
| 10311 | has_size_request = ctk_widget_has_size_request (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10312 | if (priv->resizable || has_size_request) | |||
| 10313 | return; | |||
| 10314 | ||||
| 10315 | info = ctk_window_get_geometry_info (window, FALSE(0)); | |||
| 10316 | if (info) | |||
| 10317 | { | |||
| 10318 | gint default_width_csd = info->default_width; | |||
| 10319 | gint default_height_csd = info->default_height; | |||
| 10320 | ||||
| 10321 | ctk_window_update_csd_size (window, | |||
| 10322 | &default_width_csd, &default_height_csd, | |||
| 10323 | INCLUDE_CSD_SIZE); | |||
| 10324 | ||||
| 10325 | if (info->default_width > -1) | |||
| 10326 | { | |||
| 10327 | gint w = MAX (MAX (default_width_csd, new_width), new_geometry->min_width)((((((default_width_csd) > (new_width)) ? (default_width_csd ) : (new_width))) > (new_geometry->min_width)) ? ((((default_width_csd ) > (new_width)) ? (default_width_csd) : (new_width))) : ( new_geometry->min_width)); | |||
| 10328 | new_geometry->min_width = w; | |||
| 10329 | new_geometry->max_width = w; | |||
| 10330 | } | |||
| 10331 | ||||
| 10332 | if (info->default_height > -1) | |||
| 10333 | { | |||
| 10334 | gint h = MAX (MAX (default_height_csd, new_height), new_geometry->min_height)((((((default_height_csd) > (new_height)) ? (default_height_csd ) : (new_height))) > (new_geometry->min_height)) ? (((( default_height_csd) > (new_height)) ? (default_height_csd) : (new_height))) : (new_geometry->min_height)); | |||
| 10335 | new_geometry->min_height = h; | |||
| 10336 | new_geometry->max_height = h; | |||
| 10337 | } | |||
| 10338 | } | |||
| 10339 | } | |||
| 10340 | ||||
| 10341 | /* Compute the set of geometry hints and flags for a window | |||
| 10342 | * based on the application set geometry, and requisition | |||
| 10343 | * of the window. ctk_widget_get_preferred_size() must have been | |||
| 10344 | * called first. | |||
| 10345 | */ | |||
| 10346 | static void | |||
| 10347 | ctk_window_compute_hints (CtkWindow *window, | |||
| 10348 | CdkGeometry *new_geometry, | |||
| 10349 | guint *new_flags) | |||
| 10350 | { | |||
| 10351 | CtkWindowPrivate *priv = window->priv; | |||
| 10352 | CtkWidget *widget; | |||
| 10353 | gint extra_width = 0; | |||
| 10354 | gint extra_height = 0; | |||
| 10355 | CtkWindowGeometryInfo *geometry_info; | |||
| 10356 | CtkRequisition requisition; | |||
| 10357 | ||||
| 10358 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 10359 | ||||
| 10360 | ctk_widget_get_preferred_size (widget, &requisition, NULL((void*)0)); | |||
| 10361 | geometry_info = ctk_window_get_geometry_info (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))), FALSE(0)); | |||
| 10362 | ||||
| 10363 | if (geometry_info) | |||
| 10364 | { | |||
| 10365 | *new_flags = geometry_info->mask; | |||
| 10366 | *new_geometry = geometry_info->geometry; | |||
| 10367 | } | |||
| 10368 | else | |||
| 10369 | { | |||
| 10370 | *new_flags = 0; | |||
| 10371 | } | |||
| 10372 | ||||
| 10373 | /* We don't want to set CDK_HINT_POS in here, we just set it | |||
| 10374 | * in ctk_window_move_resize() when we want the position | |||
| 10375 | * honored. | |||
| 10376 | */ | |||
| 10377 | ||||
| 10378 | if (*new_flags & CDK_HINT_BASE_SIZE) | |||
| 10379 | { | |||
| 10380 | new_geometry->base_width += extra_width; | |||
| 10381 | new_geometry->base_height += extra_height; | |||
| 10382 | } | |||
| 10383 | else | |||
| 10384 | { | |||
| 10385 | /* For simplicity, we always set the base hint, even when we | |||
| 10386 | * don't expect it to have any visible effect. | |||
| 10387 | * (Note: geometry_size_to_pixels() depends on this.) | |||
| 10388 | */ | |||
| 10389 | *new_flags |= CDK_HINT_BASE_SIZE; | |||
| 10390 | ||||
| 10391 | new_geometry->base_width = extra_width; | |||
| 10392 | new_geometry->base_height = extra_height; | |||
| 10393 | ||||
| 10394 | /* As for X, if BASE_SIZE is not set but MIN_SIZE is set, then the | |||
| 10395 | * base size is the minimum size */ | |||
| 10396 | if (*new_flags & CDK_HINT_MIN_SIZE) | |||
| 10397 | { | |||
| 10398 | if (new_geometry->min_width > 0) | |||
| 10399 | new_geometry->base_width += new_geometry->min_width; | |||
| 10400 | if (new_geometry->min_height > 0) | |||
| 10401 | new_geometry->base_height += new_geometry->min_height; | |||
| 10402 | } | |||
| 10403 | } | |||
| 10404 | ||||
| 10405 | /* Please use a good size for unresizable widgets, not the minimum one. */ | |||
| 10406 | if (!priv->resizable) | |||
| 10407 | ctk_window_guess_default_size (window, &requisition.width, &requisition.height); | |||
| 10408 | ||||
| 10409 | if (*new_flags & CDK_HINT_MIN_SIZE) | |||
| 10410 | { | |||
| 10411 | if (new_geometry->min_width < 0) | |||
| 10412 | new_geometry->min_width = requisition.width; | |||
| 10413 | else | |||
| 10414 | new_geometry->min_width = MAX (requisition.width, new_geometry->min_width + extra_width)(((requisition.width) > (new_geometry->min_width + extra_width )) ? (requisition.width) : (new_geometry->min_width + extra_width )); | |||
| 10415 | ||||
| 10416 | if (new_geometry->min_height < 0) | |||
| 10417 | new_geometry->min_height = requisition.height; | |||
| 10418 | else | |||
| 10419 | new_geometry->min_height = MAX (requisition.height, new_geometry->min_height + extra_height)(((requisition.height) > (new_geometry->min_height + extra_height )) ? (requisition.height) : (new_geometry->min_height + extra_height )); | |||
| 10420 | } | |||
| 10421 | else | |||
| 10422 | { | |||
| 10423 | *new_flags |= CDK_HINT_MIN_SIZE; | |||
| 10424 | ||||
| 10425 | new_geometry->min_width = requisition.width; | |||
| 10426 | new_geometry->min_height = requisition.height; | |||
| 10427 | } | |||
| 10428 | ||||
| 10429 | if (*new_flags & CDK_HINT_MAX_SIZE) | |||
| 10430 | { | |||
| 10431 | if (new_geometry->max_width >= 0) | |||
| 10432 | new_geometry->max_width += extra_width; | |||
| 10433 | new_geometry->max_width = MAX (new_geometry->max_width, new_geometry->min_width)(((new_geometry->max_width) > (new_geometry->min_width )) ? (new_geometry->max_width) : (new_geometry->min_width )); | |||
| 10434 | ||||
| 10435 | if (new_geometry->max_height >= 0) | |||
| 10436 | new_geometry->max_height += extra_height; | |||
| 10437 | ||||
| 10438 | new_geometry->max_height = MAX (new_geometry->max_height, new_geometry->min_height)(((new_geometry->max_height) > (new_geometry->min_height )) ? (new_geometry->max_height) : (new_geometry->min_height )); | |||
| 10439 | } | |||
| 10440 | else if (!priv->resizable) | |||
| 10441 | { | |||
| 10442 | *new_flags |= CDK_HINT_MAX_SIZE; | |||
| 10443 | ||||
| 10444 | new_geometry->max_width = new_geometry->min_width; | |||
| 10445 | new_geometry->max_height = new_geometry->min_height; | |||
| 10446 | } | |||
| 10447 | ||||
| 10448 | *new_flags |= CDK_HINT_WIN_GRAVITY; | |||
| 10449 | new_geometry->win_gravity = priv->gravity; | |||
| 10450 | } | |||
| 10451 | ||||
| 10452 | #undef INCLUDE_CSD_SIZE | |||
| 10453 | #undef EXCLUDE_CSD_SIZE | |||
| 10454 | ||||
| 10455 | /*********************** | |||
| 10456 | * Redrawing functions * | |||
| 10457 | ***********************/ | |||
| 10458 | ||||
| 10459 | static gboolean | |||
| 10460 | ctk_window_draw (CtkWidget *widget, | |||
| 10461 | cairo_t *cr) | |||
| 10462 | { | |||
| 10463 | CtkWindowPrivate *priv = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ()))))))->priv; | |||
| 10464 | CtkStyleContext *context; | |||
| 10465 | gboolean ret = FALSE(0); | |||
| 10466 | CtkAllocation allocation; | |||
| 10467 | CtkBorder window_border; | |||
| 10468 | gint title_height; | |||
| 10469 | ||||
| 10470 | context = ctk_widget_get_style_context (widget); | |||
| 10471 | ||||
| 10472 | get_shadow_width (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))), &window_border); | |||
| 10473 | _ctk_widget_get_allocation (widget, &allocation); | |||
| 10474 | ||||
| 10475 | if (ctk_cairo_should_draw_window (cr, _ctk_widget_get_window (widget))) | |||
| 10476 | { | |||
| 10477 | if (priv->client_decorated && | |||
| 10478 | priv->decorated && | |||
| 10479 | !priv->fullscreen && | |||
| 10480 | !priv->maximized) | |||
| 10481 | { | |||
| 10482 | ctk_style_context_save_to_node (context, priv->decoration_node); | |||
| 10483 | ||||
| 10484 | if (priv->use_client_shadow) | |||
| 10485 | { | |||
| 10486 | CtkBorder padding, border; | |||
| 10487 | ||||
| 10488 | ctk_style_context_get_padding (context, ctk_style_context_get_state (context), &padding); | |||
| 10489 | ctk_style_context_get_border (context, ctk_style_context_get_state (context), &border); | |||
| 10490 | sum_borders (&border, &padding); | |||
| 10491 | ||||
| 10492 | ctk_render_background (context, cr, | |||
| 10493 | window_border.left - border.left, window_border.top - border.top, | |||
| 10494 | allocation.width - | |||
| 10495 | (window_border.left + window_border.right - border.left - border.right), | |||
| 10496 | allocation.height - | |||
| 10497 | (window_border.top + window_border.bottom - border.top - border.bottom)); | |||
| 10498 | ctk_render_frame (context, cr, | |||
| 10499 | window_border.left - border.left, window_border.top - border.top, | |||
| 10500 | allocation.width - | |||
| 10501 | (window_border.left + window_border.right - border.left - border.right), | |||
| 10502 | allocation.height - | |||
| 10503 | (window_border.top + window_border.bottom - border.top - border.bottom)); | |||
| 10504 | } | |||
| 10505 | else | |||
| 10506 | { | |||
| 10507 | ctk_render_background (context, cr, 0, 0, | |||
| 10508 | allocation.width, | |||
| 10509 | allocation.height); | |||
| 10510 | ||||
| 10511 | ctk_render_frame (context, cr, 0, 0, | |||
| 10512 | allocation.width, | |||
| 10513 | allocation.height); | |||
| 10514 | } | |||
| 10515 | ||||
| 10516 | ctk_style_context_restore (context); | |||
| 10517 | } | |||
| 10518 | ||||
| 10519 | if (!ctk_widget_get_app_paintable (widget)) | |||
| 10520 | { | |||
| 10521 | if (priv->title_box && | |||
| 10522 | ctk_widget_get_visible (priv->title_box) && | |||
| 10523 | ctk_widget_get_child_visible (priv->title_box)) | |||
| 10524 | title_height = priv->title_height; | |||
| 10525 | else | |||
| 10526 | title_height = 0; | |||
| 10527 | ||||
| 10528 | ctk_render_background (context, cr, | |||
| 10529 | window_border.left, | |||
| 10530 | window_border.top + title_height, | |||
| 10531 | allocation.width - | |||
| 10532 | (window_border.left + window_border.right), | |||
| 10533 | allocation.height - | |||
| 10534 | (window_border.top + window_border.bottom + | |||
| 10535 | title_height)); | |||
| 10536 | ctk_render_frame (context, cr, | |||
| 10537 | window_border.left, | |||
| 10538 | window_border.top + title_height, | |||
| 10539 | allocation.width - | |||
| 10540 | (window_border.left + window_border.right), | |||
| 10541 | allocation.height - | |||
| 10542 | (window_border.top + window_border.bottom + | |||
| 10543 | title_height)); | |||
| 10544 | } | |||
| 10545 | } | |||
| 10546 | ||||
| 10547 | if (CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->draw) | |||
| 10548 | ret = CTK_WIDGET_CLASS (ctk_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_window_parent_class)), ((ctk_widget_get_type ()))))) )->draw (widget, cr); | |||
| 10549 | ||||
| 10550 | return ret; | |||
| 10551 | } | |||
| 10552 | ||||
| 10553 | /** | |||
| 10554 | * ctk_window_present: | |||
| 10555 | * @window: a #CtkWindow | |||
| 10556 | * | |||
| 10557 | * Presents a window to the user. This function should not be used | |||
| 10558 | * as when it is called, it is too late to gather a valid timestamp | |||
| 10559 | * to allow focus stealing prevention to work correctly. | |||
| 10560 | **/ | |||
| 10561 | void | |||
| 10562 | ctk_window_present (CtkWindow *window) | |||
| 10563 | { | |||
| 10564 | ctk_window_present_with_time (window, CDK_CURRENT_TIME0L); | |||
| 10565 | } | |||
| 10566 | ||||
| 10567 | /** | |||
| 10568 | * ctk_window_present_with_time: | |||
| 10569 | * @window: a #CtkWindow | |||
| 10570 | * @timestamp: the timestamp of the user interaction (typically a | |||
| 10571 | * button or key press event) which triggered this call | |||
| 10572 | * | |||
| 10573 | * Presents a window to the user. This may mean raising the window | |||
| 10574 | * in the stacking order, deiconifying it, moving it to the current | |||
| 10575 | * desktop, and/or giving it the keyboard focus, possibly dependent | |||
| 10576 | * on the user’s platform, window manager, and preferences. | |||
| 10577 | * | |||
| 10578 | * If @window is hidden, this function calls ctk_widget_show() | |||
| 10579 | * as well. | |||
| 10580 | * | |||
| 10581 | * This function should be used when the user tries to open a window | |||
| 10582 | * that’s already open. Say for example the preferences dialog is | |||
| 10583 | * currently open, and the user chooses Preferences from the menu | |||
| 10584 | * a second time; use ctk_window_present() to move the already-open dialog | |||
| 10585 | * where the user can see it. | |||
| 10586 | * | |||
| 10587 | * Presents a window to the user in response to a user interaction. The | |||
| 10588 | * timestamp should be gathered when the window was requested to be shown | |||
| 10589 | * (when clicking a link for example), rather than once the window is | |||
| 10590 | * ready to be shown. | |||
| 10591 | * | |||
| 10592 | * Since: 2.8 | |||
| 10593 | **/ | |||
| 10594 | void | |||
| 10595 | ctk_window_present_with_time (CtkWindow *window, | |||
| 10596 | guint32 timestamp) | |||
| 10597 | { | |||
| 10598 | CtkWindowPrivate *priv; | |||
| 10599 | CtkWidget *widget; | |||
| 10600 | CdkWindow *cdk_window; | |||
| 10601 | ||||
| 10602 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10603 | ||||
| 10604 | priv = window->priv; | |||
| 10605 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 10606 | ||||
| 10607 | if (ctk_widget_get_visible (widget)) | |||
| 10608 | { | |||
| 10609 | cdk_window = _ctk_widget_get_window (widget); | |||
| 10610 | ||||
| 10611 | g_assert (cdk_window != NULL)do { if (cdk_window != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c", 10611, ((const char*) (__func__)), "cdk_window != NULL" ); } while (0); | |||
| 10612 | ||||
| 10613 | cdk_window_show (cdk_window); | |||
| 10614 | ||||
| 10615 | /* Translate a timestamp of CDK_CURRENT_TIME appropriately */ | |||
| 10616 | if (timestamp == CDK_CURRENT_TIME0L) | |||
| 10617 | { | |||
| 10618 | #ifdef CDK_WINDOWING_X11 | |||
| 10619 | if (CDK_IS_X11_WINDOW(cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_x11_window_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; }))))) | |||
| 10620 | { | |||
| 10621 | CdkDisplay *display; | |||
| 10622 | ||||
| 10623 | display = ctk_widget_get_display (widget); | |||
| 10624 | timestamp = cdk_x11_display_get_user_time (display); | |||
| 10625 | } | |||
| 10626 | else | |||
| 10627 | #endif | |||
| 10628 | timestamp = ctk_get_current_event_time (); | |||
| 10629 | } | |||
| 10630 | ||||
| 10631 | cdk_window_focus (cdk_window, timestamp); | |||
| 10632 | } | |||
| 10633 | else | |||
| 10634 | { | |||
| 10635 | priv->initial_timestamp = timestamp; | |||
| 10636 | ctk_widget_show (widget); | |||
| 10637 | } | |||
| 10638 | } | |||
| 10639 | ||||
| 10640 | /** | |||
| 10641 | * ctk_window_iconify: | |||
| 10642 | * @window: a #CtkWindow | |||
| 10643 | * | |||
| 10644 | * Asks to iconify (i.e. minimize) the specified @window. Note that | |||
| 10645 | * you shouldn’t assume the window is definitely iconified afterward, | |||
| 10646 | * because other entities (e.g. the user or | |||
| 10647 | * [window manager][ctk-X11-arch]) could deiconify it | |||
| 10648 | * again, or there may not be a window manager in which case | |||
| 10649 | * iconification isn’t possible, etc. But normally the window will end | |||
| 10650 | * up iconified. Just don’t write code that crashes if not. | |||
| 10651 | * | |||
| 10652 | * It’s permitted to call this function before showing a window, | |||
| 10653 | * in which case the window will be iconified before it ever appears | |||
| 10654 | * onscreen. | |||
| 10655 | * | |||
| 10656 | * You can track iconification via the “window-state-event” signal | |||
| 10657 | * on #CtkWidget. | |||
| 10658 | **/ | |||
| 10659 | void | |||
| 10660 | ctk_window_iconify (CtkWindow *window) | |||
| 10661 | { | |||
| 10662 | CdkWindow *toplevel; | |||
| 10663 | ||||
| 10664 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10665 | ||||
| 10666 | window->priv->iconify_initially = TRUE(!(0)); | |||
| 10667 | ||||
| 10668 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10669 | ||||
| 10670 | if (toplevel != NULL((void*)0)) | |||
| 10671 | cdk_window_iconify (toplevel); | |||
| 10672 | } | |||
| 10673 | ||||
| 10674 | /** | |||
| 10675 | * ctk_window_deiconify: | |||
| 10676 | * @window: a #CtkWindow | |||
| 10677 | * | |||
| 10678 | * Asks to deiconify (i.e. unminimize) the specified @window. Note | |||
| 10679 | * that you shouldn’t assume the window is definitely deiconified | |||
| 10680 | * afterward, because other entities (e.g. the user or | |||
| 10681 | * [window manager][ctk-X11-arch])) could iconify it | |||
| 10682 | * again before your code which assumes deiconification gets to run. | |||
| 10683 | * | |||
| 10684 | * You can track iconification via the “window-state-event” signal | |||
| 10685 | * on #CtkWidget. | |||
| 10686 | **/ | |||
| 10687 | void | |||
| 10688 | ctk_window_deiconify (CtkWindow *window) | |||
| 10689 | { | |||
| 10690 | CdkWindow *toplevel; | |||
| 10691 | ||||
| 10692 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10693 | ||||
| 10694 | window->priv->iconify_initially = FALSE(0); | |||
| 10695 | ||||
| 10696 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10697 | ||||
| 10698 | if (toplevel != NULL((void*)0)) | |||
| 10699 | cdk_window_deiconify (toplevel); | |||
| 10700 | } | |||
| 10701 | ||||
| 10702 | /** | |||
| 10703 | * ctk_window_stick: | |||
| 10704 | * @window: a #CtkWindow | |||
| 10705 | * | |||
| 10706 | * Asks to stick @window, which means that it will appear on all user | |||
| 10707 | * desktops. Note that you shouldn’t assume the window is definitely | |||
| 10708 | * stuck afterward, because other entities (e.g. the user or | |||
| 10709 | * [window manager][ctk-X11-arch] could unstick it | |||
| 10710 | * again, and some window managers do not support sticking | |||
| 10711 | * windows. But normally the window will end up stuck. Just don't | |||
| 10712 | * write code that crashes if not. | |||
| 10713 | * | |||
| 10714 | * It’s permitted to call this function before showing a window. | |||
| 10715 | * | |||
| 10716 | * You can track stickiness via the “window-state-event” signal | |||
| 10717 | * on #CtkWidget. | |||
| 10718 | **/ | |||
| 10719 | void | |||
| 10720 | ctk_window_stick (CtkWindow *window) | |||
| 10721 | { | |||
| 10722 | CdkWindow *toplevel; | |||
| 10723 | ||||
| 10724 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10725 | ||||
| 10726 | window->priv->stick_initially = TRUE(!(0)); | |||
| 10727 | ||||
| 10728 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10729 | ||||
| 10730 | if (toplevel != NULL((void*)0)) | |||
| 10731 | cdk_window_stick (toplevel); | |||
| 10732 | } | |||
| 10733 | ||||
| 10734 | /** | |||
| 10735 | * ctk_window_unstick: | |||
| 10736 | * @window: a #CtkWindow | |||
| 10737 | * | |||
| 10738 | * Asks to unstick @window, which means that it will appear on only | |||
| 10739 | * one of the user’s desktops. Note that you shouldn’t assume the | |||
| 10740 | * window is definitely unstuck afterward, because other entities | |||
| 10741 | * (e.g. the user or [window manager][ctk-X11-arch]) could | |||
| 10742 | * stick it again. But normally the window will | |||
| 10743 | * end up stuck. Just don’t write code that crashes if not. | |||
| 10744 | * | |||
| 10745 | * You can track stickiness via the “window-state-event” signal | |||
| 10746 | * on #CtkWidget. | |||
| 10747 | **/ | |||
| 10748 | void | |||
| 10749 | ctk_window_unstick (CtkWindow *window) | |||
| 10750 | { | |||
| 10751 | CdkWindow *toplevel; | |||
| 10752 | ||||
| 10753 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10754 | ||||
| 10755 | window->priv->stick_initially = FALSE(0); | |||
| 10756 | ||||
| 10757 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10758 | ||||
| 10759 | if (toplevel != NULL((void*)0)) | |||
| 10760 | cdk_window_unstick (toplevel); | |||
| 10761 | } | |||
| 10762 | ||||
| 10763 | /** | |||
| 10764 | * ctk_window_maximize: | |||
| 10765 | * @window: a #CtkWindow | |||
| 10766 | * | |||
| 10767 | * Asks to maximize @window, so that it becomes full-screen. Note that | |||
| 10768 | * you shouldn’t assume the window is definitely maximized afterward, | |||
| 10769 | * because other entities (e.g. the user or | |||
| 10770 | * [window manager][ctk-X11-arch]) could unmaximize it | |||
| 10771 | * again, and not all window managers support maximization. But | |||
| 10772 | * normally the window will end up maximized. Just don’t write code | |||
| 10773 | * that crashes if not. | |||
| 10774 | * | |||
| 10775 | * It’s permitted to call this function before showing a window, | |||
| 10776 | * in which case the window will be maximized when it appears onscreen | |||
| 10777 | * initially. | |||
| 10778 | * | |||
| 10779 | * You can track maximization via the “window-state-event” signal | |||
| 10780 | * on #CtkWidget, or by listening to notifications on the | |||
| 10781 | * #CtkWindow:is-maximized property. | |||
| 10782 | **/ | |||
| 10783 | void | |||
| 10784 | ctk_window_maximize (CtkWindow *window) | |||
| 10785 | { | |||
| 10786 | CdkWindow *toplevel; | |||
| 10787 | ||||
| 10788 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10789 | ||||
| 10790 | window->priv->maximize_initially = TRUE(!(0)); | |||
| 10791 | ||||
| 10792 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10793 | ||||
| 10794 | if (toplevel != NULL((void*)0)) | |||
| 10795 | cdk_window_maximize (toplevel); | |||
| 10796 | } | |||
| 10797 | ||||
| 10798 | /** | |||
| 10799 | * ctk_window_unmaximize: | |||
| 10800 | * @window: a #CtkWindow | |||
| 10801 | * | |||
| 10802 | * Asks to unmaximize @window. Note that you shouldn’t assume the | |||
| 10803 | * window is definitely unmaximized afterward, because other entities | |||
| 10804 | * (e.g. the user or [window manager][ctk-X11-arch]) | |||
| 10805 | * could maximize it again, and not all window | |||
| 10806 | * managers honor requests to unmaximize. But normally the window will | |||
| 10807 | * end up unmaximized. Just don’t write code that crashes if not. | |||
| 10808 | * | |||
| 10809 | * You can track maximization via the “window-state-event” signal | |||
| 10810 | * on #CtkWidget. | |||
| 10811 | **/ | |||
| 10812 | void | |||
| 10813 | ctk_window_unmaximize (CtkWindow *window) | |||
| 10814 | { | |||
| 10815 | CdkWindow *toplevel; | |||
| 10816 | ||||
| 10817 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10818 | ||||
| 10819 | window->priv->maximize_initially = FALSE(0); | |||
| 10820 | ||||
| 10821 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10822 | ||||
| 10823 | if (toplevel != NULL((void*)0)) | |||
| 10824 | cdk_window_unmaximize (toplevel); | |||
| 10825 | } | |||
| 10826 | ||||
| 10827 | /** | |||
| 10828 | * ctk_window_fullscreen: | |||
| 10829 | * @window: a #CtkWindow | |||
| 10830 | * | |||
| 10831 | * Asks to place @window in the fullscreen state. Note that you | |||
| 10832 | * shouldn’t assume the window is definitely full screen afterward, | |||
| 10833 | * because other entities (e.g. the user or | |||
| 10834 | * [window manager][ctk-X11-arch]) could unfullscreen it | |||
| 10835 | * again, and not all window managers honor requests to fullscreen | |||
| 10836 | * windows. But normally the window will end up fullscreen. Just | |||
| 10837 | * don’t write code that crashes if not. | |||
| 10838 | * | |||
| 10839 | * You can track the fullscreen state via the “window-state-event” signal | |||
| 10840 | * on #CtkWidget. | |||
| 10841 | * | |||
| 10842 | * Since: 2.2 | |||
| 10843 | **/ | |||
| 10844 | void | |||
| 10845 | ctk_window_fullscreen (CtkWindow *window) | |||
| 10846 | { | |||
| 10847 | CdkWindow *toplevel; | |||
| 10848 | ||||
| 10849 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10850 | ||||
| 10851 | window->priv->fullscreen_initially = TRUE(!(0)); | |||
| 10852 | ||||
| 10853 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10854 | ||||
| 10855 | if (toplevel != NULL((void*)0)) | |||
| 10856 | cdk_window_fullscreen (toplevel); | |||
| 10857 | } | |||
| 10858 | ||||
| 10859 | /** | |||
| 10860 | * ctk_window_fullscreen_on_monitor: | |||
| 10861 | * @window: a #CtkWindow | |||
| 10862 | * @screen: a #CdkScreen to draw to | |||
| 10863 | * @monitor: which monitor to go fullscreen on | |||
| 10864 | * | |||
| 10865 | * Asks to place @window in the fullscreen state. Note that you shouldn't assume | |||
| 10866 | * the window is definitely full screen afterward. | |||
| 10867 | * | |||
| 10868 | * You can track the fullscreen state via the "window-state-event" signal | |||
| 10869 | * on #CtkWidget. | |||
| 10870 | * | |||
| 10871 | * Since: 3.18 | |||
| 10872 | */ | |||
| 10873 | void | |||
| 10874 | ctk_window_fullscreen_on_monitor (CtkWindow *window, | |||
| 10875 | CdkScreen *screen, | |||
| 10876 | gint monitor) | |||
| 10877 | { | |||
| 10878 | CtkWindowPrivate *priv; | |||
| 10879 | CtkWidget *widget; | |||
| 10880 | CdkWindow *toplevel; | |||
| 10881 | ||||
| 10882 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10883 | g_return_if_fail (CDK_IS_SCREEN (screen))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((screen)); GType _t = ((cdk_screen_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 ("Ctk", ((const char*) (__func__)), "CDK_IS_SCREEN (screen)" ); return; } } while (0); | |||
| 10884 | g_return_if_fail (cdk_display_get_monitor (cdk_screen_get_display (screen), monitor) != NULL)do { if ((cdk_display_get_monitor (cdk_screen_get_display (screen ), monitor) != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cdk_display_get_monitor (cdk_screen_get_display (screen), monitor) != NULL" ); return; } } while (0); | |||
| 10885 | ||||
| 10886 | priv = window->priv; | |||
| 10887 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 10888 | ||||
| 10889 | ctk_window_set_screen (window, screen); | |||
| 10890 | ||||
| 10891 | priv->initial_fullscreen_monitor = monitor; | |||
| 10892 | priv->fullscreen_initially = TRUE(!(0)); | |||
| 10893 | ||||
| 10894 | toplevel = _ctk_widget_get_window (widget); | |||
| 10895 | ||||
| 10896 | if (toplevel != NULL((void*)0)) | |||
| 10897 | cdk_window_fullscreen_on_monitor (toplevel, monitor); | |||
| 10898 | } | |||
| 10899 | ||||
| 10900 | /** | |||
| 10901 | * ctk_window_unfullscreen: | |||
| 10902 | * @window: a #CtkWindow | |||
| 10903 | * | |||
| 10904 | * Asks to toggle off the fullscreen state for @window. Note that you | |||
| 10905 | * shouldn’t assume the window is definitely not full screen | |||
| 10906 | * afterward, because other entities (e.g. the user or | |||
| 10907 | * [window manager][ctk-X11-arch]) could fullscreen it | |||
| 10908 | * again, and not all window managers honor requests to unfullscreen | |||
| 10909 | * windows. But normally the window will end up restored to its normal | |||
| 10910 | * state. Just don’t write code that crashes if not. | |||
| 10911 | * | |||
| 10912 | * You can track the fullscreen state via the “window-state-event” signal | |||
| 10913 | * on #CtkWidget. | |||
| 10914 | * | |||
| 10915 | * Since: 2.2 | |||
| 10916 | **/ | |||
| 10917 | void | |||
| 10918 | ctk_window_unfullscreen (CtkWindow *window) | |||
| 10919 | { | |||
| 10920 | CdkWindow *toplevel; | |||
| 10921 | ||||
| 10922 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10923 | ||||
| 10924 | window->priv->initial_fullscreen_monitor = -1; | |||
| 10925 | window->priv->fullscreen_initially = FALSE(0); | |||
| 10926 | ||||
| 10927 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10928 | ||||
| 10929 | if (toplevel != NULL((void*)0)) | |||
| 10930 | cdk_window_unfullscreen (toplevel); | |||
| 10931 | } | |||
| 10932 | ||||
| 10933 | /** | |||
| 10934 | * ctk_window_set_keep_above: | |||
| 10935 | * @window: a #CtkWindow | |||
| 10936 | * @setting: whether to keep @window above other windows | |||
| 10937 | * | |||
| 10938 | * Asks to keep @window above, so that it stays on top. Note that | |||
| 10939 | * you shouldn’t assume the window is definitely above afterward, | |||
| 10940 | * because other entities (e.g. the user or | |||
| 10941 | * [window manager][ctk-X11-arch]) could not keep it above, | |||
| 10942 | * and not all window managers support keeping windows above. But | |||
| 10943 | * normally the window will end kept above. Just don’t write code | |||
| 10944 | * that crashes if not. | |||
| 10945 | * | |||
| 10946 | * It’s permitted to call this function before showing a window, | |||
| 10947 | * in which case the window will be kept above when it appears onscreen | |||
| 10948 | * initially. | |||
| 10949 | * | |||
| 10950 | * You can track the above state via the “window-state-event” signal | |||
| 10951 | * on #CtkWidget. | |||
| 10952 | * | |||
| 10953 | * Note that, according to the | |||
| 10954 | * [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec), | |||
| 10955 | * the above state is mainly meant for user preferences and should not | |||
| 10956 | * be used by applications e.g. for drawing attention to their | |||
| 10957 | * dialogs. | |||
| 10958 | * | |||
| 10959 | * Since: 2.4 | |||
| 10960 | **/ | |||
| 10961 | void | |||
| 10962 | ctk_window_set_keep_above (CtkWindow *window, | |||
| 10963 | gboolean setting) | |||
| 10964 | { | |||
| 10965 | CdkWindow *toplevel; | |||
| 10966 | ||||
| 10967 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 10968 | ||||
| 10969 | setting = setting != FALSE(0); | |||
| 10970 | ||||
| 10971 | window->priv->above_initially = setting; | |||
| 10972 | window->priv->below_initially &= !setting; | |||
| 10973 | ||||
| 10974 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 10975 | ||||
| 10976 | if (toplevel != NULL((void*)0)) | |||
| 10977 | cdk_window_set_keep_above (toplevel, setting); | |||
| 10978 | } | |||
| 10979 | ||||
| 10980 | /** | |||
| 10981 | * ctk_window_set_keep_below: | |||
| 10982 | * @window: a #CtkWindow | |||
| 10983 | * @setting: whether to keep @window below other windows | |||
| 10984 | * | |||
| 10985 | * Asks to keep @window below, so that it stays in bottom. Note that | |||
| 10986 | * you shouldn’t assume the window is definitely below afterward, | |||
| 10987 | * because other entities (e.g. the user or | |||
| 10988 | * [window manager][ctk-X11-arch]) could not keep it below, | |||
| 10989 | * and not all window managers support putting windows below. But | |||
| 10990 | * normally the window will be kept below. Just don’t write code | |||
| 10991 | * that crashes if not. | |||
| 10992 | * | |||
| 10993 | * It’s permitted to call this function before showing a window, | |||
| 10994 | * in which case the window will be kept below when it appears onscreen | |||
| 10995 | * initially. | |||
| 10996 | * | |||
| 10997 | * You can track the below state via the “window-state-event” signal | |||
| 10998 | * on #CtkWidget. | |||
| 10999 | * | |||
| 11000 | * Note that, according to the | |||
| 11001 | * [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec), | |||
| 11002 | * the above state is mainly meant for user preferences and should not | |||
| 11003 | * be used by applications e.g. for drawing attention to their | |||
| 11004 | * dialogs. | |||
| 11005 | * | |||
| 11006 | * Since: 2.4 | |||
| 11007 | **/ | |||
| 11008 | void | |||
| 11009 | ctk_window_set_keep_below (CtkWindow *window, | |||
| 11010 | gboolean setting) | |||
| 11011 | { | |||
| 11012 | CdkWindow *toplevel; | |||
| 11013 | ||||
| 11014 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 11015 | ||||
| 11016 | setting = setting != FALSE(0); | |||
| 11017 | ||||
| 11018 | window->priv->below_initially = setting; | |||
| 11019 | window->priv->above_initially &= !setting; | |||
| 11020 | ||||
| 11021 | toplevel = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 11022 | ||||
| 11023 | if (toplevel != NULL((void*)0)) | |||
| 11024 | cdk_window_set_keep_below (toplevel, setting); | |||
| 11025 | } | |||
| 11026 | ||||
| 11027 | /** | |||
| 11028 | * ctk_window_set_resizable: | |||
| 11029 | * @window: a #CtkWindow | |||
| 11030 | * @resizable: %TRUE if the user can resize this window | |||
| 11031 | * | |||
| 11032 | * Sets whether the user can resize a window. Windows are user resizable | |||
| 11033 | * by default. | |||
| 11034 | **/ | |||
| 11035 | void | |||
| 11036 | ctk_window_set_resizable (CtkWindow *window, | |||
| 11037 | gboolean resizable) | |||
| 11038 | { | |||
| 11039 | CtkWindowPrivate *priv; | |||
| 11040 | ||||
| 11041 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 11042 | ||||
| 11043 | priv = window->priv; | |||
| 11044 | ||||
| 11045 | resizable = (resizable != FALSE(0)); | |||
| 11046 | ||||
| 11047 | if (priv->resizable != resizable) | |||
| 11048 | { | |||
| 11049 | priv->resizable = resizable; | |||
| 11050 | ||||
| 11051 | update_window_buttons (window); | |||
| 11052 | ||||
| 11053 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 11054 | ||||
| 11055 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_RESIZABLE]); | |||
| 11056 | } | |||
| 11057 | } | |||
| 11058 | ||||
| 11059 | /** | |||
| 11060 | * ctk_window_get_resizable: | |||
| 11061 | * @window: a #CtkWindow | |||
| 11062 | * | |||
| 11063 | * Gets the value set by ctk_window_set_resizable(). | |||
| 11064 | * | |||
| 11065 | * Returns: %TRUE if the user can resize the window | |||
| 11066 | **/ | |||
| 11067 | gboolean | |||
| 11068 | ctk_window_get_resizable (CtkWindow *window) | |||
| 11069 | { | |||
| 11070 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 11071 | ||||
| 11072 | return window->priv->resizable; | |||
| 11073 | } | |||
| 11074 | ||||
| 11075 | /** | |||
| 11076 | * ctk_window_set_gravity: | |||
| 11077 | * @window: a #CtkWindow | |||
| 11078 | * @gravity: window gravity | |||
| 11079 | * | |||
| 11080 | * Window gravity defines the meaning of coordinates passed to | |||
| 11081 | * ctk_window_move(). See ctk_window_move() and #CdkGravity for | |||
| 11082 | * more details. | |||
| 11083 | * | |||
| 11084 | * The default window gravity is #CDK_GRAVITY_NORTH_WEST which will | |||
| 11085 | * typically “do what you mean.” | |||
| 11086 | * | |||
| 11087 | **/ | |||
| 11088 | void | |||
| 11089 | ctk_window_set_gravity (CtkWindow *window, | |||
| 11090 | CdkGravity gravity) | |||
| 11091 | { | |||
| 11092 | CtkWindowPrivate *priv; | |||
| 11093 | ||||
| 11094 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 11095 | ||||
| 11096 | priv = window->priv; | |||
| 11097 | ||||
| 11098 | if (gravity != priv->gravity) | |||
| 11099 | { | |||
| 11100 | priv->gravity = gravity; | |||
| 11101 | ||||
| 11102 | /* ctk_window_move_resize() will adapt gravity | |||
| 11103 | */ | |||
| 11104 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 11105 | ||||
| 11106 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_GRAVITY]); | |||
| 11107 | } | |||
| 11108 | } | |||
| 11109 | ||||
| 11110 | /** | |||
| 11111 | * ctk_window_get_gravity: | |||
| 11112 | * @window: a #CtkWindow | |||
| 11113 | * | |||
| 11114 | * Gets the value set by ctk_window_set_gravity(). | |||
| 11115 | * | |||
| 11116 | * Returns: (transfer none): window gravity | |||
| 11117 | **/ | |||
| 11118 | CdkGravity | |||
| 11119 | ctk_window_get_gravity (CtkWindow *window) | |||
| 11120 | { | |||
| 11121 | g_return_val_if_fail (CTK_IS_WINDOW (window), 0)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (0); } } while (0); | |||
| 11122 | ||||
| 11123 | return window->priv->gravity; | |||
| 11124 | } | |||
| 11125 | ||||
| 11126 | /** | |||
| 11127 | * ctk_window_begin_resize_drag: | |||
| 11128 | * @window: a #CtkWindow | |||
| 11129 | * @button: mouse button that initiated the drag | |||
| 11130 | * @edge: position of the resize control | |||
| 11131 | * @root_x: X position where the user clicked to initiate the drag, in root window coordinates | |||
| 11132 | * @root_y: Y position where the user clicked to initiate the drag | |||
| 11133 | * @timestamp: timestamp from the click event that initiated the drag | |||
| 11134 | * | |||
| 11135 | * Starts resizing a window. This function is used if an application | |||
| 11136 | * has window resizing controls. When CDK can support it, the resize | |||
| 11137 | * will be done using the standard mechanism for the | |||
| 11138 | * [window manager][ctk-X11-arch] or windowing | |||
| 11139 | * system. Otherwise, CDK will try to emulate window resizing, | |||
| 11140 | * potentially not all that well, depending on the windowing system. | |||
| 11141 | */ | |||
| 11142 | void | |||
| 11143 | ctk_window_begin_resize_drag (CtkWindow *window, | |||
| 11144 | CdkWindowEdge edge, | |||
| 11145 | gint button, | |||
| 11146 | gint root_x, | |||
| 11147 | gint root_y, | |||
| 11148 | guint32 timestamp) | |||
| 11149 | { | |||
| 11150 | CtkWidget *widget; | |||
| 11151 | CdkWindow *toplevel; | |||
| 11152 | ||||
| 11153 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 11154 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 11155 | g_return_if_fail (ctk_widget_get_visible (widget))do { if ((ctk_widget_get_visible (widget))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "ctk_widget_get_visible (widget)" ); return; } } while (0); | |||
| 11156 | ||||
| 11157 | toplevel = _ctk_widget_get_window (widget); | |||
| 11158 | ||||
| 11159 | cdk_window_begin_resize_drag (toplevel, | |||
| 11160 | edge, button, | |||
| 11161 | root_x, root_y, | |||
| 11162 | timestamp); | |||
| 11163 | } | |||
| 11164 | ||||
| 11165 | /** | |||
| 11166 | * ctk_window_begin_move_drag: | |||
| 11167 | * @window: a #CtkWindow | |||
| 11168 | * @button: mouse button that initiated the drag | |||
| 11169 | * @root_x: X position where the user clicked to initiate the drag, in root window coordinates | |||
| 11170 | * @root_y: Y position where the user clicked to initiate the drag | |||
| 11171 | * @timestamp: timestamp from the click event that initiated the drag | |||
| 11172 | * | |||
| 11173 | * Starts moving a window. This function is used if an application has | |||
| 11174 | * window movement grips. When CDK can support it, the window movement | |||
| 11175 | * will be done using the standard mechanism for the | |||
| 11176 | * [window manager][ctk-X11-arch] or windowing | |||
| 11177 | * system. Otherwise, CDK will try to emulate window movement, | |||
| 11178 | * potentially not all that well, depending on the windowing system. | |||
| 11179 | */ | |||
| 11180 | void | |||
| 11181 | ctk_window_begin_move_drag (CtkWindow *window, | |||
| 11182 | gint button, | |||
| 11183 | gint root_x, | |||
| 11184 | gint root_y, | |||
| 11185 | guint32 timestamp) | |||
| 11186 | { | |||
| 11187 | CtkWidget *widget; | |||
| 11188 | CdkWindow *toplevel; | |||
| 11189 | ||||
| 11190 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 11191 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 11192 | g_return_if_fail (ctk_widget_get_visible (widget))do { if ((ctk_widget_get_visible (widget))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "ctk_widget_get_visible (widget)" ); return; } } while (0); | |||
| 11193 | ||||
| 11194 | toplevel = _ctk_widget_get_window (widget); | |||
| 11195 | ||||
| 11196 | cdk_window_begin_move_drag (toplevel, | |||
| 11197 | button, | |||
| 11198 | root_x, root_y, | |||
| 11199 | timestamp); | |||
| 11200 | } | |||
| 11201 | ||||
| 11202 | /** | |||
| 11203 | * ctk_window_set_screen: | |||
| 11204 | * @window: a #CtkWindow. | |||
| 11205 | * @screen: a #CdkScreen. | |||
| 11206 | * | |||
| 11207 | * Sets the #CdkScreen where the @window is displayed; if | |||
| 11208 | * the window is already mapped, it will be unmapped, and | |||
| 11209 | * then remapped on the new screen. | |||
| 11210 | * | |||
| 11211 | * Since: 2.2 | |||
| 11212 | */ | |||
| 11213 | void | |||
| 11214 | ctk_window_set_screen (CtkWindow *window, | |||
| 11215 | CdkScreen *screen) | |||
| 11216 | { | |||
| 11217 | CtkWindowPrivate *priv; | |||
| 11218 | CtkWidget *widget; | |||
| 11219 | CdkScreen *previous_screen; | |||
| 11220 | gboolean was_rgba; | |||
| 11221 | gboolean was_mapped; | |||
| 11222 | ||||
| 11223 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 11224 | g_return_if_fail (CDK_IS_SCREEN (screen))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((screen)); GType _t = ((cdk_screen_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 ("Ctk", ((const char*) (__func__)), "CDK_IS_SCREEN (screen)" ); return; } } while (0); | |||
| 11225 | ||||
| 11226 | priv = window->priv; | |||
| 11227 | ||||
| 11228 | if (screen == priv->screen) | |||
| 11229 | return; | |||
| 11230 | ||||
| 11231 | /* reset initial_fullscreen_monitor since they are relative to the screen */ | |||
| 11232 | priv->initial_fullscreen_monitor = -1; | |||
| 11233 | ||||
| 11234 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 11235 | ||||
| 11236 | previous_screen = priv->screen; | |||
| 11237 | ||||
| 11238 | if (cdk_screen_get_rgba_visual (previous_screen) == ctk_widget_get_visual (widget)) | |||
| 11239 | was_rgba = TRUE(!(0)); | |||
| 11240 | else | |||
| 11241 | was_rgba = FALSE(0); | |||
| 11242 | ||||
| 11243 | was_mapped = _ctk_widget_get_mapped (widget); | |||
| 11244 | ||||
| 11245 | if (was_mapped) | |||
| 11246 | ctk_widget_unmap (widget); | |||
| 11247 | if (_ctk_widget_get_realized (widget)) | |||
| 11248 | ctk_widget_unrealize (widget); | |||
| 11249 | ||||
| 11250 | ctk_window_free_key_hash (window); | |||
| 11251 | priv->screen = screen; | |||
| 11252 | if (screen != previous_screen) | |||
| 11253 | { | |||
| 11254 | if (previous_screen) | |||
| 11255 | { | |||
| 11256 | g_signal_handlers_disconnect_by_func (previous_screen,g_signal_handlers_disconnect_matched ((previous_screen), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_window_on_composited_changed), (window)) | |||
| 11257 | ctk_window_on_composited_changed, window)g_signal_handlers_disconnect_matched ((previous_screen), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_window_on_composited_changed), (window)); | |||
| 11258 | #ifdef CDK_WINDOWING_X11 | |||
| 11259 | g_signal_handlers_disconnect_by_func (ctk_settings_get_for_screen (previous_screen),g_signal_handlers_disconnect_matched ((ctk_settings_get_for_screen (previous_screen)), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (ctk_window_on_theme_variant_changed ), (window)) | |||
| 11260 | ctk_window_on_theme_variant_changed, window)g_signal_handlers_disconnect_matched ((ctk_settings_get_for_screen (previous_screen)), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (ctk_window_on_theme_variant_changed ), (window)); | |||
| 11261 | #endif | |||
| 11262 | } | |||
| 11263 | g_signal_connect (screen, "composited-changed",g_signal_connect_data ((screen), ("composited-changed"), (((GCallback ) (ctk_window_on_composited_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
| 11264 | G_CALLBACK (ctk_window_on_composited_changed), window)g_signal_connect_data ((screen), ("composited-changed"), (((GCallback ) (ctk_window_on_composited_changed))), (window), ((void*)0), (GConnectFlags) 0); | |||
| 11265 | #ifdef CDK_WINDOWING_X11 | |||
| 11266 | g_signal_connect (ctk_settings_get_for_screen (screen),g_signal_connect_data ((ctk_settings_get_for_screen (screen)) , ("notify::ctk-application-prefer-dark-theme"), (((GCallback ) (ctk_window_on_theme_variant_changed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
| 11267 | "notify::ctk-application-prefer-dark-theme",g_signal_connect_data ((ctk_settings_get_for_screen (screen)) , ("notify::ctk-application-prefer-dark-theme"), (((GCallback ) (ctk_window_on_theme_variant_changed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
| 11268 | G_CALLBACK (ctk_window_on_theme_variant_changed), window)g_signal_connect_data ((ctk_settings_get_for_screen (screen)) , ("notify::ctk-application-prefer-dark-theme"), (((GCallback ) (ctk_window_on_theme_variant_changed))), (window), ((void*) 0), (GConnectFlags) 0); | |||
| 11269 | #endif | |||
| 11270 | ||||
| 11271 | _ctk_widget_propagate_screen_changed (widget, previous_screen); | |||
| 11272 | _ctk_widget_propagate_composited_changed (widget); | |||
| 11273 | } | |||
| 11274 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_SCREEN]); | |||
| 11275 | ||||
| 11276 | if (was_rgba && priv->use_client_shadow) | |||
| 11277 | { | |||
| 11278 | CdkVisual *visual; | |||
| 11279 | ||||
| 11280 | visual = cdk_screen_get_rgba_visual (screen); | |||
| 11281 | if (visual) | |||
| 11282 | ctk_widget_set_visual (widget, visual); | |||
| 11283 | } | |||
| 11284 | ||||
| 11285 | if (was_mapped) | |||
| 11286 | ctk_widget_map (widget); | |||
| 11287 | ||||
| 11288 | check_scale_changed (window); | |||
| 11289 | } | |||
| 11290 | ||||
| 11291 | static void | |||
| 11292 | ctk_window_set_theme_variant (CtkWindow *window) | |||
| 11293 | { | |||
| 11294 | #ifdef CDK_WINDOWING_X11 | |||
| 11295 | CdkWindow *cdk_window; | |||
| 11296 | gboolean dark_theme_requested; | |||
| 11297 | ||||
| 11298 | g_object_get (ctk_settings_get_for_screen (window->priv->screen), | |||
| 11299 | "ctk-application-prefer-dark-theme", &dark_theme_requested, | |||
| 11300 | NULL((void*)0)); | |||
| 11301 | ||||
| 11302 | cdk_window = _ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 11303 | ||||
| 11304 | if (CDK_IS_X11_WINDOW (cdk_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (cdk_window)); GType _t = ((cdk_x11_window_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; }))))) | |||
| 11305 | cdk_x11_window_set_theme_variant (cdk_window, | |||
| 11306 | dark_theme_requested ? "dark" : NULL((void*)0)); | |||
| 11307 | #endif | |||
| 11308 | } | |||
| 11309 | ||||
| 11310 | #ifdef CDK_WINDOWING_X11 | |||
| 11311 | static void | |||
| 11312 | ctk_window_on_theme_variant_changed (CtkSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 11313 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 11314 | CtkWindow *window) | |||
| 11315 | { | |||
| 11316 | if (window->priv->type == CTK_WINDOW_TOPLEVEL) | |||
| 11317 | ctk_window_set_theme_variant (window); | |||
| 11318 | } | |||
| 11319 | #endif | |||
| 11320 | ||||
| 11321 | static void | |||
| 11322 | ctk_window_on_composited_changed (CdkScreen *screen G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 11323 | CtkWindow *window) | |||
| 11324 | { | |||
| 11325 | CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 11326 | ||||
| 11327 | ctk_widget_queue_draw (widget); | |||
| 11328 | _ctk_widget_propagate_composited_changed (widget); | |||
| 11329 | } | |||
| 11330 | ||||
| 11331 | static CdkScreen * | |||
| 11332 | ctk_window_check_screen (CtkWindow *window) | |||
| 11333 | { | |||
| 11334 | CtkWindowPrivate *priv = window->priv; | |||
| 11335 | ||||
| 11336 | if (priv->screen) | |||
| 11337 | return priv->screen; | |||
| 11338 | else | |||
| 11339 | { | |||
| 11340 | g_warning ("Screen for CtkWindow not set; you must always set\n" | |||
| 11341 | "a screen for a CtkWindow before using the window"); | |||
| 11342 | return NULL((void*)0); | |||
| 11343 | } | |||
| 11344 | } | |||
| 11345 | ||||
| 11346 | /** | |||
| 11347 | * ctk_window_get_screen: | |||
| 11348 | * @window: a #CtkWindow. | |||
| 11349 | * | |||
| 11350 | * Returns the #CdkScreen associated with @window. | |||
| 11351 | * | |||
| 11352 | * Returns: (transfer none): a #CdkScreen. | |||
| 11353 | * | |||
| 11354 | * Since: 2.2 | |||
| 11355 | */ | |||
| 11356 | CdkScreen* | |||
| 11357 | ctk_window_get_screen (CtkWindow *window) | |||
| 11358 | { | |||
| 11359 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 11360 | ||||
| 11361 | return window->priv->screen; | |||
| 11362 | } | |||
| 11363 | ||||
| 11364 | CdkScreen * | |||
| 11365 | _ctk_window_get_screen (CtkWindow *window) | |||
| 11366 | { | |||
| 11367 | return window->priv->screen; | |||
| 11368 | } | |||
| 11369 | ||||
| 11370 | /** | |||
| 11371 | * ctk_window_is_active: | |||
| 11372 | * @window: a #CtkWindow | |||
| 11373 | * | |||
| 11374 | * Returns whether the window is part of the current active toplevel. | |||
| 11375 | * (That is, the toplevel window receiving keystrokes.) | |||
| 11376 | * The return value is %TRUE if the window is active toplevel | |||
| 11377 | * itself, but also if it is, say, a #CtkPlug embedded in the active toplevel. | |||
| 11378 | * You might use this function if you wanted to draw a widget | |||
| 11379 | * differently in an active window from a widget in an inactive window. | |||
| 11380 | * See ctk_window_has_toplevel_focus() | |||
| 11381 | * | |||
| 11382 | * Returns: %TRUE if the window part of the current active window. | |||
| 11383 | * | |||
| 11384 | * Since: 2.4 | |||
| 11385 | **/ | |||
| 11386 | gboolean | |||
| 11387 | ctk_window_is_active (CtkWindow *window) | |||
| 11388 | { | |||
| 11389 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 11390 | ||||
| 11391 | return window->priv->is_active; | |||
| 11392 | } | |||
| 11393 | ||||
| 11394 | /** | |||
| 11395 | * ctk_window_has_toplevel_focus: | |||
| 11396 | * @window: a #CtkWindow | |||
| 11397 | * | |||
| 11398 | * Returns whether the input focus is within this CtkWindow. | |||
| 11399 | * For real toplevel windows, this is identical to ctk_window_is_active(), | |||
| 11400 | * but for embedded windows, like #CtkPlug, the results will differ. | |||
| 11401 | * | |||
| 11402 | * Returns: %TRUE if the input focus is within this CtkWindow | |||
| 11403 | * | |||
| 11404 | * Since: 2.4 | |||
| 11405 | **/ | |||
| 11406 | gboolean | |||
| 11407 | ctk_window_has_toplevel_focus (CtkWindow *window) | |||
| 11408 | { | |||
| 11409 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 11410 | ||||
| 11411 | return window->priv->has_toplevel_focus; | |||
| 11412 | } | |||
| 11413 | ||||
| 11414 | /** | |||
| 11415 | * ctk_window_get_group: | |||
| 11416 | * @window: (allow-none): a #CtkWindow, or %NULL | |||
| 11417 | * | |||
| 11418 | * Returns the group for @window or the default group, if | |||
| 11419 | * @window is %NULL or if @window does not have an explicit | |||
| 11420 | * window group. | |||
| 11421 | * | |||
| 11422 | * Returns: (transfer none): the #CtkWindowGroup for a window or the default group | |||
| 11423 | * | |||
| 11424 | * Since: 2.10 | |||
| 11425 | */ | |||
| 11426 | CtkWindowGroup * | |||
| 11427 | ctk_window_get_group (CtkWindow *window) | |||
| 11428 | { | |||
| 11429 | if (window && window->priv->group) | |||
| 11430 | return window->priv->group; | |||
| 11431 | else | |||
| 11432 | { | |||
| 11433 | static CtkWindowGroup *default_group = NULL((void*)0); | |||
| 11434 | ||||
| 11435 | if (!default_group) | |||
| 11436 | default_group = ctk_window_group_new (); | |||
| 11437 | ||||
| 11438 | return default_group; | |||
| 11439 | } | |||
| 11440 | } | |||
| 11441 | ||||
| 11442 | /** | |||
| 11443 | * ctk_window_has_group: | |||
| 11444 | * @window: a #CtkWindow | |||
| 11445 | * | |||
| 11446 | * Returns whether @window has an explicit window group. | |||
| 11447 | * | |||
| 11448 | * Returns: %TRUE if @window has an explicit window group. | |||
| 11449 | * | |||
| 11450 | * Since 2.22 | |||
| 11451 | **/ | |||
| 11452 | gboolean | |||
| 11453 | ctk_window_has_group (CtkWindow *window) | |||
| 11454 | { | |||
| 11455 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 11456 | ||||
| 11457 | return window->priv->group != NULL((void*)0); | |||
| 11458 | } | |||
| 11459 | ||||
| 11460 | CtkWindowGroup * | |||
| 11461 | _ctk_window_get_window_group (CtkWindow *window) | |||
| 11462 | { | |||
| 11463 | return window->priv->group; | |||
| 11464 | } | |||
| 11465 | ||||
| 11466 | void | |||
| 11467 | _ctk_window_set_window_group (CtkWindow *window, | |||
| 11468 | CtkWindowGroup *group) | |||
| 11469 | { | |||
| 11470 | window->priv->group = group; | |||
| 11471 | } | |||
| 11472 | ||||
| 11473 | /* | |||
| 11474 | Derived from XParseGeometry() in XFree86 | |||
| 11475 | ||||
| 11476 | Copyright 1985, 1986, 1987,1998 The Open Group | |||
| 11477 | ||||
| 11478 | All Rights Reserved. | |||
| 11479 | ||||
| 11480 | The above copyright notice and this permission notice shall be included | |||
| 11481 | in all copies or substantial portions of the Software. | |||
| 11482 | ||||
| 11483 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |||
| 11484 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||
| 11485 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| 11486 | IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR | |||
| 11487 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |||
| 11488 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |||
| 11489 | OTHER DEALINGS IN THE SOFTWARE. | |||
| 11490 | ||||
| 11491 | Except as contained in this notice, the name of The Open Group shall | |||
| 11492 | not be used in advertising or otherwise to promote the sale, use or | |||
| 11493 | other dealings in this Software without prior written authorization | |||
| 11494 | from The Open Group. | |||
| 11495 | */ | |||
| 11496 | ||||
| 11497 | ||||
| 11498 | /* | |||
| 11499 | * XParseGeometry parses strings of the form | |||
| 11500 | * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where | |||
| 11501 | * width, height, xoffset, and yoffset are unsigned integers. | |||
| 11502 | * Example: “=80x24+300-49” | |||
| 11503 | * The equal sign is optional. | |||
| 11504 | * It returns a bitmask that indicates which of the four values | |||
| 11505 | * were actually found in the string. For each value found, | |||
| 11506 | * the corresponding argument is updated; for each value | |||
| 11507 | * not found, the corresponding argument is left unchanged. | |||
| 11508 | */ | |||
| 11509 | ||||
| 11510 | /* The following code is from Xlib, and is minimally modified, so we | |||
| 11511 | * can track any upstream changes if required. Don’t change this | |||
| 11512 | * code. Or if you do, put in a huge comment marking which thing | |||
| 11513 | * changed. | |||
| 11514 | */ | |||
| 11515 | ||||
| 11516 | static int | |||
| 11517 | read_int (gchar *string, | |||
| 11518 | gchar **next) | |||
| 11519 | { | |||
| 11520 | int result = 0; | |||
| 11521 | int sign = 1; | |||
| 11522 | ||||
| 11523 | if (*string == '+') | |||
| 11524 | string++; | |||
| 11525 | else if (*string == '-') | |||
| 11526 | { | |||
| 11527 | string++; | |||
| 11528 | sign = -1; | |||
| 11529 | } | |||
| 11530 | ||||
| 11531 | for (; (*string >= '0') && (*string <= '9'); string++) | |||
| 11532 | { | |||
| 11533 | result = (result * 10) + (*string - '0'); | |||
| 11534 | } | |||
| 11535 | ||||
| 11536 | *next = string; | |||
| 11537 | ||||
| 11538 | if (sign >= 0) | |||
| 11539 | return (result); | |||
| 11540 | else | |||
| 11541 | return (-result); | |||
| 11542 | } | |||
| 11543 | ||||
| 11544 | /* | |||
| 11545 | * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding | |||
| 11546 | * value (x, y, width, height) was found in the parsed string. | |||
| 11547 | */ | |||
| 11548 | #define NoValue0x0000 0x0000 | |||
| 11549 | #define XValue0x0001 0x0001 | |||
| 11550 | #define YValue0x0002 0x0002 | |||
| 11551 | #define WidthValue0x0004 0x0004 | |||
| 11552 | #define HeightValue0x0008 0x0008 | |||
| 11553 | #define AllValues0x000F 0x000F | |||
| 11554 | #define XNegative0x0010 0x0010 | |||
| 11555 | #define YNegative0x0020 0x0020 | |||
| 11556 | ||||
| 11557 | /* Try not to reformat/modify, so we can compare/sync with X sources */ | |||
| 11558 | static int | |||
| 11559 | ctk_XParseGeometry (const char *string, | |||
| 11560 | int *x, | |||
| 11561 | int *y, | |||
| 11562 | unsigned int *width, | |||
| 11563 | unsigned int *height) | |||
| 11564 | { | |||
| 11565 | int mask = NoValue0x0000; | |||
| 11566 | char *strind; | |||
| 11567 | unsigned int tempWidth, tempHeight; | |||
| 11568 | int tempX, tempY; | |||
| 11569 | char *nextCharacter; | |||
| 11570 | ||||
| 11571 | /* These initializations are just to silence gcc */ | |||
| 11572 | tempWidth = 0; | |||
| 11573 | tempHeight = 0; | |||
| 11574 | tempX = 0; | |||
| 11575 | tempY = 0; | |||
| 11576 | ||||
| 11577 | if ( (string == NULL((void*)0)) || (*string == '\0')) return(mask); | |||
| 11578 | if (*string == '=') | |||
| 11579 | string++; /* ignore possible '=' at beg of geometry spec */ | |||
| 11580 | ||||
| 11581 | strind = (char *)string; | |||
| 11582 | if (*strind != '+' && *strind != '-' && *strind != 'x') { | |||
| 11583 | tempWidth = read_int(strind, &nextCharacter); | |||
| 11584 | if (strind == nextCharacter) | |||
| 11585 | return (0); | |||
| 11586 | strind = nextCharacter; | |||
| 11587 | mask |= WidthValue0x0004; | |||
| 11588 | } | |||
| 11589 | ||||
| 11590 | if (*strind == 'x' || *strind == 'X') { | |||
| 11591 | strind++; | |||
| 11592 | tempHeight = read_int(strind, &nextCharacter); | |||
| 11593 | if (strind == nextCharacter) | |||
| 11594 | return (0); | |||
| 11595 | strind = nextCharacter; | |||
| 11596 | mask |= HeightValue0x0008; | |||
| 11597 | } | |||
| 11598 | ||||
| 11599 | if ((*strind == '+') || (*strind == '-')) { | |||
| 11600 | if (*strind == '-') { | |||
| 11601 | strind++; | |||
| 11602 | tempX = -read_int(strind, &nextCharacter); | |||
| 11603 | if (strind == nextCharacter) | |||
| 11604 | return (0); | |||
| 11605 | strind = nextCharacter; | |||
| 11606 | mask |= XNegative0x0010; | |||
| 11607 | ||||
| 11608 | } | |||
| 11609 | else | |||
| 11610 | { strind++; | |||
| 11611 | tempX = read_int(strind, &nextCharacter); | |||
| 11612 | if (strind == nextCharacter) | |||
| 11613 | return(0); | |||
| 11614 | strind = nextCharacter; | |||
| 11615 | } | |||
| 11616 | mask |= XValue0x0001; | |||
| 11617 | if ((*strind == '+') || (*strind == '-')) { | |||
| 11618 | if (*strind == '-') { | |||
| 11619 | strind++; | |||
| 11620 | tempY = -read_int(strind, &nextCharacter); | |||
| 11621 | if (strind == nextCharacter) | |||
| 11622 | return(0); | |||
| 11623 | strind = nextCharacter; | |||
| 11624 | mask |= YNegative0x0020; | |||
| 11625 | ||||
| 11626 | } | |||
| 11627 | else | |||
| 11628 | { | |||
| 11629 | strind++; | |||
| 11630 | tempY = read_int(strind, &nextCharacter); | |||
| 11631 | if (strind == nextCharacter) | |||
| 11632 | return(0); | |||
| 11633 | strind = nextCharacter; | |||
| 11634 | } | |||
| 11635 | mask |= YValue0x0002; | |||
| 11636 | } | |||
| 11637 | } | |||
| 11638 | ||||
| 11639 | /* If strind isn't at the end of the string the it's an invalid | |||
| 11640 | geometry specification. */ | |||
| 11641 | ||||
| 11642 | if (*strind != '\0') return (0); | |||
| 11643 | ||||
| 11644 | if (mask & XValue0x0001) | |||
| 11645 | *x = tempX; | |||
| 11646 | if (mask & YValue0x0002) | |||
| 11647 | *y = tempY; | |||
| 11648 | if (mask & WidthValue0x0004) | |||
| 11649 | *width = tempWidth; | |||
| 11650 | if (mask & HeightValue0x0008) | |||
| 11651 | *height = tempHeight; | |||
| 11652 | return (mask); | |||
| 11653 | } | |||
| 11654 | ||||
| 11655 | /** | |||
| 11656 | * ctk_window_parse_geometry: | |||
| 11657 | * @window: a #CtkWindow | |||
| 11658 | * @geometry: geometry string | |||
| 11659 | * | |||
| 11660 | * Parses a standard X Window System geometry string - see the | |||
| 11661 | * manual page for X (type “man X”) for details on this. | |||
| 11662 | * ctk_window_parse_geometry() does work on all CTK+ ports | |||
| 11663 | * including Win32 but is primarily intended for an X environment. | |||
| 11664 | * | |||
| 11665 | * If either a size or a position can be extracted from the | |||
| 11666 | * geometry string, ctk_window_parse_geometry() returns %TRUE | |||
| 11667 | * and calls ctk_window_set_default_size() and/or ctk_window_move() | |||
| 11668 | * to resize/move the window. | |||
| 11669 | * | |||
| 11670 | * If ctk_window_parse_geometry() returns %TRUE, it will also | |||
| 11671 | * set the #CDK_HINT_USER_POS and/or #CDK_HINT_USER_SIZE hints | |||
| 11672 | * indicating to the window manager that the size/position of | |||
| 11673 | * the window was user-specified. This causes most window | |||
| 11674 | * managers to honor the geometry. | |||
| 11675 | * | |||
| 11676 | * Note that for ctk_window_parse_geometry() to work as expected, it has | |||
| 11677 | * to be called when the window has its “final” size, i.e. after calling | |||
| 11678 | * ctk_widget_show_all() on the contents and ctk_window_set_geometry_hints() | |||
| 11679 | * on the window. | |||
| 11680 | * |[<!-- language="C" --> | |||
| 11681 | * #include <ctk/ctk.h> | |||
| 11682 | * | |||
| 11683 | * static void | |||
| 11684 | * fill_with_content (CtkWidget *vbox) | |||
| 11685 | * { | |||
| 11686 | * // fill with content... | |||
| 11687 | * } | |||
| 11688 | * | |||
| 11689 | * int | |||
| 11690 | * main (int argc, char *argv[]) | |||
| 11691 | * { | |||
| 11692 | * CtkWidget *window, *vbox; | |||
| 11693 | * CdkGeometry size_hints = { | |||
| 11694 | * 100, 50, 0, 0, 100, 50, 10, | |||
| 11695 | * 10, 0.0, 0.0, CDK_GRAVITY_NORTH_WEST | |||
| 11696 | * }; | |||
| 11697 | * | |||
| 11698 | * ctk_init (&argc, &argv); | |||
| 11699 | * | |||
| 11700 | * window = ctk_window_new (CTK_WINDOW_TOPLEVEL); | |||
| 11701 | * vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
| 11702 | * | |||
| 11703 | * ctk_container_add (CTK_CONTAINER (window), vbox); | |||
| 11704 | * fill_with_content (vbox); | |||
| 11705 | * ctk_widget_show_all (vbox); | |||
| 11706 | * | |||
| 11707 | * ctk_window_set_geometry_hints (CTK_WINDOW (window), | |||
| 11708 | * NULL, | |||
| 11709 | * &size_hints, | |||
| 11710 | * CDK_HINT_MIN_SIZE | | |||
| 11711 | * CDK_HINT_BASE_SIZE | | |||
| 11712 | * CDK_HINT_RESIZE_INC); | |||
| 11713 | * | |||
| 11714 | * if (argc > 1) | |||
| 11715 | * { | |||
| 11716 | * gboolean res; | |||
| 11717 | * res = ctk_window_parse_geometry (CTK_WINDOW (window), | |||
| 11718 | * argv[1]); | |||
| 11719 | * if (! res) | |||
| 11720 | * fprintf (stderr, | |||
| 11721 | * "Failed to parse “%s”\n", | |||
| 11722 | * argv[1]); | |||
| 11723 | * } | |||
| 11724 | * | |||
| 11725 | * ctk_widget_show_all (window); | |||
| 11726 | * ctk_main (); | |||
| 11727 | * | |||
| 11728 | * return 0; | |||
| 11729 | * } | |||
| 11730 | * ]| | |||
| 11731 | * | |||
| 11732 | * Returns: %TRUE if string was parsed successfully | |||
| 11733 | **/ | |||
| 11734 | gboolean | |||
| 11735 | ctk_window_parse_geometry (CtkWindow *window, | |||
| 11736 | const gchar *geometry) | |||
| 11737 | { | |||
| 11738 | gint result, x = 0, y = 0; | |||
| 11739 | guint w, h; | |||
| 11740 | CtkWidget *child; | |||
| 11741 | CdkGravity grav; | |||
| 11742 | gboolean size_set, pos_set; | |||
| 11743 | CdkScreen *screen; | |||
| 11744 | ||||
| 11745 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 11746 | g_return_val_if_fail (geometry != NULL, FALSE)do { if ((geometry != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "geometry != NULL"); return ((0)); } } while (0); | |||
| 11747 | ||||
| 11748 | child = ctk_bin_get_child (CTK_BIN (window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_bin_get_type ()))))))); | |||
| 11749 | if (!child || !ctk_widget_get_visible (child)) | |||
| 11750 | g_warning ("ctk_window_parse_geometry() called on a window with no " | |||
| 11751 | "visible children; the window should be set up before " | |||
| 11752 | "ctk_window_parse_geometry() is called."); | |||
| 11753 | ||||
| 11754 | screen = ctk_window_check_screen (window); | |||
| 11755 | ||||
| 11756 | result = ctk_XParseGeometry (geometry, &x, &y, &w, &h); | |||
| 11757 | ||||
| 11758 | size_set = FALSE(0); | |||
| 11759 | if ((result & WidthValue0x0004) || (result & HeightValue0x0008)) | |||
| 11760 | { | |||
| 11761 | ctk_window_set_default_size_internal (window, | |||
| 11762 | TRUE(!(0)), result & WidthValue0x0004 ? w : -1, | |||
| 11763 | TRUE(!(0)), result & HeightValue0x0008 ? h : -1, | |||
| 11764 | TRUE(!(0))); | |||
| 11765 | size_set = TRUE(!(0)); | |||
| 11766 | } | |||
| 11767 | ||||
| 11768 | ctk_window_get_size (window, (gint *)&w, (gint *)&h); | |||
| 11769 | ||||
| 11770 | grav = CDK_GRAVITY_NORTH_WEST; | |||
| 11771 | ||||
| 11772 | if ((result & XNegative0x0010) && (result & YNegative0x0020)) | |||
| 11773 | grav = CDK_GRAVITY_SOUTH_EAST; | |||
| 11774 | else if (result & XNegative0x0010) | |||
| 11775 | grav = CDK_GRAVITY_NORTH_EAST; | |||
| 11776 | else if (result & YNegative0x0020) | |||
| 11777 | grav = CDK_GRAVITY_SOUTH_WEST; | |||
| 11778 | ||||
| 11779 | if ((result & XValue0x0001) == 0) | |||
| 11780 | x = 0; | |||
| 11781 | ||||
| 11782 | if ((result & YValue0x0002) == 0) | |||
| 11783 | y = 0; | |||
| 11784 | ||||
| 11785 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" | |||
| 11786 | if (grav == CDK_GRAVITY_SOUTH_WEST || | |||
| 11787 | grav == CDK_GRAVITY_SOUTH_EAST) | |||
| 11788 | y = cdk_screen_get_height (screen) - h + y; | |||
| 11789 | ||||
| 11790 | if (grav == CDK_GRAVITY_SOUTH_EAST || | |||
| 11791 | grav == CDK_GRAVITY_NORTH_EAST) | |||
| 11792 | x = cdk_screen_get_width (screen) - w + x; | |||
| 11793 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop | |||
| 11794 | ||||
| 11795 | /* we don't let you put a window offscreen; maybe some people would | |||
| 11796 | * prefer to be able to, but it's kind of a bogus thing to do. | |||
| 11797 | */ | |||
| 11798 | if (y < 0) | |||
| 11799 | y = 0; | |||
| 11800 | ||||
| 11801 | if (x < 0) | |||
| 11802 | x = 0; | |||
| 11803 | ||||
| 11804 | pos_set = FALSE(0); | |||
| 11805 | if ((result & XValue0x0001) || (result & YValue0x0002)) | |||
| 11806 | { | |||
| 11807 | ctk_window_set_gravity (window, grav); | |||
| 11808 | ctk_window_move (window, x, y); | |||
| 11809 | pos_set = TRUE(!(0)); | |||
| 11810 | } | |||
| 11811 | ||||
| 11812 | if (size_set || pos_set) | |||
| 11813 | { | |||
| 11814 | /* Set USSize, USPosition hints */ | |||
| 11815 | CtkWindowGeometryInfo *info; | |||
| 11816 | ||||
| 11817 | info = ctk_window_get_geometry_info (window, TRUE(!(0))); | |||
| 11818 | ||||
| 11819 | if (pos_set) | |||
| 11820 | info->mask |= CDK_HINT_USER_POS; | |||
| 11821 | if (size_set) | |||
| 11822 | info->mask |= CDK_HINT_USER_SIZE; | |||
| 11823 | } | |||
| 11824 | ||||
| 11825 | return result != 0; | |||
| 11826 | } | |||
| 11827 | ||||
| 11828 | gboolean | |||
| 11829 | _ctk_window_activate_menubar (CtkWindow *window, | |||
| 11830 | CdkEventKey *event) | |||
| 11831 | { | |||
| 11832 | CtkWindowPrivate *priv = window->priv; | |||
| 11833 | gchar *accel = NULL((void*)0); | |||
| 11834 | guint keyval = 0; | |||
| 11835 | CdkModifierType mods = 0; | |||
| 11836 | ||||
| 11837 | g_object_get (ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 11838 | "ctk-menu-bar-accel", &accel, | |||
| 11839 | NULL((void*)0)); | |||
| 11840 | ||||
| 11841 | if (accel == NULL((void*)0) || *accel == 0) | |||
| 11842 | return FALSE(0); | |||
| 11843 | ||||
| 11844 | ctk_accelerator_parse (accel, &keyval, &mods); | |||
| 11845 | ||||
| 11846 | if (keyval == 0) | |||
| 11847 | { | |||
| 11848 | g_warning ("Failed to parse menu bar accelerator '%s'", accel); | |||
| 11849 | g_free (accel)(__builtin_object_size ((accel), 0) != ((size_t) - 1)) ? g_free_sized (accel, __builtin_object_size ((accel), 0)) : (g_free) (accel ); | |||
| 11850 | return FALSE(0); | |||
| 11851 | } | |||
| 11852 | ||||
| 11853 | g_free (accel)(__builtin_object_size ((accel), 0) != ((size_t) - 1)) ? g_free_sized (accel, __builtin_object_size ((accel), 0)) : (g_free) (accel ); | |||
| 11854 | ||||
| 11855 | /* FIXME this is wrong, needs to be in the global accel resolution | |||
| 11856 | * thing, to properly consider i18n etc., but that probably requires | |||
| 11857 | * AccelGroup changes etc. | |||
| 11858 | */ | |||
| 11859 | if (event->keyval == keyval && | |||
| 11860 | ((event->state & ctk_accelerator_get_default_mod_mask ()) == | |||
| 11861 | (mods & ctk_accelerator_get_default_mod_mask ()))) | |||
| 11862 | { | |||
| 11863 | GList *tmp_menubars; | |||
| 11864 | GList *menubars; | |||
| 11865 | CtkMenuShell *menu_shell; | |||
| 11866 | CtkWidget *focus; | |||
| 11867 | ||||
| 11868 | focus = ctk_window_get_focus (window); | |||
| 11869 | ||||
| 11870 | if (priv->title_box != NULL((void*)0) && | |||
| 11871 | (focus == NULL((void*)0) || !ctk_widget_is_ancestor (focus, priv->title_box)) && | |||
| 11872 | ctk_widget_child_focus (priv->title_box, CTK_DIR_TAB_FORWARD)) | |||
| 11873 | return TRUE(!(0)); | |||
| 11874 | ||||
| 11875 | tmp_menubars = _ctk_menu_bar_get_viewable_menu_bars (window); | |||
| 11876 | if (tmp_menubars == NULL((void*)0)) | |||
| 11877 | return FALSE(0); | |||
| 11878 | ||||
| 11879 | menubars = _ctk_container_focus_sort (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), tmp_menubars, | |||
| 11880 | CTK_DIR_TAB_FORWARD, NULL((void*)0)); | |||
| 11881 | g_list_free (tmp_menubars); | |||
| 11882 | ||||
| 11883 | if (menubars == NULL((void*)0)) | |||
| 11884 | return FALSE(0); | |||
| 11885 | ||||
| 11886 | menu_shell = CTK_MENU_SHELL (menubars->data)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menubars->data)), ((ctk_menu_shell_get_type ())))))); | |||
| 11887 | ||||
| 11888 | _ctk_menu_shell_set_keyboard_mode (menu_shell, TRUE(!(0))); | |||
| 11889 | ctk_menu_shell_select_first (menu_shell, FALSE(0)); | |||
| 11890 | ||||
| 11891 | g_list_free (menubars); | |||
| 11892 | ||||
| 11893 | return TRUE(!(0)); | |||
| 11894 | } | |||
| 11895 | return FALSE(0); | |||
| 11896 | } | |||
| 11897 | ||||
| 11898 | static void | |||
| 11899 | ctk_window_mnemonic_hash_foreach (guint keyval, | |||
| 11900 | GSList *targets G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 11901 | gpointer data) | |||
| 11902 | { | |||
| 11903 | struct { | |||
| 11904 | CtkWindow *window; | |||
| 11905 | CtkWindowKeysForeachFunc func; | |||
| 11906 | gpointer func_data; | |||
| 11907 | } *info = data; | |||
| 11908 | ||||
| 11909 | (*info->func) (info->window, keyval, info->window->priv->mnemonic_modifier, TRUE(!(0)), info->func_data); | |||
| 11910 | } | |||
| 11911 | ||||
| 11912 | void | |||
| 11913 | _ctk_window_keys_foreach (CtkWindow *window, | |||
| 11914 | CtkWindowKeysForeachFunc func, | |||
| 11915 | gpointer func_data) | |||
| 11916 | { | |||
| 11917 | GSList *groups; | |||
| 11918 | CtkMnemonicHash *mnemonic_hash; | |||
| 11919 | ||||
| 11920 | struct { | |||
| 11921 | CtkWindow *window; | |||
| 11922 | CtkWindowKeysForeachFunc func; | |||
| 11923 | gpointer func_data; | |||
| 11924 | } info; | |||
| 11925 | ||||
| 11926 | info.window = window; | |||
| 11927 | info.func = func; | |||
| 11928 | info.func_data = func_data; | |||
| 11929 | ||||
| 11930 | mnemonic_hash = ctk_window_get_mnemonic_hash (window, FALSE(0)); | |||
| 11931 | if (mnemonic_hash) | |||
| 11932 | _ctk_mnemonic_hash_foreach (mnemonic_hash, | |||
| 11933 | ctk_window_mnemonic_hash_foreach, &info); | |||
| 11934 | ||||
| 11935 | groups = ctk_accel_groups_from_object (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | |||
| 11936 | while (groups) | |||
| 11937 | { | |||
| 11938 | CtkAccelGroup *group = groups->data; | |||
| 11939 | gint i; | |||
| 11940 | ||||
| 11941 | for (i = 0; i < group->priv->n_accels; i++) | |||
| 11942 | { | |||
| 11943 | CtkAccelKey *key = &group->priv->priv_accels[i].key; | |||
| 11944 | ||||
| 11945 | if (key->accel_key) | |||
| 11946 | (*func) (window, key->accel_key, key->accel_mods, FALSE(0), func_data); | |||
| 11947 | } | |||
| 11948 | ||||
| 11949 | groups = groups->next; | |||
| 11950 | } | |||
| 11951 | ||||
| 11952 | if (window->priv->application) | |||
| 11953 | { | |||
| 11954 | CtkApplicationAccels *app_accels; | |||
| 11955 | ||||
| 11956 | app_accels = ctk_application_get_application_accels (window->priv->application); | |||
| 11957 | ctk_application_accels_foreach_key (app_accels, window, func, func_data); | |||
| 11958 | } | |||
| 11959 | } | |||
| 11960 | ||||
| 11961 | static void | |||
| 11962 | ctk_window_keys_changed (CtkWindow *window) | |||
| 11963 | { | |||
| 11964 | ctk_window_free_key_hash (window); | |||
| 11965 | ctk_window_get_key_hash (window); | |||
| 11966 | } | |||
| 11967 | ||||
| 11968 | typedef struct _CtkWindowKeyEntry CtkWindowKeyEntry; | |||
| 11969 | ||||
| 11970 | struct _CtkWindowKeyEntry | |||
| 11971 | { | |||
| 11972 | guint keyval; | |||
| 11973 | guint modifiers; | |||
| 11974 | guint is_mnemonic : 1; | |||
| 11975 | }; | |||
| 11976 | ||||
| 11977 | static void | |||
| 11978 | window_key_entry_destroy (gpointer data) | |||
| 11979 | { | |||
| 11980 | g_slice_free (CtkWindowKeyEntry, data)do { if (1) g_slice_free1 (sizeof (CtkWindowKeyEntry), (data) ); else (void) ((CtkWindowKeyEntry*) 0 == (data)); } while (0 ); | |||
| 11981 | } | |||
| 11982 | ||||
| 11983 | static void | |||
| 11984 | add_to_key_hash (CtkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 11985 | guint keyval, | |||
| 11986 | CdkModifierType modifiers, | |||
| 11987 | gboolean is_mnemonic, | |||
| 11988 | gpointer data) | |||
| 11989 | { | |||
| 11990 | CtkKeyHash *key_hash = data; | |||
| 11991 | ||||
| 11992 | CtkWindowKeyEntry *entry = g_slice_new (CtkWindowKeyEntry)((CtkWindowKeyEntry*) g_slice_alloc ((sizeof (CtkWindowKeyEntry ) > 0 ? sizeof (CtkWindowKeyEntry) : 1))); | |||
| 11993 | ||||
| 11994 | entry->keyval = keyval; | |||
| 11995 | entry->modifiers = modifiers; | |||
| 11996 | entry->is_mnemonic = is_mnemonic; | |||
| 11997 | ||||
| 11998 | /* CtkAccelGroup stores lowercased accelerators. To deal | |||
| 11999 | * with this, if <Shift> was specified, uppercase. | |||
| 12000 | */ | |||
| 12001 | if (modifiers & CDK_SHIFT_MASK) | |||
| 12002 | { | |||
| 12003 | if (keyval == CDK_KEY_Tab0xff09) | |||
| 12004 | keyval = CDK_KEY_ISO_Left_Tab0xfe20; | |||
| 12005 | else | |||
| 12006 | keyval = cdk_keyval_to_upper (keyval); | |||
| 12007 | } | |||
| 12008 | ||||
| 12009 | _ctk_key_hash_add_entry (key_hash, keyval, entry->modifiers, entry); | |||
| 12010 | } | |||
| 12011 | ||||
| 12012 | static CtkKeyHash * | |||
| 12013 | ctk_window_get_key_hash (CtkWindow *window) | |||
| 12014 | { | |||
| 12015 | CdkScreen *screen = ctk_window_check_screen (window); | |||
| 12016 | CtkKeyHash *key_hash = g_object_get_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), quark_ctk_window_key_hash); | |||
| 12017 | ||||
| 12018 | if (key_hash) | |||
| 12019 | return key_hash; | |||
| 12020 | ||||
| 12021 | key_hash = _ctk_key_hash_new (cdk_keymap_get_for_display (cdk_screen_get_display (screen)), | |||
| 12022 | (GDestroyNotify)window_key_entry_destroy); | |||
| 12023 | _ctk_window_keys_foreach (window, add_to_key_hash, key_hash); | |||
| 12024 | g_object_set_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), quark_ctk_window_key_hash, key_hash); | |||
| 12025 | ||||
| 12026 | return key_hash; | |||
| 12027 | } | |||
| 12028 | ||||
| 12029 | static void | |||
| 12030 | ctk_window_free_key_hash (CtkWindow *window) | |||
| 12031 | { | |||
| 12032 | CtkKeyHash *key_hash = g_object_get_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), quark_ctk_window_key_hash); | |||
| 12033 | if (key_hash) | |||
| 12034 | { | |||
| 12035 | _ctk_key_hash_free (key_hash); | |||
| 12036 | g_object_set_qdata (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), quark_ctk_window_key_hash, NULL((void*)0)); | |||
| 12037 | } | |||
| 12038 | } | |||
| 12039 | ||||
| 12040 | /** | |||
| 12041 | * ctk_window_activate_key: | |||
| 12042 | * @window: a #CtkWindow | |||
| 12043 | * @event: a #CdkEventKey | |||
| 12044 | * | |||
| 12045 | * Activates mnemonics and accelerators for this #CtkWindow. This is normally | |||
| 12046 | * called by the default ::key_press_event handler for toplevel windows, | |||
| 12047 | * however in some cases it may be useful to call this directly when | |||
| 12048 | * overriding the standard key handling for a toplevel window. | |||
| 12049 | * | |||
| 12050 | * Returns: %TRUE if a mnemonic or accelerator was found and activated. | |||
| 12051 | * | |||
| 12052 | * Since: 2.4 | |||
| 12053 | */ | |||
| 12054 | gboolean | |||
| 12055 | ctk_window_activate_key (CtkWindow *window, | |||
| 12056 | CdkEventKey *event) | |||
| 12057 | { | |||
| 12058 | CtkKeyHash *key_hash; | |||
| 12059 | CtkWindowKeyEntry *found_entry = NULL((void*)0); | |||
| 12060 | gboolean enable_accels; | |||
| 12061 | gboolean enable_mnemonics; | |||
| 12062 | ||||
| 12063 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 12064 | g_return_val_if_fail (event != NULL, FALSE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "event != NULL"); return ((0)); } } while (0); | |||
| 12065 | ||||
| 12066 | /* While an interactive search popup is open for a window of this | |||
| 12067 | * group, no accelerator fires: the search popup owns the keyboard | |||
| 12068 | * (see ctk_window_set_interactive_search_open()). The popup itself | |||
| 12069 | * shares the group, so its own key handling, which ends up here | |||
| 12070 | * through ctk_window_key_press_event(), is covered by this check | |||
| 12071 | * as well. */ | |||
| 12072 | if (window->priv->interactive_search_open) | |||
| 12073 | return FALSE(0); | |||
| 12074 | ||||
| 12075 | if (window->priv->group != NULL((void*)0)) | |||
| 12076 | { | |||
| 12077 | GList *group_windows, *l; | |||
| 12078 | ||||
| 12079 | group_windows = ctk_window_group_list_windows (window->priv->group); | |||
| 12080 | for (l = group_windows; l; l = l->next) | |||
| 12081 | { | |||
| 12082 | if (CTK_WINDOW (l->data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_window_get_type ()))))))->priv->interactive_search_open) | |||
| 12083 | { | |||
| 12084 | g_list_free (group_windows); | |||
| 12085 | return FALSE(0); | |||
| 12086 | } | |||
| 12087 | } | |||
| 12088 | g_list_free (group_windows); | |||
| 12089 | } | |||
| 12090 | ||||
| 12091 | key_hash = ctk_window_get_key_hash (window); | |||
| 12092 | ||||
| 12093 | if (key_hash) | |||
| 12094 | { | |||
| 12095 | GSList *tmp_list; | |||
| 12096 | GSList *entries = _ctk_key_hash_lookup (key_hash, | |||
| 12097 | event->hardware_keycode, | |||
| 12098 | event->state, | |||
| 12099 | ctk_accelerator_get_default_mod_mask (), | |||
| 12100 | event->group); | |||
| 12101 | ||||
| 12102 | g_object_get (ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 12103 | "ctk-enable-mnemonics", &enable_mnemonics, | |||
| 12104 | "ctk-enable-accels", &enable_accels, | |||
| 12105 | NULL((void*)0)); | |||
| 12106 | ||||
| 12107 | for (tmp_list = entries; tmp_list; tmp_list = tmp_list->next) | |||
| 12108 | { | |||
| 12109 | CtkWindowKeyEntry *entry = tmp_list->data; | |||
| 12110 | if (entry->is_mnemonic) | |||
| 12111 | { | |||
| 12112 | if( enable_mnemonics) | |||
| 12113 | { | |||
| 12114 | found_entry = entry; | |||
| 12115 | break; | |||
| 12116 | } | |||
| 12117 | } | |||
| 12118 | else | |||
| 12119 | { | |||
| 12120 | if (enable_accels && !found_entry) | |||
| 12121 | { | |||
| 12122 | found_entry = entry; | |||
| 12123 | } | |||
| 12124 | } | |||
| 12125 | } | |||
| 12126 | ||||
| 12127 | g_slist_free (entries); | |||
| 12128 | } | |||
| 12129 | ||||
| 12130 | if (found_entry) | |||
| 12131 | { | |||
| 12132 | if (found_entry->is_mnemonic) | |||
| 12133 | { | |||
| 12134 | if( enable_mnemonics) | |||
| 12135 | return ctk_window_mnemonic_activate (window, found_entry->keyval, | |||
| 12136 | found_entry->modifiers); | |||
| 12137 | } | |||
| 12138 | else | |||
| 12139 | { | |||
| 12140 | if (enable_accels) | |||
| 12141 | { | |||
| 12142 | if (ctk_accel_groups_activate (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), found_entry->keyval, found_entry->modifiers)) | |||
| 12143 | return TRUE(!(0)); | |||
| 12144 | ||||
| 12145 | if (window->priv->application) | |||
| 12146 | { | |||
| 12147 | CtkWidget *focused_widget; | |||
| 12148 | CtkActionMuxer *muxer; | |||
| 12149 | CtkApplicationAccels *app_accels; | |||
| 12150 | ||||
| 12151 | focused_widget = ctk_window_get_focus (window); | |||
| 12152 | ||||
| 12153 | if (focused_widget) | |||
| 12154 | muxer = _ctk_widget_get_action_muxer (focused_widget, FALSE(0)); | |||
| 12155 | else | |||
| 12156 | muxer = _ctk_widget_get_action_muxer (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), FALSE(0)); | |||
| 12157 | ||||
| 12158 | if (muxer == NULL((void*)0)) | |||
| 12159 | return FALSE(0); | |||
| 12160 | ||||
| 12161 | app_accels = ctk_application_get_application_accels (window->priv->application); | |||
| 12162 | return ctk_application_accels_activate (app_accels, | |||
| 12163 | G_ACTION_GROUP (muxer)((((GActionGroup*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((muxer)), ((g_action_group_get_type ())))))), | |||
| 12164 | found_entry->keyval, found_entry->modifiers); | |||
| 12165 | } | |||
| 12166 | } | |||
| 12167 | } | |||
| 12168 | } | |||
| 12169 | ||||
| 12170 | return _ctk_window_activate_menubar (window, event); | |||
| 12171 | } | |||
| 12172 | ||||
| 12173 | gboolean | |||
| 12174 | _ctk_window_activate_mnemonics (CtkWindow *window, | |||
| 12175 | CdkEventKey *event) | |||
| 12176 | { | |||
| 12177 | CtkKeyHash *key_hash; | |||
| 12178 | CtkWindowKeyEntry *found_entry = NULL((void*)0); | |||
| 12179 | gboolean enable_mnemonics; | |||
| 12180 | ||||
| 12181 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 12182 | g_return_val_if_fail (event != NULL, FALSE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "event != NULL"); return ((0)); } } while (0); | |||
| 12183 | ||||
| 12184 | /* Mnemonic-only mirror of the key hash lookup of | |||
| 12185 | * ctk_window_activate_key(): the entries carry the mnemonic | |||
| 12186 | * modifier (Alt by default), so the lookup only matches with | |||
| 12187 | * the modifier held and plain keys are unaffected. | |||
| 12188 | * Accelerators stay out: they must remain swallowed by the | |||
| 12189 | * search. */ | |||
| 12190 | key_hash = ctk_window_get_key_hash (window); | |||
| 12191 | ||||
| 12192 | if (key_hash) | |||
| 12193 | { | |||
| 12194 | GSList *tmp_list; | |||
| 12195 | GSList *entries = _ctk_key_hash_lookup (key_hash, | |||
| 12196 | event->hardware_keycode, | |||
| 12197 | event->state, | |||
| 12198 | ctk_accelerator_get_default_mod_mask (), | |||
| 12199 | event->group); | |||
| 12200 | ||||
| 12201 | g_object_get (ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), | |||
| 12202 | "ctk-enable-mnemonics", &enable_mnemonics, | |||
| 12203 | NULL((void*)0)); | |||
| 12204 | ||||
| 12205 | for (tmp_list = entries; tmp_list; tmp_list = tmp_list->next) | |||
| 12206 | { | |||
| 12207 | CtkWindowKeyEntry *entry = tmp_list->data; | |||
| 12208 | ||||
| 12209 | if (entry->is_mnemonic && enable_mnemonics) | |||
| 12210 | { | |||
| 12211 | found_entry = entry; | |||
| 12212 | break; | |||
| 12213 | } | |||
| 12214 | } | |||
| 12215 | ||||
| 12216 | g_slist_free (entries); | |||
| 12217 | } | |||
| 12218 | ||||
| 12219 | if (found_entry) | |||
| 12220 | return ctk_window_mnemonic_activate (window, | |||
| 12221 | found_entry->keyval, | |||
| 12222 | found_entry->modifiers); | |||
| 12223 | ||||
| 12224 | return FALSE(0); | |||
| 12225 | } | |||
| 12226 | ||||
| 12227 | static void | |||
| 12228 | window_update_has_focus (CtkWindow *window) | |||
| 12229 | { | |||
| 12230 | CtkWindowPrivate *priv = window->priv; | |||
| 12231 | CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 12232 | gboolean has_focus = priv->has_toplevel_focus && priv->is_active; | |||
| 12233 | ||||
| 12234 | if (has_focus != priv->has_focus) | |||
| 12235 | { | |||
| 12236 | priv->has_focus = has_focus; | |||
| 12237 | ||||
| 12238 | if (has_focus) | |||
| 12239 | { | |||
| 12240 | if (priv->focus_widget && | |||
| 12241 | priv->focus_widget != widget && | |||
| 12242 | !ctk_widget_has_focus (priv->focus_widget)) | |||
| 12243 | do_focus_change (priv->focus_widget, TRUE(!(0))); | |||
| 12244 | } | |||
| 12245 | else | |||
| 12246 | { | |||
| 12247 | if (priv->focus_widget && | |||
| 12248 | priv->focus_widget != widget && | |||
| 12249 | ctk_widget_has_focus (priv->focus_widget)) | |||
| 12250 | do_focus_change (priv->focus_widget, FALSE(0)); | |||
| 12251 | } | |||
| 12252 | } | |||
| 12253 | } | |||
| 12254 | ||||
| 12255 | /** | |||
| 12256 | * _ctk_window_set_is_active: | |||
| 12257 | * @window: a #CtkWindow | |||
| 12258 | * @is_active: %TRUE if the window is in the currently active toplevel | |||
| 12259 | * | |||
| 12260 | * Internal function that sets whether the #CtkWindow is part | |||
| 12261 | * of the currently active toplevel window (taking into account inter-process | |||
| 12262 | * embedding.) | |||
| 12263 | **/ | |||
| 12264 | void | |||
| 12265 | _ctk_window_set_is_active (CtkWindow *window, | |||
| 12266 | gboolean is_active) | |||
| 12267 | { | |||
| 12268 | CtkWindowPrivate *priv; | |||
| 12269 | ||||
| 12270 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12271 | ||||
| 12272 | priv = window->priv; | |||
| 12273 | ||||
| 12274 | is_active = is_active != FALSE(0); | |||
| 12275 | ||||
| 12276 | if (is_active != priv->is_active) | |||
| 12277 | { | |||
| 12278 | priv->is_active = is_active; | |||
| 12279 | window_update_has_focus (window); | |||
| 12280 | ||||
| 12281 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_IS_ACTIVE]); | |||
| 12282 | } | |||
| 12283 | } | |||
| 12284 | ||||
| 12285 | /** | |||
| 12286 | * _ctk_window_set_is_toplevel: | |||
| 12287 | * @window: a #CtkWindow | |||
| 12288 | * @is_toplevel: %TRUE if the window is still a real toplevel (nominally a | |||
| 12289 | * child of the root window); %FALSE if it is not (for example, for an | |||
| 12290 | * in-process, parented CtkPlug) | |||
| 12291 | * | |||
| 12292 | * Internal function used by #CtkPlug when it gets parented/unparented by a | |||
| 12293 | * #CtkSocket. This keeps the @window’s #CTK_WINDOW_TOPLEVEL flag in sync | |||
| 12294 | * with the global list of toplevel windows. | |||
| 12295 | */ | |||
| 12296 | void | |||
| 12297 | _ctk_window_set_is_toplevel (CtkWindow *window, | |||
| 12298 | gboolean is_toplevel) | |||
| 12299 | { | |||
| 12300 | CtkWidget *widget; | |||
| 12301 | CtkWidget *toplevel; | |||
| 12302 | ||||
| 12303 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); | |||
| 12304 | ||||
| 12305 | if (_ctk_widget_is_toplevel (widget)) | |||
| 12306 | g_assert (g_slist_find (toplevel_list, window) != NULL)do { if (g_slist_find (toplevel_list, window) != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c", 12306, ( (const char*) (__func__)), "g_slist_find (toplevel_list, window) != NULL" ); } while (0); | |||
| 12307 | else | |||
| 12308 | g_assert (g_slist_find (toplevel_list, window) == NULL)do { if (g_slist_find (toplevel_list, window) == ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkwindow.c", 12308, ( (const char*) (__func__)), "g_slist_find (toplevel_list, window) == NULL" ); } while (0); | |||
| 12309 | ||||
| 12310 | if (is_toplevel == _ctk_widget_is_toplevel (widget)) | |||
| 12311 | return; | |||
| 12312 | ||||
| 12313 | if (is_toplevel) | |||
| 12314 | { | |||
| 12315 | /* Pass through regular pathways of an embedded toplevel | |||
| 12316 | * to go through unmapping and hiding the widget before | |||
| 12317 | * becomming a toplevel again. | |||
| 12318 | * | |||
| 12319 | * We remain hidden after becomming toplevel in order to | |||
| 12320 | * avoid problems during an embedded toplevel's dispose cycle | |||
| 12321 | * (When a toplevel window is shown it tries to grab focus again, | |||
| 12322 | * this causes problems while disposing). | |||
| 12323 | */ | |||
| 12324 | ctk_widget_hide (widget); | |||
| 12325 | ||||
| 12326 | /* Save the toplevel this widget was previously anchored into before | |||
| 12327 | * propagating a hierarchy-changed. | |||
| 12328 | * | |||
| 12329 | * Usually this happens by way of ctk_widget_unparent() and we are | |||
| 12330 | * already unanchored at this point, just adding this clause incase | |||
| 12331 | * things happen differently. | |||
| 12332 | */ | |||
| 12333 | toplevel = _ctk_widget_get_toplevel (widget); | |||
| 12334 | if (!_ctk_widget_is_toplevel (toplevel)) | |||
| 12335 | toplevel = NULL((void*)0); | |||
| 12336 | ||||
| 12337 | _ctk_widget_set_is_toplevel (widget, TRUE(!(0))); | |||
| 12338 | ||||
| 12339 | /* When a window becomes toplevel after being embedded and anchored | |||
| 12340 | * into another window we need to unset its anchored flag so that | |||
| 12341 | * the hierarchy changed signal kicks in properly. | |||
| 12342 | */ | |||
| 12343 | _ctk_widget_set_anchored (widget, FALSE(0)); | |||
| 12344 | _ctk_widget_propagate_hierarchy_changed (widget, toplevel); | |||
| 12345 | ||||
| 12346 | toplevel_list = g_slist_prepend (toplevel_list, window); | |||
| 12347 | } | |||
| 12348 | else | |||
| 12349 | { | |||
| 12350 | _ctk_widget_set_is_toplevel (widget, FALSE(0)); | |||
| 12351 | toplevel_list = g_slist_remove (toplevel_list, window); | |||
| 12352 | _ctk_widget_propagate_hierarchy_changed (widget, widget); | |||
| 12353 | } | |||
| 12354 | ctk_window_update_debugging (); | |||
| 12355 | } | |||
| 12356 | ||||
| 12357 | /** | |||
| 12358 | * _ctk_window_set_has_toplevel_focus: | |||
| 12359 | * @window: a #CtkWindow | |||
| 12360 | * @has_toplevel_focus: %TRUE if the in | |||
| 12361 | * | |||
| 12362 | * Internal function that sets whether the keyboard focus for the | |||
| 12363 | * toplevel window (taking into account inter-process embedding.) | |||
| 12364 | **/ | |||
| 12365 | void | |||
| 12366 | _ctk_window_set_has_toplevel_focus (CtkWindow *window, | |||
| 12367 | gboolean has_toplevel_focus) | |||
| 12368 | { | |||
| 12369 | CtkWindowPrivate *priv; | |||
| 12370 | ||||
| 12371 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12372 | ||||
| 12373 | priv = window->priv; | |||
| 12374 | ||||
| 12375 | has_toplevel_focus = has_toplevel_focus != FALSE(0); | |||
| 12376 | ||||
| 12377 | if (has_toplevel_focus != priv->has_toplevel_focus) | |||
| 12378 | { | |||
| 12379 | priv->has_toplevel_focus = has_toplevel_focus; | |||
| 12380 | window_update_has_focus (window); | |||
| 12381 | ||||
| 12382 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_HAS_TOPLEVEL_FOCUS]); | |||
| 12383 | } | |||
| 12384 | } | |||
| 12385 | ||||
| 12386 | /** | |||
| 12387 | * ctk_window_set_auto_startup_notification: | |||
| 12388 | * @setting: %TRUE to automatically do startup notification | |||
| 12389 | * | |||
| 12390 | * By default, after showing the first #CtkWindow, CTK+ calls | |||
| 12391 | * cdk_notify_startup_complete(). Call this function to disable | |||
| 12392 | * the automatic startup notification. You might do this if your | |||
| 12393 | * first window is a splash screen, and you want to delay notification | |||
| 12394 | * until after your real main window has been shown, for example. | |||
| 12395 | * | |||
| 12396 | * In that example, you would disable startup notification | |||
| 12397 | * temporarily, show your splash screen, then re-enable it so that | |||
| 12398 | * showing the main window would automatically result in notification. | |||
| 12399 | * | |||
| 12400 | * Since: 2.2 | |||
| 12401 | **/ | |||
| 12402 | void | |||
| 12403 | ctk_window_set_auto_startup_notification (gboolean setting) | |||
| 12404 | { | |||
| 12405 | disable_startup_notification = !setting; | |||
| 12406 | } | |||
| 12407 | ||||
| 12408 | /** | |||
| 12409 | * ctk_window_get_window_type: | |||
| 12410 | * @window: a #CtkWindow | |||
| 12411 | * | |||
| 12412 | * Gets the type of the window. See #CtkWindowType. | |||
| 12413 | * | |||
| 12414 | * Returns: the type of the window | |||
| 12415 | * | |||
| 12416 | * Since: 2.20 | |||
| 12417 | **/ | |||
| 12418 | CtkWindowType | |||
| 12419 | ctk_window_get_window_type (CtkWindow *window) | |||
| 12420 | { | |||
| 12421 | g_return_val_if_fail (CTK_IS_WINDOW (window), CTK_WINDOW_TOPLEVEL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (CTK_WINDOW_TOPLEVEL); } } while (0); | |||
| 12422 | ||||
| 12423 | return window->priv->type; | |||
| 12424 | } | |||
| 12425 | ||||
| 12426 | /** | |||
| 12427 | * ctk_window_get_mnemonics_visible: | |||
| 12428 | * @window: a #CtkWindow | |||
| 12429 | * | |||
| 12430 | * Gets the value of the #CtkWindow:mnemonics-visible property. | |||
| 12431 | * | |||
| 12432 | * Returns: %TRUE if mnemonics are supposed to be visible | |||
| 12433 | * in this window. | |||
| 12434 | * | |||
| 12435 | * Since: 2.20 | |||
| 12436 | */ | |||
| 12437 | gboolean | |||
| 12438 | ctk_window_get_mnemonics_visible (CtkWindow *window) | |||
| 12439 | { | |||
| 12440 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 12441 | ||||
| 12442 | return window->priv->mnemonics_visible; | |||
| 12443 | } | |||
| 12444 | ||||
| 12445 | /** | |||
| 12446 | * ctk_window_set_mnemonics_visible: | |||
| 12447 | * @window: a #CtkWindow | |||
| 12448 | * @setting: the new value | |||
| 12449 | * | |||
| 12450 | * Sets the #CtkWindow:mnemonics-visible property. | |||
| 12451 | * | |||
| 12452 | * Since: 2.20 | |||
| 12453 | */ | |||
| 12454 | void | |||
| 12455 | ctk_window_set_mnemonics_visible (CtkWindow *window, | |||
| 12456 | gboolean setting) | |||
| 12457 | { | |||
| 12458 | CtkWindowPrivate *priv; | |||
| 12459 | ||||
| 12460 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12461 | ||||
| 12462 | priv = window->priv; | |||
| 12463 | ||||
| 12464 | setting = setting != FALSE(0); | |||
| 12465 | ||||
| 12466 | if (priv->mnemonics_visible != setting) | |||
| 12467 | { | |||
| 12468 | priv->mnemonics_visible = setting; | |||
| 12469 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_MNEMONICS_VISIBLE]); | |||
| 12470 | } | |||
| 12471 | ||||
| 12472 | if (priv->mnemonics_display_timeout_id) | |||
| 12473 | { | |||
| 12474 | g_source_remove (priv->mnemonics_display_timeout_id); | |||
| 12475 | priv->mnemonics_display_timeout_id = 0; | |||
| 12476 | } | |||
| 12477 | ||||
| 12478 | priv->mnemonics_visible_set = TRUE(!(0)); | |||
| 12479 | } | |||
| 12480 | ||||
| 12481 | static gboolean | |||
| 12482 | schedule_mnemonics_visible_cb (gpointer data) | |||
| 12483 | { | |||
| 12484 | CtkWindow *window = data; | |||
| 12485 | ||||
| 12486 | window->priv->mnemonics_display_timeout_id = 0; | |||
| 12487 | ||||
| 12488 | ctk_window_set_mnemonics_visible (window, TRUE(!(0))); | |||
| 12489 | ||||
| 12490 | return FALSE(0); | |||
| 12491 | } | |||
| 12492 | ||||
| 12493 | void | |||
| 12494 | _ctk_window_schedule_mnemonics_visible (CtkWindow *window) | |||
| 12495 | { | |||
| 12496 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12497 | ||||
| 12498 | if (window->priv->mnemonics_display_timeout_id) | |||
| 12499 | return; | |||
| 12500 | ||||
| 12501 | window->priv->mnemonics_display_timeout_id = | |||
| 12502 | cdk_threads_add_timeout (MNEMONICS_DELAY300, schedule_mnemonics_visible_cb, window); | |||
| 12503 | g_source_set_name_by_id (window->priv->mnemonics_display_timeout_id, "[ctk+] schedule_mnemonics_visible_cb"); | |||
| 12504 | } | |||
| 12505 | ||||
| 12506 | /** | |||
| 12507 | * ctk_window_get_focus_visible: | |||
| 12508 | * @window: a #CtkWindow | |||
| 12509 | * | |||
| 12510 | * Gets the value of the #CtkWindow:focus-visible property. | |||
| 12511 | * | |||
| 12512 | * Returns: %TRUE if “focus rectangles” are supposed to be visible | |||
| 12513 | * in this window. | |||
| 12514 | * | |||
| 12515 | * Since: 3.2 | |||
| 12516 | */ | |||
| 12517 | gboolean | |||
| 12518 | ctk_window_get_focus_visible (CtkWindow *window) | |||
| 12519 | { | |||
| 12520 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 12521 | ||||
| 12522 | return window->priv->focus_visible; | |||
| 12523 | } | |||
| 12524 | ||||
| 12525 | /** | |||
| 12526 | * ctk_window_set_focus_visible: | |||
| 12527 | * @window: a #CtkWindow | |||
| 12528 | * @setting: the new value | |||
| 12529 | * | |||
| 12530 | * Sets the #CtkWindow:focus-visible property. | |||
| 12531 | * | |||
| 12532 | * Since: 3.2 | |||
| 12533 | */ | |||
| 12534 | void | |||
| 12535 | ctk_window_set_focus_visible (CtkWindow *window, | |||
| 12536 | gboolean setting) | |||
| 12537 | { | |||
| 12538 | CtkWindowPrivate *priv; | |||
| 12539 | ||||
| 12540 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12541 | ||||
| 12542 | priv = window->priv; | |||
| 12543 | ||||
| 12544 | setting = setting != FALSE(0); | |||
| 12545 | ||||
| 12546 | if (priv->focus_visible != setting) | |||
| 12547 | { | |||
| 12548 | priv->focus_visible = setting; | |||
| 12549 | g_object_notify_by_pspec (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), window_props[PROP_FOCUS_VISIBLE]); | |||
| 12550 | } | |||
| 12551 | } | |||
| 12552 | ||||
| 12553 | void | |||
| 12554 | _ctk_window_get_wmclass (CtkWindow *window, | |||
| 12555 | gchar **wmclass_name, | |||
| 12556 | gchar **wmclass_class) | |||
| 12557 | { | |||
| 12558 | CtkWindowPrivate *priv = window->priv; | |||
| 12559 | ||||
| 12560 | *wmclass_name = priv->wmclass_name; | |||
| 12561 | *wmclass_class = priv->wmclass_class; | |||
| 12562 | } | |||
| 12563 | ||||
| 12564 | /** | |||
| 12565 | * ctk_window_set_has_user_ref_count: | |||
| 12566 | * @window: a #CtkWindow | |||
| 12567 | * @setting: the new value | |||
| 12568 | * | |||
| 12569 | * Tells CTK+ whether to drop its extra reference to the window | |||
| 12570 | * when ctk_widget_destroy() is called. | |||
| 12571 | * | |||
| 12572 | * This function is only exported for the benefit of language | |||
| 12573 | * bindings which may need to keep the window alive until their | |||
| 12574 | * wrapper object is garbage collected. There is no justification | |||
| 12575 | * for ever calling this function in an application. | |||
| 12576 | * | |||
| 12577 | * Since: 3.0 | |||
| 12578 | */ | |||
| 12579 | void | |||
| 12580 | ctk_window_set_has_user_ref_count (CtkWindow *window, | |||
| 12581 | gboolean setting) | |||
| 12582 | { | |||
| 12583 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12584 | ||||
| 12585 | window->priv->has_user_ref_count = setting; | |||
| 12586 | } | |||
| 12587 | ||||
| 12588 | static void | |||
| 12589 | ensure_state_flag_backdrop (CtkWidget *widget) | |||
| 12590 | { | |||
| 12591 | CdkWindow *window; | |||
| 12592 | gboolean window_focused = TRUE(!(0)); | |||
| 12593 | ||||
| 12594 | window = _ctk_widget_get_window (widget); | |||
| 12595 | ||||
| 12596 | window_focused = cdk_window_get_state (window) & CDK_WINDOW_STATE_FOCUSED; | |||
| 12597 | ||||
| 12598 | if (!window_focused) | |||
| 12599 | ctk_widget_set_state_flags (widget, CTK_STATE_FLAG_BACKDROP, FALSE(0)); | |||
| 12600 | else | |||
| 12601 | ctk_widget_unset_state_flags (widget, CTK_STATE_FLAG_BACKDROP); | |||
| 12602 | } | |||
| 12603 | ||||
| 12604 | void | |||
| 12605 | _ctk_window_get_shadow_width (CtkWindow *window, | |||
| 12606 | CtkBorder *border) | |||
| 12607 | { | |||
| 12608 | get_shadow_width (window, border); | |||
| 12609 | } | |||
| 12610 | ||||
| 12611 | void | |||
| 12612 | _ctk_window_add_popover (CtkWindow *window, | |||
| 12613 | CtkWidget *popover, | |||
| 12614 | CtkWidget *parent, | |||
| 12615 | gboolean clamp_allocation) | |||
| 12616 | { | |||
| 12617 | CtkWindowPrivate *priv; | |||
| 12618 | CtkWindowPopover *data; | |||
| 12619 | AtkObject *accessible; | |||
| 12620 | ||||
| 12621 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12622 | g_return_if_fail (CTK_IS_WIDGET (popover))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((popover)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (popover)" ); return; } } while (0); | |||
| 12623 | g_return_if_fail (CTK_IS_WIDGET (parent))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((parent)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (parent)" ); return; } } while (0); | |||
| 12624 | g_return_if_fail (_ctk_widget_get_parent (popover) == NULL)do { if ((_ctk_widget_get_parent (popover) == ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "_ctk_widget_get_parent (popover) == NULL"); return; } } while (0); | |||
| 12625 | g_return_if_fail (ctk_widget_is_ancestor (parent, CTK_WIDGET (window)))do { if ((ctk_widget_is_ancestor (parent, ((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ( (ctk_widget_get_type ()))))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "ctk_widget_is_ancestor (parent, CTK_WIDGET (window))" ); return; } } while (0); | |||
| 12626 | ||||
| 12627 | priv = window->priv; | |||
| 12628 | ||||
| 12629 | if (_ctk_window_has_popover (window, popover)) | |||
| 12630 | return; | |||
| 12631 | ||||
| 12632 | data = g_new0 (CtkWindowPopover, 1)((CtkWindowPopover *) g_malloc0_n ((1), sizeof (CtkWindowPopover ))); | |||
| 12633 | data->widget = popover; | |||
| 12634 | data->parent = parent; | |||
| 12635 | data->clamp_allocation = !!clamp_allocation; | |||
| 12636 | priv->popovers = g_list_prepend (priv->popovers, data); | |||
| 12637 | ||||
| 12638 | if (_ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 12639 | popover_realize (popover, data, window); | |||
| 12640 | ||||
| 12641 | ctk_widget_set_parent (popover, CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 12642 | ||||
| 12643 | accessible = ctk_widget_get_accessible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 12644 | _ctk_container_accessible_add_child (CTK_CONTAINER_ACCESSIBLE (accessible)((((CtkContainerAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((accessible)), ((ctk_container_accessible_get_type ())))))), | |||
| 12645 | ctk_widget_get_accessible (popover), -1); | |||
| 12646 | } | |||
| 12647 | ||||
| 12648 | void | |||
| 12649 | _ctk_window_remove_popover (CtkWindow *window, | |||
| 12650 | CtkWidget *popover) | |||
| 12651 | { | |||
| 12652 | CtkWindowPrivate *priv; | |||
| 12653 | CtkWindowPopover *data; | |||
| 12654 | AtkObject *accessible; | |||
| 12655 | ||||
| 12656 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12657 | g_return_if_fail (CTK_IS_WIDGET (popover))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((popover)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (popover)" ); return; } } while (0); | |||
| 12658 | ||||
| 12659 | priv = window->priv; | |||
| 12660 | ||||
| 12661 | data = _ctk_window_has_popover (window, popover); | |||
| 12662 | ||||
| 12663 | if (!data) | |||
| 12664 | return; | |||
| 12665 | ||||
| 12666 | g_object_ref (popover)((__typeof__ (popover)) (g_object_ref) (popover)); | |||
| 12667 | ctk_widget_unparent (popover); | |||
| 12668 | ||||
| 12669 | popover_unmap (popover, data); | |||
| 12670 | ||||
| 12671 | if (_ctk_widget_get_realized (CTK_WIDGET (popover)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((popover)), ((ctk_widget_get_type ())))))))) | |||
| 12672 | popover_unrealize (popover, data, window); | |||
| 12673 | ||||
| 12674 | priv->popovers = g_list_remove (priv->popovers, data); | |||
| 12675 | ||||
| 12676 | accessible = ctk_widget_get_accessible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 12677 | _ctk_container_accessible_remove_child (CTK_CONTAINER_ACCESSIBLE (accessible)((((CtkContainerAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((accessible)), ((ctk_container_accessible_get_type ())))))), | |||
| 12678 | ctk_widget_get_accessible (popover), -1); | |||
| 12679 | popover_destroy (data); | |||
| 12680 | g_object_unref (popover); | |||
| 12681 | } | |||
| 12682 | ||||
| 12683 | void | |||
| 12684 | _ctk_window_set_popover_position (CtkWindow *window, | |||
| 12685 | CtkWidget *popover, | |||
| 12686 | CtkPositionType pos, | |||
| 12687 | const cairo_rectangle_int_t *rect) | |||
| 12688 | { | |||
| 12689 | gboolean need_resize; | |||
| 12690 | gboolean need_move; | |||
| 12691 | CtkWindowPopover *data; | |||
| 12692 | ||||
| 12693 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| ||||
| 12694 | g_return_if_fail (CTK_IS_WIDGET (popover))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((popover)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (popover)" ); return; } } while (0); | |||
| 12695 | ||||
| 12696 | data = _ctk_window_has_popover (window, popover); | |||
| 12697 | ||||
| 12698 | if (!data) | |||
| 12699 | { | |||
| 12700 | g_warning ("Widget %s(%p) is not a popover of window %s(%p)", | |||
| 12701 | ctk_widget_get_name (popover), popover, | |||
| 12702 | ctk_widget_get_name (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), window); | |||
| 12703 | return; | |||
| 12704 | } | |||
| 12705 | ||||
| 12706 | ||||
| 12707 | /* Don't queue a resize if the position as well as the size are the same */ | |||
| 12708 | need_move = data->pos != pos || | |||
| 12709 | data->rect.x != rect->x || | |||
| 12710 | data->rect.y != rect->y; | |||
| 12711 | ||||
| 12712 | need_resize = data->pos != pos
| |||
| 12713 | data->rect.width != rect->width || | |||
| 12714 | data->rect.height != rect->height; | |||
| 12715 | ||||
| 12716 | data->rect = *rect; | |||
| 12717 | data->pos = pos; | |||
| 12718 | ||||
| 12719 | if (ctk_widget_is_visible (popover) && !data->window && | |||
| 12720 | ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
| 12721 | { | |||
| 12722 | popover_realize (popover, data, window); | |||
| 12723 | popover_map (popover, data); | |||
| 12724 | } | |||
| 12725 | ||||
| 12726 | if (need_resize) | |||
| 12727 | { | |||
| 12728 | ctk_widget_queue_resize (popover); | |||
| 12729 | } | |||
| 12730 | else if (need_move) | |||
| 12731 | { | |||
| 12732 | cairo_rectangle_int_t new_size; | |||
| 12733 | popover_get_rect (data, window, &new_size); | |||
| 12734 | cdk_window_move (data->window, new_size.x, new_size.y); | |||
| 12735 | } | |||
| 12736 | } | |||
| 12737 | ||||
| 12738 | void | |||
| 12739 | _ctk_window_get_popover_position (CtkWindow *window, | |||
| 12740 | CtkWidget *popover, | |||
| 12741 | CtkPositionType *pos, | |||
| 12742 | cairo_rectangle_int_t *rect) | |||
| 12743 | { | |||
| 12744 | CtkWindowPopover *data; | |||
| 12745 | ||||
| 12746 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 12747 | g_return_if_fail (CTK_IS_WIDGET (popover))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((popover)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (popover)" ); return; } } while (0); | |||
| 12748 | ||||
| 12749 | data = _ctk_window_has_popover (window, popover); | |||
| 12750 | ||||
| 12751 | if (!data) | |||
| 12752 | { | |||
| 12753 | g_warning ("Widget %s(%p) is not a popover of window %s(%p)", | |||
| 12754 | ctk_widget_get_name (popover), popover, | |||
| 12755 | ctk_widget_get_name (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), window); | |||
| 12756 | return; | |||
| 12757 | } | |||
| 12758 | ||||
| 12759 | if (pos) | |||
| 12760 | *pos = data->pos; | |||
| 12761 | ||||
| 12762 | if (rect) | |||
| 12763 | *rect = data->rect; | |||
| 12764 | } | |||
| 12765 | ||||
| 12766 | /*<private> | |||
| 12767 | * _ctk_window_get_popover_parent: | |||
| 12768 | * @window: A #CtkWindow | |||
| 12769 | * @popover: A popover #CtkWidget | |||
| 12770 | * | |||
| 12771 | * Returns the conceptual parent of this popover, the real | |||
| 12772 | * parent will always be @window. | |||
| 12773 | * | |||
| 12774 | * Returns: (nullable): The conceptual parent widget, or %NULL. | |||
| 12775 | **/ | |||
| 12776 | CtkWidget * | |||
| 12777 | _ctk_window_get_popover_parent (CtkWindow *window, | |||
| 12778 | CtkWidget *popover) | |||
| 12779 | { | |||
| 12780 | CtkWindowPopover *data; | |||
| 12781 | ||||
| 12782 | g_return_val_if_fail (CTK_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return (((void*)0)); } } while (0); | |||
| 12783 | g_return_val_if_fail (CTK_IS_WIDGET (popover), NULL)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((popover)); 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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WIDGET (popover)" ); return (((void*)0)); } } while (0); | |||
| 12784 | ||||
| 12785 | data = _ctk_window_has_popover (window, popover); | |||
| 12786 | ||||
| 12787 | if (data && data->parent) | |||
| 12788 | return data->parent; | |||
| 12789 | ||||
| 12790 | return NULL((void*)0); | |||
| 12791 | } | |||
| 12792 | ||||
| 12793 | /*<private> | |||
| 12794 | * _ctk_window_is_popover_widget: | |||
| 12795 | * @window: A #CtkWindow | |||
| 12796 | * @possible_popover: A possible popover of @window | |||
| 12797 | * | |||
| 12798 | * Returns #TRUE if @possible_popover is a popover of @window. | |||
| 12799 | * | |||
| 12800 | * Returns: Whether the widget is a popover of @window | |||
| 12801 | **/ | |||
| 12802 | gboolean | |||
| 12803 | _ctk_window_is_popover_widget (CtkWindow *window, | |||
| 12804 | CtkWidget *possible_popover) | |||
| 12805 | { | |||
| 12806 | g_return_val_if_fail (CTK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return ((0)); } } while (0); | |||
| 12807 | g_return_val_if_fail (CTK_IS_WIDGET (possible_popover), FALSE)do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((possible_popover)); 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 ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (possible_popover)"); return ((0)); } } while (0); | |||
| 12808 | ||||
| 12809 | return _ctk_window_has_popover (window, possible_popover) != NULL((void*)0); | |||
| 12810 | } | |||
| 12811 | ||||
| 12812 | void | |||
| 12813 | _ctk_window_raise_popover (CtkWindow *window, | |||
| 12814 | CtkWidget *widget) | |||
| 12815 | { | |||
| 12816 | CtkWindowPrivate *priv = window->priv; | |||
| 12817 | GList *link; | |||
| 12818 | ||||
| 12819 | for (link = priv->popovers; link; link = link->next) | |||
| 12820 | { | |||
| 12821 | CtkWindowPopover *popover = link->data; | |||
| 12822 | ||||
| 12823 | if (popover->widget != widget) | |||
| 12824 | continue; | |||
| 12825 | ||||
| 12826 | priv->popovers = g_list_remove_link (priv->popovers, link); | |||
| 12827 | priv->popovers = g_list_append (priv->popovers, link->data); | |||
| 12828 | g_list_free (link); | |||
| 12829 | break; | |||
| 12830 | } | |||
| 12831 | ctk_window_restack_popovers (window); | |||
| 12832 | } | |||
| 12833 | ||||
| 12834 | static CtkWidget *inspector_window = NULL((void*)0); | |||
| 12835 | ||||
| 12836 | static guint ctk_window_update_debugging_id; | |||
| 12837 | ||||
| 12838 | static void set_warn_again (gboolean warn); | |||
| 12839 | ||||
| 12840 | static void | |||
| 12841 | warn_response (CtkDialog *dialog, | |||
| 12842 | gint response) | |||
| 12843 | { | |||
| 12844 | CtkWidget *check; | |||
| 12845 | gboolean remember; | |||
| 12846 | ||||
| 12847 | check = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "check"); | |||
| 12848 | remember = ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((check)), ((ctk_toggle_button_get_type ()))))))); | |||
| 12849 | ||||
| 12850 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
| 12851 | g_object_set_data (G_OBJECT (inspector_window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((inspector_window)), (((GType) ((20) << (2)))))))), "warning_dialog", NULL((void*)0)); | |||
| 12852 | if (response == CTK_RESPONSE_NO) | |||
| 12853 | { | |||
| 12854 | CtkWidget *window; | |||
| 12855 | ||||
| 12856 | if (ctk_window_update_debugging_id) | |||
| 12857 | { | |||
| 12858 | g_source_remove (ctk_window_update_debugging_id); | |||
| 12859 | ctk_window_update_debugging_id = 0; | |||
| 12860 | } | |||
| 12861 | ||||
| 12862 | /* Steal reference into temp variable, so not to mess up with | |||
| 12863 | * inspector_window during ctk_widget_destroy(). | |||
| 12864 | */ | |||
| 12865 | window = inspector_window; | |||
| 12866 | inspector_window = NULL((void*)0); | |||
| 12867 | ctk_widget_destroy (window); | |||
| 12868 | } | |||
| 12869 | else | |||
| 12870 | { | |||
| 12871 | set_warn_again (!remember); | |||
| 12872 | } | |||
| 12873 | } | |||
| 12874 | ||||
| 12875 | static gboolean | |||
| 12876 | update_debugging (gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
| 12877 | { | |||
| 12878 | ctk_inspector_window_rescan (inspector_window); | |||
| 12879 | ctk_window_update_debugging_id = 0; | |||
| 12880 | return G_SOURCE_REMOVE(0); | |||
| 12881 | } | |||
| 12882 | ||||
| 12883 | static void | |||
| 12884 | ctk_window_update_debugging (void) | |||
| 12885 | { | |||
| 12886 | if (inspector_window && | |||
| 12887 | ctk_window_update_debugging_id == 0) | |||
| 12888 | { | |||
| 12889 | ctk_window_update_debugging_id = cdk_threads_add_idle (update_debugging, NULL((void*)0)); | |||
| 12890 | g_source_set_name_by_id (ctk_window_update_debugging_id, "[ctk+] ctk_window_update_debugging"); | |||
| 12891 | } | |||
| 12892 | } | |||
| 12893 | ||||
| 12894 | static void | |||
| 12895 | ctk_window_set_debugging (gboolean enable, | |||
| 12896 | gboolean select, | |||
| 12897 | gboolean warn) | |||
| 12898 | { | |||
| 12899 | CtkWidget *dialog = NULL((void*)0); | |||
| 12900 | CtkWidget *area; | |||
| 12901 | CtkWidget *check; | |||
| 12902 | ||||
| 12903 | if (inspector_window == NULL((void*)0)) | |||
| 12904 | { | |||
| 12905 | ctk_inspector_init (); | |||
| 12906 | inspector_window = ctk_inspector_window_new (); | |||
| 12907 | g_signal_connect (inspector_window, "delete-event",g_signal_connect_data ((inspector_window), ("delete-event"), ( ((GCallback) (ctk_widget_hide_on_delete))), (((void*)0)), ((void *)0), (GConnectFlags) 0) | |||
| 12908 | G_CALLBACK (ctk_widget_hide_on_delete), NULL)g_signal_connect_data ((inspector_window), ("delete-event"), ( ((GCallback) (ctk_widget_hide_on_delete))), (((void*)0)), ((void *)0), (GConnectFlags) 0); | |||
| 12909 | ||||
| 12910 | if (warn) | |||
| 12911 | { | |||
| 12912 | dialog = ctk_message_dialog_new (CTK_WINDOW (inspector_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((inspector_window)), ((ctk_window_get_type ())))))), | |||
| 12913 | CTK_DIALOG_MODAL|CTK_DIALOG_DESTROY_WITH_PARENT, | |||
| 12914 | CTK_MESSAGE_QUESTION, | |||
| 12915 | CTK_BUTTONS_NONE, | |||
| 12916 | _("Do you want to use CTK+ Inspector?")((char *) g_dgettext ("ctk30", "Do you want to use CTK+ Inspector?" ))); | |||
| 12917 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) ))))), | |||
| 12918 | _("CTK+ Inspector is an interactive debugger that lets you explore and "((char *) g_dgettext ("ctk30", "CTK+ Inspector is an interactive debugger that lets you explore and " "modify the internals of any CTK+ application. Using it may cause the " "application to break or crash.")) | |||
| 12919 | "modify the internals of any CTK+ application. Using it may cause the "((char *) g_dgettext ("ctk30", "CTK+ Inspector is an interactive debugger that lets you explore and " "modify the internals of any CTK+ application. Using it may cause the " "application to break or crash.")) | |||
| 12920 | "application to break or crash.")((char *) g_dgettext ("ctk30", "CTK+ Inspector is an interactive debugger that lets you explore and " "modify the internals of any CTK+ application. Using it may cause the " "application to break or crash."))); | |||
| 12921 | ||||
| 12922 | area = ctk_message_dialog_get_message_area (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) )))))); | |||
| 12923 | check = ctk_check_button_new_with_label (_("Don't show this message again")((char *) g_dgettext ("ctk30", "Don't show this message again" ))); | |||
| 12924 | ctk_widget_set_margin_start (check, 10); | |||
| 12925 | ctk_widget_show (check); | |||
| 12926 | ctk_container_add (CTK_CONTAINER (area)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_container_get_type ())))))), check); | |||
| 12927 | g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "check", check); | |||
| 12928 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), _("_Cancel")((char *) g_dgettext ("ctk30", "_Cancel")), CTK_RESPONSE_NO); | |||
| 12929 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), _("_OK")((char *) g_dgettext ("ctk30", "_OK")), CTK_RESPONSE_YES); | |||
| 12930 | g_signal_connect (dialog, "response", G_CALLBACK (warn_response), NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) ( warn_response))), (((void*)0)), ((void*)0), (GConnectFlags) 0 ); | |||
| 12931 | g_object_set_data (G_OBJECT (inspector_window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((inspector_window)), (((GType) ((20) << (2)))))))), "warning_dialog", dialog); | |||
| 12932 | } | |||
| 12933 | } | |||
| 12934 | ||||
| 12935 | dialog = g_object_get_data (G_OBJECT (inspector_window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((inspector_window)), (((GType) ((20) << (2)))))))), "warning_dialog"); | |||
| 12936 | ||||
| 12937 | if (enable) | |||
| 12938 | { | |||
| 12939 | ctk_window_present (CTK_WINDOW (inspector_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((inspector_window)), ((ctk_window_get_type ()))))))); | |||
| 12940 | ||||
| 12941 | if (dialog) | |||
| 12942 | ctk_widget_show (dialog); | |||
| 12943 | ||||
| 12944 | if (select) | |||
| 12945 | ctk_inspector_window_select_widget_under_pointer (CTK_INSPECTOR_WINDOW (inspector_window)((((CtkInspectorWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((inspector_window)), ((ctk_inspector_window_get_type ()))))))); | |||
| 12946 | } | |||
| 12947 | else | |||
| 12948 | { | |||
| 12949 | if (dialog) | |||
| 12950 | ctk_widget_hide (dialog); | |||
| 12951 | ctk_widget_hide (inspector_window); | |||
| 12952 | } | |||
| 12953 | } | |||
| 12954 | ||||
| 12955 | /** | |||
| 12956 | * ctk_window_set_interactive_debugging: | |||
| 12957 | * @enable: %TRUE to enable interactive debugging | |||
| 12958 | * | |||
| 12959 | * Opens or closes the [interactive debugger][interactive-debugging], | |||
| 12960 | * which offers access to the widget hierarchy of the application | |||
| 12961 | * and to useful debugging tools. | |||
| 12962 | * | |||
| 12963 | * Since: 3.14 | |||
| 12964 | */ | |||
| 12965 | void | |||
| 12966 | ctk_window_set_interactive_debugging (gboolean enable) | |||
| 12967 | { | |||
| 12968 | ctk_window_set_debugging (enable, FALSE(0), FALSE(0)); | |||
| 12969 | } | |||
| 12970 | ||||
| 12971 | static gboolean | |||
| 12972 | inspector_keybinding_enabled (gboolean *warn) | |||
| 12973 | { | |||
| 12974 | GSettingsSchema *schema; | |||
| 12975 | GSettings *settings; | |||
| 12976 | gboolean enabled; | |||
| 12977 | ||||
| 12978 | enabled = FALSE(0); | |||
| 12979 | *warn = FALSE(0); | |||
| 12980 | ||||
| 12981 | schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), | |||
| 12982 | "org.ctk.Settings.Debug", | |||
| 12983 | TRUE(!(0))); | |||
| 12984 | ||||
| 12985 | if (schema) | |||
| 12986 | { | |||
| 12987 | settings = g_settings_new_full (schema, NULL((void*)0), NULL((void*)0)); | |||
| 12988 | enabled = g_settings_get_boolean (settings, "enable-inspector-keybinding"); | |||
| 12989 | *warn = g_settings_get_boolean (settings, "inspector-warning"); | |||
| 12990 | g_object_unref (settings); | |||
| 12991 | g_settings_schema_unref (schema); | |||
| 12992 | } | |||
| 12993 | ||||
| 12994 | return enabled; | |||
| 12995 | } | |||
| 12996 | ||||
| 12997 | static void | |||
| 12998 | set_warn_again (gboolean warn) | |||
| 12999 | { | |||
| 13000 | GSettingsSchema *schema; | |||
| 13001 | GSettings *settings; | |||
| 13002 | ||||
| 13003 | schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), | |||
| 13004 | "org.ctk.Settings.Debug", | |||
| 13005 | TRUE(!(0))); | |||
| 13006 | ||||
| 13007 | if (schema) | |||
| 13008 | { | |||
| 13009 | settings = g_settings_new_full (schema, NULL((void*)0), NULL((void*)0)); | |||
| 13010 | g_settings_set_boolean (settings, "inspector-warning", warn); | |||
| 13011 | g_object_unref (settings); | |||
| 13012 | g_settings_schema_unref (schema); | |||
| 13013 | } | |||
| 13014 | } | |||
| 13015 | ||||
| 13016 | static gboolean | |||
| 13017 | ctk_window_enable_debugging (CtkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 13018 | gboolean toggle) | |||
| 13019 | { | |||
| 13020 | gboolean warn; | |||
| 13021 | ||||
| 13022 | if (!inspector_keybinding_enabled (&warn)) | |||
| 13023 | return FALSE(0); | |||
| 13024 | ||||
| 13025 | if (toggle) | |||
| 13026 | { | |||
| 13027 | if (CTK_IS_WIDGET (inspector_window)(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (inspector_window)); 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; })))) && | |||
| 13028 | ctk_widget_is_visible (inspector_window)) | |||
| 13029 | ctk_window_set_debugging (FALSE(0), FALSE(0), FALSE(0)); | |||
| 13030 | else | |||
| 13031 | ctk_window_set_debugging (TRUE(!(0)), FALSE(0), warn); | |||
| 13032 | } | |||
| 13033 | else | |||
| 13034 | ctk_window_set_debugging (TRUE(!(0)), TRUE(!(0)), warn); | |||
| 13035 | ||||
| 13036 | return TRUE(!(0)); | |||
| 13037 | } | |||
| 13038 | ||||
| 13039 | void | |||
| 13040 | ctk_window_set_use_subsurface (CtkWindow *window, | |||
| 13041 | gboolean use_subsurface) | |||
| 13042 | { | |||
| 13043 | CtkWindowPrivate *priv = window->priv; | |||
| 13044 | ||||
| 13045 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 13046 | g_return_if_fail (!_ctk_widget_get_realized (CTK_WIDGET (window)))do { if ((!_ctk_widget_get_realized (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ()))))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!_ctk_widget_get_realized (CTK_WIDGET (window))" ); return; } } while (0); | |||
| 13047 | ||||
| 13048 | priv->use_subsurface = use_subsurface; | |||
| 13049 | } | |||
| 13050 | ||||
| 13051 | void | |||
| 13052 | ctk_window_set_hardcoded_window (CtkWindow *window, | |||
| 13053 | CdkWindow *cdk_window) | |||
| 13054 | { | |||
| 13055 | CtkWindowPrivate *priv = window->priv; | |||
| 13056 | ||||
| 13057 | g_return_if_fail (CTK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *_inst = (GTypeInstance *) ((window)); GType _t = ((ctk_window_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 ("Ctk", ((const char*) (__func__)), "CTK_IS_WINDOW (window)" ); return; } } while (0); | |||
| 13058 | g_return_if_fail (!_ctk_widget_get_realized (CTK_WIDGET (window)))do { if ((!_ctk_widget_get_realized (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ()))))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!_ctk_widget_get_realized (CTK_WIDGET (window))" ); return; } } while (0); | |||
| 13059 | ||||
| 13060 | g_set_object (&priv->hardcoded_window, cdk_window)(__extension__ ({ _Static_assert (sizeof *(&priv->hardcoded_window ) == sizeof (cdk_window), "Expression evaluates to false"); union { char *in; GObject **out; } _object_ptr; _object_ptr.in = ( char *) (&priv->hardcoded_window); (void) (0 ? *(& priv->hardcoded_window) = (cdk_window), (0) : (0)); (g_set_object ) (_object_ptr.out, (GObject *) cdk_window); })); | |||
| 13061 | } | |||
| 13062 | ||||
| 13063 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 13064 | typedef struct { | |||
| 13065 | CtkWindow *window; | |||
| 13066 | CtkWindowHandleExported callback; | |||
| 13067 | gpointer user_data; | |||
| 13068 | } WaylandWindowHandleExportedData; | |||
| 13069 | ||||
| 13070 | static void | |||
| 13071 | wayland_window_handle_exported (CdkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 13072 | const char *wayland_handle_str, | |||
| 13073 | gpointer user_data) | |||
| 13074 | { | |||
| 13075 | WaylandWindowHandleExportedData *data = user_data; | |||
| 13076 | char *handle_str; | |||
| 13077 | ||||
| 13078 | handle_str = g_strdup_printf ("wayland:%s", wayland_handle_str); | |||
| 13079 | data->callback (data->window, handle_str, data->user_data); | |||
| 13080 | g_free (handle_str)(__builtin_object_size ((handle_str), 0) != ((size_t) - 1)) ? g_free_sized (handle_str, __builtin_object_size ((handle_str ), 0)) : (g_free) (handle_str); | |||
| 13081 | } | |||
| 13082 | #endif | |||
| 13083 | ||||
| 13084 | gboolean | |||
| 13085 | ctk_window_export_handle (CtkWindow *window, | |||
| 13086 | CtkWindowHandleExported callback, | |||
| 13087 | gpointer user_data) | |||
| 13088 | { | |||
| 13089 | ||||
| 13090 | #ifdef CDK_WINDOWING_X11 | |||
| 13091 | if (CDK_IS_X11_DISPLAY (ctk_widget_get_display (CTK_WIDGET (window)))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ())))))) ))); GType _t = ((cdk_x11_display_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; }))))) | |||
| 13092 | { | |||
| 13093 | CdkWindow *cdk_window = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 13094 | char *handle_str; | |||
| 13095 | guint32 xid = (guint32) cdk_x11_window_get_xid (cdk_window); | |||
| 13096 | ||||
| 13097 | handle_str = g_strdup_printf ("x11:%x", xid); | |||
| 13098 | callback (window, handle_str, user_data); | |||
| 13099 | ||||
| 13100 | return TRUE(!(0)); | |||
| 13101 | } | |||
| 13102 | #endif | |||
| 13103 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 13104 | if (CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (CTK_WIDGET (window)))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ())))))) ))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 13105 | { | |||
| 13106 | CdkWindow *cdk_window = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 13107 | WaylandWindowHandleExportedData *data; | |||
| 13108 | ||||
| 13109 | data = g_new0 (WaylandWindowHandleExportedData, 1)((WaylandWindowHandleExportedData *) g_malloc0_n ((1), sizeof (WaylandWindowHandleExportedData))); | |||
| 13110 | data->window = window; | |||
| 13111 | data->callback = callback; | |||
| 13112 | data->user_data = user_data; | |||
| 13113 | ||||
| 13114 | if (!cdk_wayland_window_export_handle (cdk_window, | |||
| 13115 | wayland_window_handle_exported, | |||
| 13116 | data, | |||
| 13117 | g_free)) | |||
| 13118 | { | |||
| 13119 | g_free (data)(__builtin_object_size ((data), 0) != ((size_t) - 1)) ? g_free_sized (data, __builtin_object_size ((data), 0)) : (g_free) (data); | |||
| 13120 | return FALSE(0); | |||
| 13121 | } | |||
| 13122 | else | |||
| 13123 | { | |||
| 13124 | return TRUE(!(0)); | |||
| 13125 | } | |||
| 13126 | } | |||
| 13127 | #endif | |||
| 13128 | ||||
| 13129 | g_warning ("Couldn't export handle, unsupported windowing system"); | |||
| 13130 | ||||
| 13131 | return FALSE(0); | |||
| 13132 | } | |||
| 13133 | ||||
| 13134 | void | |||
| 13135 | ctk_window_unexport_handle (CtkWindow *window) | |||
| 13136 | { | |||
| 13137 | #ifdef CDK_WINDOWING_WAYLAND | |||
| 13138 | if (CDK_IS_WAYLAND_DISPLAY (ctk_widget_get_display (CTK_WIDGET (window)))(((__extension__ ({ GTypeInstance *_inst = (GTypeInstance*) ( (ctk_widget_get_display (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_widget_get_type ())))))) ))); GType _t = ((cdk_wayland_display_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; }))))) | |||
| 13139 | { | |||
| 13140 | CdkWindow *cdk_window = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
| 13141 | ||||
| 13142 | cdk_wayland_window_unexport_handle (cdk_window); | |||
| 13143 | } | |||
| 13144 | #endif | |||
| 13145 | } |