Bug Summary

File:core/core.c
Warning:line 92, column 5
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name core.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib/llvm-21/lib/clang/21 -D HAVE_CONFIG_H -I . -I .. -I ./include -D CROMA_LIBEXECDIR="/usr/libexec" -D HOST_ALIAS="" -D CROMA_LOCALEDIR="/usr/share/locale" -D CROMA_PKGDATADIR="/usr/share/croma" -D CROMA_DATADIR="/usr/share" -D G_LOG_DOMAIN="croma" -D SN_API_NOT_YET_FROZEN=1 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -D _REENTRANT -D _REENTRANT -I /usr/include/startup-notification-1.0 -I /usr/include/libgtop-2.0 -D PIC -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2025-12-29-131332-30873-1 -x c core/core.c
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
3/* Croma interface used by CTK+ UI to talk to core */
4
5/*
6 * Copyright (C) 2001 Havoc Pennington
7 * Copyright (C) 2003 Rob Adams
8 * Copyright (C) 2004-2006 Elijah Newren
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301, USA.
24 */
25
26#include <config.h>
27#include "core.h"
28#include "frame-private.h"
29#include "workspace.h"
30#include "prefs.h"
31#include "errors.h"
32
33/* Looks up the MetaWindow representing the frame of the given X window.
34 * Used as a helper function by a bunch of the functions below.
35 *
36 * FIXME: The functions that use this function throw the result away
37 * after use. Many of these functions tend to be called in small groups,
38 * which results in get_window() getting called several times in succession
39 * with the same parameters. We should profile to see whether this wastes
40 * much time, and if it does we should look into a generalised
41 * meta_core_get_window_info() which takes a bunch of pointers to variables
42 * to put its results in, and only fills in the non-null ones.
43 */
44static MetaWindow *
45get_window (Display *xdisplay,
46 Window frame_xwindow)
47{
48 MetaDisplay *display;
49 MetaWindow *window;
50
51 display = meta_display_for_x_display (xdisplay);
52 window = meta_display_lookup_x_window (display, frame_xwindow);
53
54 if (window == NULL((void*)0) || window->frame == NULL((void*)0))
55 {
56 meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
57 return NULL((void*)0);
58 }
59
60 return window;
61}
62
63void
64meta_core_get (Display *xdisplay,
65 Window xwindow,
66 ...)
67{
68 va_list args;
69 MetaCoreGetType request;
70
71 MetaDisplay *display = meta_display_for_x_display (xdisplay);
72 MetaWindow *window = meta_display_lookup_x_window (display, xwindow);
73
74 va_start (args, xwindow)__builtin_va_start(args, xwindow);
75
76 request = va_arg (args, MetaCoreGetType)__builtin_va_arg(args, MetaCoreGetType);
77
78 /* Now, we special-case the first request slightly. Mostly, requests
79 * for information on windows which have no frame are errors.
80 * But sometimes we may want to know *whether* a window has a frame.
81 * In this case, pass the key META_CORE_WINDOW_HAS_FRAME
82 * as the *first* request, with a pointer to a boolean; if the window
83 * has no frame, this will be set to False and meta_core_get will
84 * exit immediately (so the values of any other requests will be
85 * undefined). Otherwise it will be set to True and meta_core_get will
86 * continue happily on its way.
87 */
88
89 if (request != META_CORE_WINDOW_HAS_FRAME &&
90 (window == NULL((void*)0) || window->frame == NULL((void*)0))) {
91 meta_bug ("No such frame window 0x%lx!\n", xwindow);
92 goto out;
This statement is never executed
93 }
94
95 while (request != META_CORE_GET_END) {
96
97 gpointer answer = va_arg (args, gpointer)__builtin_va_arg(args, gpointer);
98
99 switch (request) {
100 case META_CORE_WINDOW_HAS_FRAME:
101 *((gboolean*)answer) = window != NULL((void*)0) && window->frame != NULL((void*)0);
102 if (!*((gboolean*)answer)) goto out; /* see above */
103 break;
104 case META_CORE_GET_CLIENT_WIDTH:
105 *((gint*)answer) = window->rect.width;
106 break;
107 case META_CORE_GET_CLIENT_HEIGHT:
108 *((gint*)answer) = window->rect.height;
109 break;
110 case META_CORE_IS_TITLEBAR_ONSCREEN:
111 *((gboolean*)answer) = meta_window_titlebar_is_onscreen (window);
112 break;
113 case META_CORE_GET_CLIENT_XWINDOW:
114 *((Window*)answer) = window->xwindow;
115 break;
116 case META_CORE_GET_FRAME_FLAGS:
117 *((MetaFrameFlags*)answer) = meta_frame_get_flags (window->frame);
118 break;
119 case META_CORE_GET_FRAME_TYPE:
120 {
121 MetaFrameType base_type = META_FRAME_TYPE_LAST;
122
123 switch (window->type)
124 {
125 case META_WINDOW_NORMAL:
126 base_type = META_FRAME_TYPE_NORMAL;
127 break;
128
129 case META_WINDOW_DIALOG:
130 base_type = META_FRAME_TYPE_DIALOG;
131 break;
132
133 case META_WINDOW_MODAL_DIALOG:
134 if (meta_prefs_get_attach_modal_dialogs () &&
135 meta_window_get_transient_for (window) != NULL((void*)0))
136 base_type = META_FRAME_TYPE_ATTACHED;
137 else
138 base_type = META_FRAME_TYPE_MODAL_DIALOG;
139 break;
140
141 case META_WINDOW_MENU:
142 base_type = META_FRAME_TYPE_MENU;
143 break;
144
145 case META_WINDOW_UTILITY:
146 base_type = META_FRAME_TYPE_UTILITY;
147 break;
148
149 case META_WINDOW_DESKTOP:
150 case META_WINDOW_DOCK:
151 case META_WINDOW_TOOLBAR:
152 case META_WINDOW_SPLASHSCREEN:
153 /* No frame */
154 base_type = META_FRAME_TYPE_LAST;
155 break;
156
157 }
158
159 if (base_type == META_FRAME_TYPE_LAST)
160 {
161 /* can't add border if undecorated */
162 *((MetaFrameType*)answer) = META_FRAME_TYPE_LAST;
163 }
164 else if (window->border_only && base_type != META_FRAME_TYPE_ATTACHED)
165 {
166 /* override base frame type */
167 *((MetaFrameType*)answer) = META_FRAME_TYPE_BORDER;
168 }
169 else
170 {
171 *((MetaFrameType*)answer) = base_type;
172 }
173
174 break;
175 }
176 case META_CORE_GET_MINI_ICON:
177 *((GdkPixbuf**)answer) = window->mini_icon;
178 break;
179 case META_CORE_GET_ICON:
180 *((GdkPixbuf**)answer) = window->icon;
181 break;
182 case META_CORE_GET_X:
183 meta_window_get_position (window, (int*)answer, NULL((void*)0));
184 break;
185 case META_CORE_GET_Y:
186 meta_window_get_position (window, NULL((void*)0), (int*)answer);
187 break;
188 case META_CORE_GET_FRAME_WORKSPACE:
189 *((gint*)answer) = meta_window_get_net_wm_desktop (window);
190 break;
191 case META_CORE_GET_FRAME_X:
192 *((gint*)answer) = window->frame->rect.x;
193 break;
194 case META_CORE_GET_FRAME_Y:
195 *((gint*)answer) = window->frame->rect.y;
196 break;
197 case META_CORE_GET_FRAME_WIDTH:
198 *((gint*)answer) = window->frame->rect.width;
199 break;
200 case META_CORE_GET_FRAME_HEIGHT:
201 *((gint*)answer) = window->frame->rect.height;
202 break;
203 case META_CORE_GET_THEME_VARIANT:
204 *((char**)answer) = window->ctk_theme_variant;
205 break;
206 case META_CORE_GET_SCREEN_WIDTH:
207 *((gint*)answer) = window->screen->rect.width;
208 break;
209 case META_CORE_GET_SCREEN_HEIGHT:
210 *((gint*)answer) = window->screen->rect.height;
211 break;
212
213 default:
214 meta_warning(_("Unknown window information request: %d")dgettext ("croma", "Unknown window information request: %d"), request);
215 }
216
217 request = va_arg (args, MetaCoreGetType)__builtin_va_arg(args, MetaCoreGetType);
218 }
219
220 out:
221 va_end (args)__builtin_va_end(args);
222}
223
224void
225meta_core_queue_frame_resize (Display *xdisplay,
226 Window frame_xwindow)
227{
228 MetaWindow *window = get_window (xdisplay, frame_xwindow);
229
230 meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
231}
232
233void
234meta_core_user_move (Display *xdisplay,
235 Window frame_xwindow,
236 int x,
237 int y)
238{
239 MetaWindow *window = get_window (xdisplay, frame_xwindow);
240
241 meta_window_move (window, TRUE(!(0)), x, y);
242}
243
244void
245meta_core_user_resize (Display *xdisplay,
246 Window frame_xwindow,
247 int gravity,
248 int width,
249 int height)
250{
251 MetaWindow *window = get_window (xdisplay, frame_xwindow);
252
253 meta_window_resize_with_gravity (window, TRUE(!(0)), width, height, gravity);
254}
255
256void
257meta_core_user_raise (Display *xdisplay,
258 Window frame_xwindow)
259{
260 MetaWindow *window = get_window (xdisplay, frame_xwindow);
261
262 meta_window_raise (window);
263}
264
265void
266meta_core_user_lower_and_unfocus (Display *xdisplay,
267 Window frame_xwindow,
268 guint32 timestamp)
269{
270 MetaWindow *window = get_window (xdisplay, frame_xwindow);
271
272 meta_window_lower (window);
273
274 if (meta_prefs_get_raise_on_click ())
275 {
276 /* Move window to the back of the focusing workspace's MRU list.
277 * Do extra sanity checks to avoid possible race conditions.
278 * (Borrowed from window.c.)
279 */
280 if (window->screen->active_workspace &&
281 meta_window_located_on_workspace (window,
282 window->screen->active_workspace))
283 {
284 GList* link;
285 link = g_list_find (window->screen->active_workspace->mru_list,
286 window);
287 g_assert (link)do { if (link) ; else g_assertion_message_expr ("croma", "core/core.c"
, 287, ((const char*) (__func__)), "link"); } while (0)
;
288
289 window->screen->active_workspace->mru_list =
290 g_list_remove_link (window->screen->active_workspace->mru_list,
291 link);
292 g_list_free (link);
293
294 window->screen->active_workspace->mru_list =
295 g_list_append (window->screen->active_workspace->mru_list,
296 window);
297 }
298 }
299
300 /* focus the default window, if needed */
301 if (window->has_focus)
302 meta_workspace_focus_default_window (window->screen->active_workspace,
303 NULL((void*)0),
304 timestamp);
305}
306
307void
308meta_core_lower_beneath_focus_window (Display *xdisplay,
309 Window xwindow,
310 guint32 timestamp)
311{
312 XWindowChanges changes;
313 MetaDisplay *display;
314 MetaScreen *screen;
315 MetaWindow *focus_window;
316
317 display = meta_display_for_x_display (xdisplay);
318 screen = meta_display_screen_for_xwindow (display, xwindow);
319 focus_window = meta_stack_get_top (screen->stack);
320
321 if (focus_window == NULL((void*)0))
322 return;
323
324 changes.stack_mode = Below1;
325 changes.sibling = focus_window->frame ? focus_window->frame->xwindow
326 : focus_window->xwindow;
327
328 meta_error_trap_push (display);
329 XConfigureWindow (xdisplay,
330 xwindow,
331 CWSibling(1<<5) | CWStackMode(1<<6),
332 &changes);
333 meta_error_trap_pop (display, FALSE(0));
334}
335
336void
337meta_core_user_focus (Display *xdisplay,
338 Window frame_xwindow,
339 guint32 timestamp)
340{
341 MetaWindow *window = get_window (xdisplay, frame_xwindow);
342
343 meta_window_focus (window, timestamp);
344}
345
346void
347meta_core_minimize (Display *xdisplay,
348 Window frame_xwindow)
349{
350 MetaWindow *window = get_window (xdisplay, frame_xwindow);
351
352 meta_window_minimize (window);
353}
354
355void
356meta_core_maximize (Display *xdisplay,
357 Window frame_xwindow)
358{
359 MetaWindow *window = get_window (xdisplay, frame_xwindow);
360
361 if (meta_prefs_get_raise_on_click ())
362 meta_window_raise (window);
363
364 meta_window_maximize (window,
365 META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
366}
367
368void
369meta_core_toggle_maximize_vertically (Display *xdisplay,
370 Window frame_xwindow)
371{
372 MetaWindow *window = get_window (xdisplay, frame_xwindow);
373
374 if (meta_prefs_get_raise_on_click ())
375 meta_window_raise (window);
376
377 if (META_WINDOW_MAXIMIZED_VERTICALLY (window)((window)->maximized_vertically))
378 meta_window_unmaximize (window,
379 META_MAXIMIZE_VERTICAL);
380 else
381 meta_window_maximize (window,
382 META_MAXIMIZE_VERTICAL);
383}
384
385void
386meta_core_toggle_maximize_horizontally (Display *xdisplay,
387 Window frame_xwindow)
388{
389 MetaWindow *window = get_window (xdisplay, frame_xwindow);
390
391 if (meta_prefs_get_raise_on_click ())
392 meta_window_raise (window);
393
394 if (META_WINDOW_MAXIMIZED_HORIZONTALLY (window)((window)->maximized_horizontally))
395 meta_window_unmaximize (window,
396 META_MAXIMIZE_HORIZONTAL);
397 else
398 meta_window_maximize (window,
399 META_MAXIMIZE_HORIZONTAL);
400}
401
402void
403meta_core_toggle_maximize (Display *xdisplay,
404 Window frame_xwindow)
405{
406 MetaWindow *window = get_window (xdisplay, frame_xwindow);
407
408 if (meta_prefs_get_raise_on_click ())
409 meta_window_raise (window);
410
411 if (META_WINDOW_MAXIMIZED (window)((window)->maximized_horizontally && (window)->
maximized_vertically)
)
412 meta_window_unmaximize (window,
413 META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
414 else
415 meta_window_maximize (window,
416 META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
417}
418
419void
420meta_core_unmaximize (Display *xdisplay,
421 Window frame_xwindow)
422{
423 MetaWindow *window = get_window (xdisplay, frame_xwindow);
424
425 if (meta_prefs_get_raise_on_click ())
426 meta_window_raise (window);
427
428 meta_window_unmaximize (window,
429 META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
430}
431
432void
433meta_core_delete (Display *xdisplay,
434 Window frame_xwindow,
435 guint32 timestamp)
436{
437 MetaWindow *window = get_window (xdisplay, frame_xwindow);
438
439 meta_window_delete (window, timestamp);
440}
441
442void
443meta_core_unshade (Display *xdisplay,
444 Window frame_xwindow,
445 guint32 timestamp)
446{
447 MetaWindow *window = get_window (xdisplay, frame_xwindow);
448
449 meta_window_unshade (window, timestamp);
450}
451
452void
453meta_core_shade (Display *xdisplay,
454 Window frame_xwindow,
455 guint32 timestamp)
456{
457 MetaWindow *window = get_window (xdisplay, frame_xwindow);
458
459 meta_window_shade (window, timestamp);
460}
461
462void
463meta_core_unstick (Display *xdisplay,
464 Window frame_xwindow)
465{
466 MetaWindow *window = get_window (xdisplay, frame_xwindow);
467
468 meta_window_unstick (window);
469}
470
471void
472meta_core_make_above (Display *xdisplay,
473 Window frame_xwindow)
474{
475 MetaWindow *window = get_window (xdisplay, frame_xwindow);
476
477 meta_window_make_above (window);
478}
479
480void
481meta_core_unmake_above (Display *xdisplay,
482 Window frame_xwindow)
483{
484 MetaWindow *window = get_window (xdisplay, frame_xwindow);
485
486 meta_window_unmake_above (window);
487}
488
489void
490meta_core_stick (Display *xdisplay,
491 Window frame_xwindow)
492{
493 MetaWindow *window = get_window (xdisplay, frame_xwindow);
494
495 meta_window_stick (window);
496}
497
498void
499meta_core_change_workspace (Display *xdisplay,
500 Window frame_xwindow,
501 int new_workspace)
502{
503 MetaWindow *window = get_window (xdisplay, frame_xwindow);
504
505 meta_window_change_workspace (window,
506 meta_screen_get_workspace_by_index (window->screen,
507 new_workspace));
508}
509
510int
511meta_core_get_num_workspaces (Screen *xscreen)
512{
513 MetaScreen *screen;
514
515 screen = meta_screen_for_x_screen (xscreen);
516
517 return meta_screen_get_n_workspaces (screen);
518}
519
520int
521meta_core_get_active_workspace (Screen *xscreen)
522{
523 MetaScreen *screen;
524
525 screen = meta_screen_for_x_screen (xscreen);
526
527 return meta_workspace_index (screen->active_workspace);
528}
529
530void
531meta_core_show_window_menu (Display *xdisplay,
532 Window frame_xwindow,
533 int root_x,
534 int root_y,
535 int button,
536 guint32 timestamp)
537{
538 MetaWindow *window = get_window (xdisplay, frame_xwindow);
539
540 if (meta_prefs_get_raise_on_click ())
541 meta_window_raise (window);
542 meta_window_focus (window, timestamp);
543
544 meta_window_show_menu (window, root_x, root_y, button, timestamp);
545}
546
547void
548meta_core_get_menu_accelerator (MetaMenuOp menu_op,
549 int workspace,
550 unsigned int *keysym,
551 MetaVirtualModifier *modifiers)
552{
553 const char *name;
554
555 name = NULL((void*)0);
556
557 switch (menu_op)
558 {
559 case META_MENU_OP_NONE:
560 /* No keybinding for this one */
561 break;
562 case META_MENU_OP_DELETE:
563 name = "close";
564 break;
565 case META_MENU_OP_MINIMIZE:
566 name = "minimize";
567 break;
568 case META_MENU_OP_UNMAXIMIZE:
569 name = "unmaximize";
570 break;
571 case META_MENU_OP_MAXIMIZE:
572 name = "maximize";
573 break;
574 case META_MENU_OP_UNSHADE:
575 case META_MENU_OP_SHADE:
576 name = "toggle-shaded";
577 break;
578 case META_MENU_OP_UNSTICK:
579 case META_MENU_OP_STICK:
580 name = "toggle-on-all-workspaces";
581 break;
582 case META_MENU_OP_ABOVE:
583 case META_MENU_OP_UNABOVE:
584 name = "toggle-above";
585 break;
586 case META_MENU_OP_WORKSPACES:
587 switch (workspace)
588 {
589 case 1:
590 name = "move-to-workspace-1";
591 break;
592 case 2:
593 name = "move-to-workspace-2";
594 break;
595 case 3:
596 name = "move-to-workspace-3";
597 break;
598 case 4:
599 name = "move-to-workspace-4";
600 break;
601 case 5:
602 name = "move-to-workspace-5";
603 break;
604 case 6:
605 name = "move-to-workspace-6";
606 break;
607 case 7:
608 name = "move-to-workspace-7";
609 break;
610 case 8:
611 name = "move-to-workspace-8";
612 break;
613 case 9:
614 name = "move-to-workspace-9";
615 break;
616 case 10:
617 name = "move-to-workspace-10";
618 break;
619 case 11:
620 name = "move-to-workspace-11";
621 break;
622 case 12:
623 name = "move-to-workspace-12";
624 break;
625 }
626 break;
627 case META_MENU_OP_MOVE:
628 name = "begin-move";
629 break;
630 case META_MENU_OP_RESIZE:
631 name = "begin-resize";
632 break;
633 case META_MENU_OP_MOVE_LEFT:
634 name = "move-to-workspace-left";
635 break;
636 case META_MENU_OP_MOVE_RIGHT:
637 name = "move-to-workspace-right";
638 break;
639 case META_MENU_OP_MOVE_UP:
640 name = "move-to-workspace-up";
641 break;
642 case META_MENU_OP_MOVE_DOWN:
643 name = "move-to-workspace-down";
644 break;
645 case META_MENU_OP_RECOVER:
646 /* No keybinding for this one */
647 break;
648 }
649
650 if (name)
651 {
652 meta_prefs_get_window_binding (name, keysym, modifiers);
653 }
654 else
655 {
656 *keysym = 0;
657 *modifiers = 0;
658 }
659}
660
661const char*
662meta_core_get_workspace_name_with_index (Display *xdisplay,
663 Window xroot,
664 int index)
665{
666 MetaDisplay *display;
667 MetaScreen *screen;
668 MetaWorkspace *workspace;
669
670 display = meta_display_for_x_display (xdisplay);
671 screen = meta_display_screen_for_root (display, xroot);
672 g_assert (screen != NULL)do { if (screen != ((void*)0)) ; else g_assertion_message_expr
("croma", "core/core.c", 672, ((const char*) (__func__)), "screen != NULL"
); } while (0)
;
673 workspace = meta_screen_get_workspace_by_index (screen, index);
674 return workspace ? meta_workspace_get_name (workspace) : NULL((void*)0);
675}
676
677gboolean
678meta_core_begin_grab_op (Display *xdisplay,
679 Window frame_xwindow,
680 MetaGrabOp op,
681 gboolean pointer_already_grabbed,
682 gboolean frame_action,
683 int button,
684 gulong modmask,
685 guint32 timestamp,
686 int root_x,
687 int root_y)
688{
689 MetaWindow *window = get_window (xdisplay, frame_xwindow);
690 MetaDisplay *display;
691 MetaScreen *screen;
692
693 display = meta_display_for_x_display (xdisplay);
694 screen = meta_display_screen_for_xwindow (display, frame_xwindow);
695
696 g_assert (screen != NULL)do { if (screen != ((void*)0)) ; else g_assertion_message_expr
("croma", "core/core.c", 696, ((const char*) (__func__)), "screen != NULL"
); } while (0)
;
697
698 return meta_display_begin_grab_op (display, screen, window,
699 op, pointer_already_grabbed,
700 frame_action,
701 button, modmask,
702 timestamp, root_x, root_y);
703}
704
705void
706meta_core_end_grab_op (Display *xdisplay,
707 guint32 timestamp)
708{
709 MetaDisplay *display;
710
711 display = meta_display_for_x_display (xdisplay);
712
713 meta_display_end_grab_op (display, timestamp);
714}
715
716MetaGrabOp
717meta_core_get_grab_op (Display *xdisplay)
718{
719 MetaDisplay *display;
720
721 display = meta_display_for_x_display (xdisplay);
722
723 return display->grab_op;
724}
725
726Window
727meta_core_get_grab_frame (Display *xdisplay)
728{
729 MetaDisplay *display;
730
731 display = meta_display_for_x_display (xdisplay);
732
733 g_assert (display != NULL)do { if (display != ((void*)0)) ; else g_assertion_message_expr
("croma", "core/core.c", 733, ((const char*) (__func__)), "display != NULL"
); } while (0)
;
734 g_assert (display->grab_op == META_GRAB_OP_NONE ||do { if (display->grab_op == META_GRAB_OP_NONE || display->
grab_screen != ((void*)0)) ; else g_assertion_message_expr ("croma"
, "core/core.c", 735, ((const char*) (__func__)), "display->grab_op == META_GRAB_OP_NONE || display->grab_screen != NULL"
); } while (0)
735 display->grab_screen != NULL)do { if (display->grab_op == META_GRAB_OP_NONE || display->
grab_screen != ((void*)0)) ; else g_assertion_message_expr ("croma"
, "core/core.c", 735, ((const char*) (__func__)), "display->grab_op == META_GRAB_OP_NONE || display->grab_screen != NULL"
); } while (0)
;
736 g_assert (display->grab_op == META_GRAB_OP_NONE ||do { if (display->grab_op == META_GRAB_OP_NONE || display->
grab_screen->display->xdisplay == xdisplay) ; else g_assertion_message_expr
("croma", "core/core.c", 737, ((const char*) (__func__)), "display->grab_op == META_GRAB_OP_NONE || display->grab_screen->display->xdisplay == xdisplay"
); } while (0)
737 display->grab_screen->display->xdisplay == xdisplay)do { if (display->grab_op == META_GRAB_OP_NONE || display->
grab_screen->display->xdisplay == xdisplay) ; else g_assertion_message_expr
("croma", "core/core.c", 737, ((const char*) (__func__)), "display->grab_op == META_GRAB_OP_NONE || display->grab_screen->display->xdisplay == xdisplay"
); } while (0)
;
738
739 if (display->grab_op != META_GRAB_OP_NONE &&
740 display->grab_window &&
741 display->grab_window->frame)
742 return display->grab_window->frame->xwindow;
743 else
744 return None0L;
745}
746
747int
748meta_core_get_grab_button (Display *xdisplay)
749{
750 MetaDisplay *display;
751
752 display = meta_display_for_x_display (xdisplay);
753
754 if (display->grab_op == META_GRAB_OP_NONE)
755 return -1;
756
757 return display->grab_button;
758}
759
760void
761meta_core_grab_buttons (Display *xdisplay,
762 Window frame_xwindow)
763{
764 MetaDisplay *display;
765
766 display = meta_display_for_x_display (xdisplay);
767
768 meta_verbosemeta_verbose_real ("Grabbing buttons on frame 0x%lx\n", frame_xwindow);
769 meta_display_grab_window_buttons (display, frame_xwindow);
770}
771
772void
773meta_core_set_screen_cursor (Display *xdisplay,
774 Window frame_on_screen,
775 MetaCursor cursor)
776{
777 MetaWindow *window = get_window (xdisplay, frame_on_screen);
778
779 meta_frame_set_screen_cursor (window->frame, cursor);
780}
781
782void
783meta_core_increment_event_serial (Display *xdisplay)
784{
785 MetaDisplay *display;
786
787 display = meta_display_for_x_display (xdisplay);
788
789 meta_display_increment_event_serial (display);
790}
791
792void
793meta_invalidate_default_icons (void)
794{
795 MetaDisplay *display = meta_get_display ();
796 GSList *windows;
797 GSList *l;
798
799 if (display == NULL((void*)0))
800 return; /* We can validly be called before the display is opened. */
801
802 windows = meta_display_list_windows (display);
803 for (l = windows; l != NULL((void*)0); l = l->next)
804 {
805 MetaWindow *window = (MetaWindow*)l->data;
806
807 if (window->icon_cache.origin == USING_FALLBACK_ICON)
808 {
809 meta_icon_cache_free (&(window->icon_cache));
810 meta_window_update_icon_now (window);
811 }
812 }
813
814 g_slist_free (windows);
815}
816
817void
818meta_invalidate_all_icons (void)
819{
820 MetaDisplay *display = meta_get_display ();
821 GSList *windows;
822 GSList *l;
823
824 if (display == NULL((void*)0))
825 return; /* We can validly be called before the display is opened. */
826
827 windows = meta_display_list_windows (display);
828 for (l = windows; l != NULL((void*)0); l = l->next)
829 {
830 MetaWindow *window = (MetaWindow*)l->data;
831
832 meta_icon_cache_invalidate (&(window->icon_cache));
833 meta_window_update_icon_now (window);
834 }
835
836 g_slist_free (windows);
837}
838