| 1 |
/* GDK - The GIMP Drawing Kit |
| 2 |
* Copyright (C) 1995-2007 Peter Mattis, Spencer Kimball, |
| 3 |
* Josh MacDonald, Ryan Lortie |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/* |
| 20 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 21 |
* file for a list of people on the GTK+ Team. See the ChangeLog |
| 22 |
* files for a list of changes. These files are distributed with |
| 23 |
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "config.h" |
| 27 |
|
| 28 |
#include "gdkwindow-x11.h" |
| 29 |
|
| 30 |
#include "gdkwindow.h" |
| 31 |
#include "gdkwindowimpl.h" |
| 32 |
#include "gdkvisualprivate.h" |
| 33 |
#include "gdkinternals.h" |
| 34 |
#include "gdkdeviceprivate.h" |
| 35 |
#include "gdkframeclockprivate.h" |
| 36 |
#include "gdkasync.h" |
| 37 |
#include "gdkeventsource.h" |
| 38 |
#include "gdkdisplay-x11.h" |
| 39 |
#include "gdkglcontext-x11.h" |
| 40 |
#include "gdkprivate-x11.h" |
| 41 |
#include "gdk-private.h" |
| 42 |
|
| 43 |
#include <stdlib.h> |
| 44 |
#include <stdio.h> |
| 45 |
#include <string.h> |
| 46 |
#include <netinet/in.h> |
| 47 |
#include <unistd.h> |
| 48 |
|
| 49 |
#include <cairo-xlib.h> |
| 50 |
|
| 51 |
#include "MwmUtil.h" |
| 52 |
|
| 53 |
#include <X11/Xlib.h> |
| 54 |
#include <X11/Xutil.h> |
| 55 |
#include <X11/Xatom.h> |
| 56 |
|
| 57 |
#include <X11/extensions/shape.h> |
| 58 |
|
| 59 |
#ifdef HAVE_XKB |
| 60 |
#include <X11/XKBlib.h> |
| 61 |
#endif |
| 62 |
|
| 63 |
#ifdef HAVE_XCOMPOSITE |
| 64 |
#include <X11/extensions/Xcomposite.h> |
| 65 |
#endif |
| 66 |
|
| 67 |
#ifdef HAVE_XFIXES |
| 68 |
#include <X11/extensions/Xfixes.h> |
| 69 |
#endif |
| 70 |
|
| 71 |
#ifdef HAVE_XDAMAGE |
| 72 |
#include <X11/extensions/Xdamage.h> |
| 73 |
#endif |
| 74 |
|
| 75 |
#define XLIB_COORD_MAX 32767 |
| 76 |
|
| 77 |
const int _gdk_x11_event_mask_table[21] = |
| 78 |
{ |
| 79 |
ExposureMask, |
| 80 |
PointerMotionMask, |
| 81 |
PointerMotionHintMask, |
| 82 |
ButtonMotionMask, |
| 83 |
Button1MotionMask, |
| 84 |
Button2MotionMask, |
| 85 |
Button3MotionMask, |
| 86 |
ButtonPressMask, |
| 87 |
ButtonReleaseMask, |
| 88 |
KeyPressMask, |
| 89 |
KeyReleaseMask, |
| 90 |
EnterWindowMask, |
| 91 |
LeaveWindowMask, |
| 92 |
FocusChangeMask, |
| 93 |
StructureNotifyMask, |
| 94 |
PropertyChangeMask, |
| 95 |
VisibilityChangeMask, |
| 96 |
0, /* PROXIMITY_IN */ |
| 97 |
0, /* PROXIMTY_OUT */ |
| 98 |
SubstructureNotifyMask, |
| 99 |
ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */ |
| 100 |
}; |
| 101 |
|
| 102 |
const gint _gdk_x11_event_mask_table_size = G_N_ELEMENTS (_gdk_x11_event_mask_table); |
| 103 |
|
| 104 |
/* Forward declarations */ |
| 105 |
static void gdk_x11_window_apply_fullscreen_mode (GdkWindow *window); |
| 106 |
static gboolean gdk_window_icon_name_set (GdkWindow *window); |
| 107 |
static void set_wm_name (GdkDisplay *display, |
| 108 |
Window xwindow, |
| 109 |
const gchar *name); |
| 110 |
static void move_to_current_desktop (GdkWindow *window); |
| 111 |
static void gdk_window_x11_set_background (GdkWindow *window, |
| 112 |
cairo_pattern_t *pattern); |
| 113 |
|
| 114 |
static void gdk_window_impl_x11_finalize (GObject *object); |
| 115 |
|
| 116 |
#define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \ |
| 117 |
(GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL || \ |
| 118 |
GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || \ |
| 119 |
GDK_WINDOW_TYPE (window) == GDK_WINDOW_FOREIGN) |
| 120 |
|
| 121 |
#define WINDOW_IS_TOPLEVEL(window) \ |
| 122 |
(GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL || \ |
| 123 |
GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP) |
| 124 |
|
| 125 |
/* Return whether time1 is considered later than time2 as far as xserver |
| 126 |
* time is concerned. Accounts for wraparound. |
| 127 |
*/ |
| 128 |
#define XSERVER_TIME_IS_LATER(time1, time2) \ |
| 129 |
( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \ |
| 130 |
(( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \ |
| 131 |
) |
| 132 |
|
| 133 |
struct _GdkX11Window { |
| 134 |
GdkWindow parent; |
| 135 |
}; |
| 136 |
|
| 137 |
struct _GdkX11WindowClass { |
| 138 |
GdkWindowClass parent_class; |
| 139 |
}; |
| 140 |
|
| 141 |
G_DEFINE_TYPE (GdkX11Window, gdk_x11_window, GDK_TYPE_WINDOW) |
| 142 |
|
| 143 |
static void |
| 144 |
gdk_x11_window_class_init (GdkX11WindowClass *x11_window_class) |
| 145 |
{ |
| 146 |
} |
| 147 |
|
| 148 |
static void |
| 149 |
gdk_x11_window_init (GdkX11Window *x11_window) |
| 150 |
{ |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
G_DEFINE_TYPE (GdkWindowImplX11, gdk_window_impl_x11, GDK_TYPE_WINDOW_IMPL) |
| 155 |
|
| 156 |
static void |
| 157 |
gdk_window_impl_x11_init (GdkWindowImplX11 *impl) |
| 158 |
{ |
| 159 |
impl->device_cursor = g_hash_table_new_full (NULL, NULL, |
| 160 |
NULL, g_object_unref); |
| 161 |
impl->window_scale = 1; |
| 162 |
impl->frame_sync_enabled = TRUE; |
| 163 |
} |
| 164 |
|
| 165 |
GdkToplevelX11 * |
| 166 |
_gdk_x11_window_get_toplevel (GdkWindow *window) |
| 167 |
{ |
| 168 |
GdkWindowImplX11 *impl; |
| 169 |
|
| 170 |
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); |
| 171 |
|
| 172 |
if (!WINDOW_IS_TOPLEVEL (window)) |
| 173 |
return NULL; |
| 174 |
|
| 175 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 176 |
|
| 177 |
if (!impl->toplevel) |
| 178 |
{ |
| 179 |
impl->toplevel = g_new0 (GdkToplevelX11, 1); |
| 180 |
impl->toplevel->have_focused = TRUE; |
| 181 |
} |
| 182 |
|
| 183 |
return impl->toplevel; |
| 184 |
} |
| 185 |
|
| 186 |
/** |
| 187 |
* _gdk_x11_window_update_size: |
| 188 |
* @impl: a #GdkWindowImplX11. |
| 189 |
* |
| 190 |
* Updates the state of the window (in particular the drawable's |
| 191 |
* cairo surface) when its size has changed. |
| 192 |
**/ |
| 193 |
void |
| 194 |
_gdk_x11_window_update_size (GdkWindowImplX11 *impl) |
| 195 |
{ |
| 196 |
if (impl->cairo_surface) |
| 197 |
{ |
| 198 |
if (impl->unscaled_width < 0) |
| 199 |
impl->unscaled_width = 0; |
| 200 |
else if (impl->unscaled_width > XLIB_COORD_MAX) |
| 201 |
impl->unscaled_width = XLIB_COORD_MAX; |
| 202 |
if (impl->unscaled_height < 0) |
| 203 |
impl->unscaled_height = 0; |
| 204 |
else if (impl->unscaled_height > XLIB_COORD_MAX) |
| 205 |
impl->unscaled_height = XLIB_COORD_MAX; |
| 206 |
cairo_xlib_surface_set_size (impl->cairo_surface, |
| 207 |
impl->unscaled_width, impl->unscaled_height); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
void |
| 212 |
gdk_x11_window_get_unscaled_size (GdkWindow *window, |
| 213 |
int *unscaled_width, |
| 214 |
int *unscaled_height) |
| 215 |
{ |
| 216 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 217 |
|
| 218 |
if (unscaled_width) |
| 219 |
*unscaled_width = impl->unscaled_width; |
| 220 |
|
| 221 |
if (unscaled_height) |
| 222 |
*unscaled_height = impl->unscaled_height; |
| 223 |
} |
| 224 |
|
| 225 |
static void |
| 226 |
set_sync_counter(Display *display, |
| 227 |
XSyncCounter counter, |
| 228 |
gint64 value) |
| 229 |
{ |
| 230 |
XSyncValue sync_value; |
| 231 |
|
| 232 |
XSyncIntsToValue (&sync_value, |
| 233 |
value & G_GINT64_CONSTANT(0xFFFFFFFF), |
| 234 |
value >> 32); |
| 235 |
XSyncSetCounter (display, counter, sync_value); |
| 236 |
} |
| 237 |
|
| 238 |
static void |
| 239 |
window_pre_damage (GdkWindow *window) |
| 240 |
{ |
| 241 |
GdkWindow *toplevel_window = gdk_window_get_toplevel (window); |
| 242 |
GdkWindowImplX11 *impl; |
| 243 |
|
| 244 |
if (!toplevel_window || !WINDOW_IS_TOPLEVEL (toplevel_window)) |
| 245 |
return; |
| 246 |
|
| 247 |
impl = GDK_WINDOW_IMPL_X11 (toplevel_window->impl); |
| 248 |
|
| 249 |
if (impl->toplevel->in_frame && |
| 250 |
impl->toplevel->current_counter_value % 2 == 0) |
| 251 |
{ |
| 252 |
impl->toplevel->current_counter_value += 1; |
| 253 |
set_sync_counter (GDK_WINDOW_XDISPLAY (impl->wrapper), |
| 254 |
impl->toplevel->extended_update_counter, |
| 255 |
impl->toplevel->current_counter_value); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
static void |
| 260 |
on_surface_changed (void *data) |
| 261 |
{ |
| 262 |
GdkWindow *window = data; |
| 263 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 264 |
|
| 265 |
if (impl->tracking_damage) |
| 266 |
window_pre_damage (window); |
| 267 |
} |
| 268 |
|
| 269 |
/* We want to know when cairo drawing causes damage to the window, |
| 270 |
* so we engage in the _NET_WM_FRAME_DRAWN protocol with the |
| 271 |
* window only when there actually is drawing. To do that we use |
| 272 |
* a technique (hack) suggested by Uli Schlachter - if we set |
| 273 |
* a dummy "mime data" on the cairo surface (this facility is |
| 274 |
* used to attach JPEG data to an imager), then cairo wil flush |
| 275 |
* and remove the mime data before making any changes to the window. |
| 276 |
*/ |
| 277 |
|
| 278 |
static void |
| 279 |
hook_surface_changed (GdkWindow *window) |
| 280 |
{ |
| 281 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 282 |
|
| 283 |
/* The hooking we do below doesn't work if we're rendering with |
| 284 |
* OpenGL (the cairo surface is not touched) so just always |
| 285 |
* do the frame. |
| 286 |
*/ |
| 287 |
if (window->current_paint.use_gl) |
| 288 |
{ |
| 289 |
window_pre_damage (window); |
| 290 |
return; |
| 291 |
} |
| 292 |
|
| 293 |
if (impl->cairo_surface) |
| 294 |
{ |
| 295 |
cairo_surface_set_mime_data (impl->cairo_surface, |
| 296 |
"x-gdk/change-notify", |
| 297 |
(unsigned char *)"X", |
| 298 |
1, |
| 299 |
on_surface_changed, |
| 300 |
window); |
| 301 |
impl->tracking_damage = 1; |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
static void |
| 306 |
unhook_surface_changed (GdkWindow *window) |
| 307 |
{ |
| 308 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 309 |
|
| 310 |
if (impl->cairo_surface) |
| 311 |
{ |
| 312 |
impl->tracking_damage = 0; |
| 313 |
cairo_surface_set_mime_data (impl->cairo_surface, |
| 314 |
"x-gdk/change-notify", |
| 315 |
NULL, 0, |
| 316 |
NULL, NULL); |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
static void |
| 321 |
gdk_x11_window_predict_presentation_time (GdkWindow *window) |
| 322 |
{ |
| 323 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 324 |
GdkFrameClock *clock; |
| 325 |
GdkFrameTimings *timings; |
| 326 |
gint64 presentation_time; |
| 327 |
gint64 refresh_interval; |
| 328 |
|
| 329 |
if (!WINDOW_IS_TOPLEVEL (window)) |
| 330 |
return; |
| 331 |
|
| 332 |
clock = gdk_window_get_frame_clock (window); |
| 333 |
|
| 334 |
timings = gdk_frame_clock_get_current_timings (clock); |
| 335 |
|
| 336 |
gdk_frame_clock_get_refresh_info (clock, |
| 337 |
timings->frame_time, |
| 338 |
&refresh_interval, &presentation_time); |
| 339 |
|
| 340 |
if (presentation_time != 0) |
| 341 |
{ |
| 342 |
if (timings->slept_before) |
| 343 |
{ |
| 344 |
presentation_time += refresh_interval; |
| 345 |
} |
| 346 |
else |
| 347 |
{ |
| 348 |
if (presentation_time < timings->frame_time + refresh_interval / 2) |
| 349 |
presentation_time += refresh_interval; |
| 350 |
} |
| 351 |
} |
| 352 |
else |
| 353 |
{ |
| 354 |
if (timings->slept_before) |
| 355 |
presentation_time = timings->frame_time + refresh_interval + refresh_interval / 2; |
| 356 |
else |
| 357 |
presentation_time = timings->frame_time + refresh_interval; |
| 358 |
} |
| 359 |
|
| 360 |
if (presentation_time < impl->toplevel->throttled_presentation_time) |
| 361 |
presentation_time = impl->toplevel->throttled_presentation_time; |
| 362 |
|
| 363 |
timings->predicted_presentation_time = presentation_time; |
| 364 |
} |
| 365 |
|
| 366 |
static void |
| 367 |
gdk_x11_window_begin_frame (GdkWindow *window, |
| 368 |
gboolean force_frame) |
| 369 |
{ |
| 370 |
GdkWindowImplX11 *impl; |
| 371 |
|
| 372 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 373 |
|
| 374 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 375 |
|
| 376 |
if (!WINDOW_IS_TOPLEVEL (window) || |
| 377 |
impl->toplevel->extended_update_counter == None) |
| 378 |
return; |
| 379 |
|
| 380 |
impl->toplevel->in_frame = TRUE; |
| 381 |
|
| 382 |
if (impl->toplevel->configure_counter_value != 0 && |
| 383 |
impl->toplevel->configure_counter_value_is_extended) |
| 384 |
{ |
| 385 |
impl->toplevel->current_counter_value = impl->toplevel->configure_counter_value; |
| 386 |
if ((impl->toplevel->current_counter_value % 2) == 1) |
| 387 |
impl->toplevel->current_counter_value += 1; |
| 388 |
|
| 389 |
impl->toplevel->configure_counter_value = 0; |
| 390 |
|
| 391 |
window_pre_damage (window); |
| 392 |
} |
| 393 |
else if (force_frame) |
| 394 |
{ |
| 395 |
/* When mapping the window, we really want to freeze the |
| 396 |
rendering of the window by the compositor until we've |
| 397 |
actually painted something into the window's buffer. */ |
| 398 |
window_pre_damage (window); |
| 399 |
} |
| 400 |
else |
| 401 |
{ |
| 402 |
hook_surface_changed (window); |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
static void |
| 407 |
gdk_x11_window_end_frame (GdkWindow *window) |
| 408 |
{ |
| 409 |
GdkFrameClock *clock; |
| 410 |
GdkFrameTimings *timings; |
| 411 |
GdkWindowImplX11 *impl; |
| 412 |
|
| 413 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 414 |
|
| 415 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 416 |
|
| 417 |
if (!WINDOW_IS_TOPLEVEL (window) || |
| 418 |
impl->toplevel->extended_update_counter == None || |
| 419 |
!impl->toplevel->in_frame) |
| 420 |
return; |
| 421 |
|
| 422 |
clock = gdk_window_get_frame_clock (window); |
| 423 |
timings = gdk_frame_clock_get_current_timings (clock); |
| 424 |
|
| 425 |
impl->toplevel->in_frame = FALSE; |
| 426 |
|
| 427 |
if (impl->toplevel->current_counter_value % 2 == 1) |
| 428 |
{ |
| 429 |
#ifdef G_ENABLE_DEBUG |
| 430 |
if (GDK_DEBUG_CHECK (FRAMES)) |
| 431 |
{ |
| 432 |
XImage *image = XGetImage (GDK_WINDOW_XDISPLAY (window), |
| 433 |
GDK_WINDOW_XID (window), |
| 434 |
0, 0, 1, 1, |
| 435 |
(1 << 24) - 1, |
| 436 |
ZPixmap); |
| 437 |
XDestroyImage (image); |
| 438 |
} |
| 439 |
#endif /* G_ENABLE_DEBUG */ |
| 440 |
|
| 441 |
/* An increment of 3 means that the frame was not drawn as fast as possible, |
| 442 |
* but rather at a particular time. This can trigger different handling from |
| 443 |
* the compositor. |
| 444 |
*/ |
| 445 |
if (timings->slept_before) |
| 446 |
impl->toplevel->current_counter_value += 3; |
| 447 |
else |
| 448 |
impl->toplevel->current_counter_value += 1; |
| 449 |
|
| 450 |
set_sync_counter(GDK_WINDOW_XDISPLAY (impl->wrapper), |
| 451 |
impl->toplevel->extended_update_counter, |
| 452 |
impl->toplevel->current_counter_value); |
| 453 |
|
| 454 |
if (impl->frame_sync_enabled && |
| 455 |
gdk_x11_screen_supports_net_wm_hint (gdk_window_get_screen (window), |
| 456 |
gdk_atom_intern_static_string ("_NET_WM_FRAME_DRAWN"))) |
| 457 |
{ |
| 458 |
impl->toplevel->frame_pending = TRUE; |
| 459 |
_gdk_frame_clock_freeze (gdk_window_get_frame_clock (window)); |
| 460 |
timings->cookie = impl->toplevel->current_counter_value; |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
unhook_surface_changed (window); |
| 465 |
|
| 466 |
if (impl->toplevel->configure_counter_value != 0 && |
| 467 |
!impl->toplevel->configure_counter_value_is_extended) |
| 468 |
{ |
| 469 |
set_sync_counter (GDK_WINDOW_XDISPLAY (window), |
| 470 |
impl->toplevel->update_counter, |
| 471 |
impl->toplevel->configure_counter_value); |
| 472 |
|
| 473 |
impl->toplevel->configure_counter_value = 0; |
| 474 |
} |
| 475 |
|
| 476 |
if (!impl->toplevel->frame_pending) |
| 477 |
timings->complete = TRUE; |
| 478 |
} |
| 479 |
|
| 480 |
/***************************************************** |
| 481 |
* X11 specific implementations of generic functions * |
| 482 |
*****************************************************/ |
| 483 |
|
| 484 |
static cairo_surface_t * |
| 485 |
gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl, |
| 486 |
int width, |
| 487 |
int height) |
| 488 |
{ |
| 489 |
GdkVisual *visual; |
| 490 |
|
| 491 |
visual = gdk_window_get_visual (impl->wrapper); |
| 492 |
return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper), |
| 493 |
GDK_WINDOW_IMPL_X11 (impl)->xid, |
| 494 |
GDK_VISUAL_XVISUAL (visual), |
| 495 |
width, height); |
| 496 |
} |
| 497 |
|
| 498 |
static cairo_surface_t * |
| 499 |
gdk_x11_ref_cairo_surface (GdkWindow *window) |
| 500 |
{ |
| 501 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 502 |
|
| 503 |
if (GDK_WINDOW_DESTROYED (window)) |
| 504 |
return NULL; |
| 505 |
|
| 506 |
if (!impl->cairo_surface) |
| 507 |
{ |
| 508 |
impl->cairo_surface = gdk_x11_create_cairo_surface (impl, |
| 509 |
gdk_window_get_width (window) * impl->window_scale, |
| 510 |
gdk_window_get_height (window) * impl->window_scale); |
| 511 |
cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale); |
| 512 |
|
| 513 |
if (WINDOW_IS_TOPLEVEL (window) && impl->toplevel->in_frame) |
| 514 |
hook_surface_changed (window); |
| 515 |
} |
| 516 |
|
| 517 |
cairo_surface_reference (impl->cairo_surface); |
| 518 |
|
| 519 |
return impl->cairo_surface; |
| 520 |
} |
| 521 |
|
| 522 |
static void |
| 523 |
gdk_window_impl_x11_finalize (GObject *object) |
| 524 |
{ |
| 525 |
GdkWindow *wrapper; |
| 526 |
GdkWindowImplX11 *impl; |
| 527 |
|
| 528 |
g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object)); |
| 529 |
|
| 530 |
impl = GDK_WINDOW_IMPL_X11 (object); |
| 531 |
|
| 532 |
wrapper = impl->wrapper; |
| 533 |
|
| 534 |
if (WINDOW_IS_TOPLEVEL (wrapper) && impl->toplevel->in_frame) |
| 535 |
unhook_surface_changed (wrapper); |
| 536 |
|
| 537 |
_gdk_x11_window_grab_check_destroy (wrapper); |
| 538 |
|
| 539 |
if (!GDK_WINDOW_DESTROYED (wrapper)) |
| 540 |
{ |
| 541 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (wrapper); |
| 542 |
|
| 543 |
_gdk_x11_display_remove_window (display, impl->xid); |
| 544 |
if (impl->toplevel && impl->toplevel->focus_window) |
| 545 |
_gdk_x11_display_remove_window (display, impl->toplevel->focus_window); |
| 546 |
} |
| 547 |
|
| 548 |
g_free (impl->toplevel); |
| 549 |
|
| 550 |
if (impl->cursor) |
| 551 |
g_object_unref (impl->cursor); |
| 552 |
|
| 553 |
g_hash_table_destroy (impl->device_cursor); |
| 554 |
|
| 555 |
G_OBJECT_CLASS (gdk_window_impl_x11_parent_class)->finalize (object); |
| 556 |
} |
| 557 |
|
| 558 |
typedef struct { |
| 559 |
GdkDisplay *display; |
| 560 |
Pixmap pixmap; |
| 561 |
} FreePixmapData; |
| 562 |
|
| 563 |
static void |
| 564 |
free_pixmap (gpointer datap) |
| 565 |
{ |
| 566 |
FreePixmapData *data = datap; |
| 567 |
|
| 568 |
if (!gdk_display_is_closed (data->display)) |
| 569 |
{ |
| 570 |
XFreePixmap (GDK_DISPLAY_XDISPLAY (data->display), |
| 571 |
data->pixmap); |
| 572 |
} |
| 573 |
|
| 574 |
g_object_unref (data->display); |
| 575 |
g_slice_free (FreePixmapData, data); |
| 576 |
} |
| 577 |
|
| 578 |
static void |
| 579 |
attach_free_pixmap_handler (cairo_surface_t *surface, |
| 580 |
GdkDisplay *display, |
| 581 |
Pixmap pixmap) |
| 582 |
{ |
| 583 |
static const cairo_user_data_key_t key; |
| 584 |
FreePixmapData *data; |
| 585 |
|
| 586 |
data = g_slice_new (FreePixmapData); |
| 587 |
data->display = g_object_ref (display); |
| 588 |
data->pixmap = pixmap; |
| 589 |
|
| 590 |
cairo_surface_set_user_data (surface, &key, data, free_pixmap); |
| 591 |
} |
| 592 |
|
| 593 |
/* Cairo does not guarantee we get an xlib surface if we call |
| 594 |
* cairo_surface_create_similar(). In some cases however, we must use a |
| 595 |
* pixmap or bitmap in the X11 API. |
| 596 |
* These functions ensure an Xlib surface. |
| 597 |
*/ |
| 598 |
cairo_surface_t * |
| 599 |
_gdk_x11_window_create_bitmap_surface (GdkWindow *window, |
| 600 |
int width, |
| 601 |
int height) |
| 602 |
{ |
| 603 |
cairo_surface_t *surface; |
| 604 |
Pixmap pixmap; |
| 605 |
|
| 606 |
pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window), |
| 607 |
GDK_WINDOW_XID (window), |
| 608 |
width, height, 1); |
| 609 |
surface = cairo_xlib_surface_create_for_bitmap (GDK_WINDOW_XDISPLAY (window), |
| 610 |
pixmap, |
| 611 |
GDK_X11_SCREEN (GDK_WINDOW_SCREEN (window))->xscreen, |
| 612 |
width, height); |
| 613 |
attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap); |
| 614 |
|
| 615 |
return surface; |
| 616 |
} |
| 617 |
|
| 618 |
/* Create a surface backed with a pixmap without alpha on the same screen as window */ |
| 619 |
static cairo_surface_t * |
| 620 |
gdk_x11_window_create_pixmap_surface (GdkWindow *window, |
| 621 |
int width, |
| 622 |
int height) |
| 623 |
{ |
| 624 |
GdkScreen *screen = gdk_window_get_screen (window); |
| 625 |
GdkVisual *visual = gdk_screen_get_system_visual (screen); |
| 626 |
cairo_surface_t *surface; |
| 627 |
Pixmap pixmap; |
| 628 |
|
| 629 |
pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window), |
| 630 |
GDK_WINDOW_XID (window), |
| 631 |
width, height, |
| 632 |
gdk_visual_get_depth (visual)); |
| 633 |
surface = cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (window), |
| 634 |
pixmap, |
| 635 |
GDK_VISUAL_XVISUAL (visual), |
| 636 |
width, height); |
| 637 |
attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap); |
| 638 |
|
| 639 |
return surface; |
| 640 |
} |
| 641 |
|
| 642 |
static void |
| 643 |
tmp_unset_bg (GdkWindow *window) |
| 644 |
{ |
| 645 |
GdkWindowImplX11 *impl; |
| 646 |
|
| 647 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 648 |
|
| 649 |
impl->no_bg = TRUE; |
| 650 |
|
| 651 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 652 |
GDK_WINDOW_XID (window), None); |
| 653 |
} |
| 654 |
|
| 655 |
static void |
| 656 |
tmp_reset_bg (GdkWindow *window) |
| 657 |
{ |
| 658 |
GdkWindowImplX11 *impl; |
| 659 |
|
| 660 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 661 |
|
| 662 |
impl->no_bg = FALSE; |
| 663 |
|
| 664 |
gdk_window_x11_set_background (window, window->background); |
| 665 |
} |
| 666 |
|
| 667 |
/* Unsetting and resetting window backgrounds. |
| 668 |
* |
| 669 |
* In many cases it is possible to avoid flicker by unsetting the |
| 670 |
* background of windows. For example if the background of the |
| 671 |
* parent window is unset when a window is unmapped, a brief flicker |
| 672 |
* of background painting is avoided. |
| 673 |
*/ |
| 674 |
void |
| 675 |
_gdk_x11_window_tmp_unset_bg (GdkWindow *window, |
| 676 |
gboolean recurse) |
| 677 |
{ |
| 678 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 679 |
|
| 680 |
if (window->input_only || window->destroyed || |
| 681 |
(window->window_type != GDK_WINDOW_ROOT && |
| 682 |
!GDK_WINDOW_IS_MAPPED (window))) |
| 683 |
return; |
| 684 |
|
| 685 |
if (_gdk_window_has_impl (window) && |
| 686 |
GDK_WINDOW_IS_X11 (window) && |
| 687 |
window->window_type != GDK_WINDOW_ROOT && |
| 688 |
window->window_type != GDK_WINDOW_FOREIGN) |
| 689 |
tmp_unset_bg (window); |
| 690 |
|
| 691 |
if (recurse) |
| 692 |
{ |
| 693 |
GList *l; |
| 694 |
|
| 695 |
for (l = window->children; l != NULL; l = l->next) |
| 696 |
_gdk_x11_window_tmp_unset_bg (l->data, TRUE); |
| 697 |
} |
| 698 |
} |
| 699 |
|
| 700 |
void |
| 701 |
_gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window) |
| 702 |
{ |
| 703 |
if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT) |
| 704 |
return; |
| 705 |
|
| 706 |
window = _gdk_window_get_impl_window (window->parent); |
| 707 |
_gdk_x11_window_tmp_unset_bg (window, FALSE); |
| 708 |
} |
| 709 |
|
| 710 |
void |
| 711 |
_gdk_x11_window_tmp_reset_bg (GdkWindow *window, |
| 712 |
gboolean recurse) |
| 713 |
{ |
| 714 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 715 |
|
| 716 |
if (window->input_only || window->destroyed || |
| 717 |
(window->window_type != GDK_WINDOW_ROOT && |
| 718 |
!GDK_WINDOW_IS_MAPPED (window))) |
| 719 |
return; |
| 720 |
|
| 721 |
|
| 722 |
if (_gdk_window_has_impl (window) && |
| 723 |
GDK_WINDOW_IS_X11 (window) && |
| 724 |
window->window_type != GDK_WINDOW_ROOT && |
| 725 |
window->window_type != GDK_WINDOW_FOREIGN) |
| 726 |
tmp_reset_bg (window); |
| 727 |
|
| 728 |
if (recurse) |
| 729 |
{ |
| 730 |
GList *l; |
| 731 |
|
| 732 |
for (l = window->children; l != NULL; l = l->next) |
| 733 |
_gdk_x11_window_tmp_reset_bg (l->data, TRUE); |
| 734 |
} |
| 735 |
} |
| 736 |
|
| 737 |
void |
| 738 |
_gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window) |
| 739 |
{ |
| 740 |
if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT) |
| 741 |
return; |
| 742 |
|
| 743 |
window = _gdk_window_get_impl_window (window->parent); |
| 744 |
|
| 745 |
_gdk_x11_window_tmp_reset_bg (window, FALSE); |
| 746 |
} |
| 747 |
|
| 748 |
void |
| 749 |
_gdk_x11_screen_init_root_window (GdkScreen *screen) |
| 750 |
{ |
| 751 |
GdkWindow *window; |
| 752 |
GdkWindowImplX11 *impl; |
| 753 |
GdkX11Screen *x11_screen; |
| 754 |
|
| 755 |
x11_screen = GDK_X11_SCREEN (screen); |
| 756 |
|
| 757 |
g_assert (x11_screen->root_window == NULL); |
| 758 |
|
| 759 |
window = x11_screen->root_window = _gdk_display_create_window (gdk_screen_get_display (screen)); |
| 760 |
|
| 761 |
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); |
| 762 |
window->impl_window = window; |
| 763 |
window->visual = gdk_screen_get_system_visual (screen); |
| 764 |
|
| 765 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 766 |
|
| 767 |
impl->xid = x11_screen->xroot_window; |
| 768 |
impl->wrapper = window; |
| 769 |
impl->window_scale = x11_screen->window_scale; |
| 770 |
|
| 771 |
window->window_type = GDK_WINDOW_ROOT; |
| 772 |
window->depth = DefaultDepthOfScreen (x11_screen->xscreen); |
| 773 |
|
| 774 |
window->x = 0; |
| 775 |
window->y = 0; |
| 776 |
window->abs_x = 0; |
| 777 |
window->abs_y = 0; |
| 778 |
impl->unscaled_width = WidthOfScreen (x11_screen->xscreen); |
| 779 |
impl->unscaled_height = HeightOfScreen (x11_screen->xscreen); |
| 780 |
window->width = WidthOfScreen (x11_screen->xscreen) / impl->window_scale; |
| 781 |
window->height = HeightOfScreen (x11_screen->xscreen) / impl->window_scale; |
| 782 |
window->viewable = TRUE; |
| 783 |
|
| 784 |
/* see init_randr_support() in gdkscreen-x11.c */ |
| 785 |
window->event_mask = GDK_STRUCTURE_MASK; |
| 786 |
|
| 787 |
_gdk_window_update_size (x11_screen->root_window); |
| 788 |
|
| 789 |
_gdk_x11_display_add_window (x11_screen->display, |
| 790 |
&x11_screen->xroot_window, |
| 791 |
x11_screen->root_window); |
| 792 |
} |
| 793 |
|
| 794 |
static void |
| 795 |
set_wm_protocols (GdkWindow *window) |
| 796 |
{ |
| 797 |
GdkDisplay *display = gdk_window_get_display (window); |
| 798 |
Atom protocols[4]; |
| 799 |
int n = 0; |
| 800 |
|
| 801 |
protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"); |
| 802 |
protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"); |
| 803 |
protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING"); |
| 804 |
|
| 805 |
#ifdef HAVE_XSYNC |
| 806 |
if (GDK_X11_DISPLAY (display)->use_sync) |
| 807 |
protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST"); |
| 808 |
#endif |
| 809 |
|
| 810 |
XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n); |
| 811 |
} |
| 812 |
|
| 813 |
static const gchar * |
| 814 |
get_default_title (void) |
| 815 |
{ |
| 816 |
const char *title; |
| 817 |
|
| 818 |
title = g_get_application_name (); |
| 819 |
if (!title) |
| 820 |
title = g_get_prgname (); |
| 821 |
if (!title) |
| 822 |
title = ""; |
| 823 |
|
| 824 |
return title; |
| 825 |
} |
| 826 |
|
| 827 |
static void |
| 828 |
check_leader_window_title (GdkDisplay *display) |
| 829 |
{ |
| 830 |
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); |
| 831 |
|
| 832 |
if (display_x11->leader_window && !display_x11->leader_window_title_set) |
| 833 |
{ |
| 834 |
set_wm_name (display, |
| 835 |
display_x11->leader_window, |
| 836 |
get_default_title ()); |
| 837 |
|
| 838 |
display_x11->leader_window_title_set = TRUE; |
| 839 |
} |
| 840 |
} |
| 841 |
|
| 842 |
static Window |
| 843 |
create_focus_window (GdkDisplay *display, |
| 844 |
XID parent) |
| 845 |
{ |
| 846 |
GdkX11Display *display_x11; |
| 847 |
GdkEventMask event_mask; |
| 848 |
Display *xdisplay; |
| 849 |
Window focus_window; |
| 850 |
XSetWindowAttributes attrs; |
| 851 |
|
| 852 |
xdisplay = GDK_DISPLAY_XDISPLAY (display); |
| 853 |
display_x11 = GDK_X11_DISPLAY (display); |
| 854 |
|
| 855 |
focus_window = XCreateWindow (xdisplay, parent, |
| 856 |
-1, -1, 1, 1, 0, |
| 857 |
0, /* depth */ |
| 858 |
InputOnly, |
| 859 |
CopyFromParent, |
| 860 |
0, &attrs); |
| 861 |
|
| 862 |
event_mask = (GDK_KEY_PRESS_MASK | |
| 863 |
GDK_KEY_RELEASE_MASK | |
| 864 |
GDK_FOCUS_CHANGE_MASK); |
| 865 |
|
| 866 |
gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source, |
| 867 |
focus_window, |
| 868 |
event_mask, 0); |
| 869 |
|
| 870 |
XMapWindow (xdisplay, focus_window); |
| 871 |
|
| 872 |
return focus_window; |
| 873 |
} |
| 874 |
|
| 875 |
static void |
| 876 |
ensure_sync_counter (GdkWindow *window) |
| 877 |
{ |
| 878 |
#ifdef HAVE_XSYNC |
| 879 |
if (!GDK_WINDOW_DESTROYED (window)) |
| 880 |
{ |
| 881 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); |
| 882 |
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window); |
| 883 |
|
| 884 |
if (toplevel && |
| 885 |
toplevel->update_counter == None && |
| 886 |
GDK_X11_DISPLAY (display)->use_sync) |
| 887 |
{ |
| 888 |
Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); |
| 889 |
XSyncValue value; |
| 890 |
Atom atom; |
| 891 |
XID counters[2]; |
| 892 |
|
| 893 |
XSyncIntToValue (&value, 0); |
| 894 |
|
| 895 |
toplevel->update_counter = XSyncCreateCounter (xdisplay, value); |
| 896 |
toplevel->extended_update_counter = XSyncCreateCounter (xdisplay, value); |
| 897 |
|
| 898 |
atom = gdk_x11_get_xatom_by_name_for_display (display, |
| 899 |
"_NET_WM_SYNC_REQUEST_COUNTER"); |
| 900 |
|
| 901 |
counters[0] = toplevel->update_counter; |
| 902 |
counters[1] = toplevel->extended_update_counter; |
| 903 |
XChangeProperty (xdisplay, GDK_WINDOW_XID (window), |
| 904 |
atom, XA_CARDINAL, |
| 905 |
32, PropModeReplace, |
| 906 |
(guchar *)counters, 2); |
| 907 |
|
| 908 |
toplevel->current_counter_value = 0; |
| 909 |
} |
| 910 |
} |
| 911 |
#endif |
| 912 |
} |
| 913 |
|
| 914 |
static void |
| 915 |
setup_toplevel_window (GdkWindow *window, |
| 916 |
GdkWindow *parent) |
| 917 |
{ |
| 918 |
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window); |
| 919 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 920 |
GdkDisplay *display = gdk_window_get_display (window); |
| 921 |
Display *xdisplay = GDK_WINDOW_XDISPLAY (window); |
| 922 |
XID xid = GDK_WINDOW_XID (window); |
| 923 |
GdkX11Screen *x11_screen = GDK_X11_SCREEN (GDK_WINDOW_SCREEN (parent)); |
| 924 |
XSizeHints size_hints; |
| 925 |
Window leader_window; |
| 926 |
|
| 927 |
set_wm_protocols (window); |
| 928 |
|
| 929 |
if (!window->input_only) |
| 930 |
{ |
| 931 |
/* The focus window is off the visible area, and serves to receive key |
| 932 |
* press events so they don't get sent to child windows. |
| 933 |
*/ |
| 934 |
toplevel->focus_window = create_focus_window (display, xid); |
| 935 |
_gdk_x11_display_add_window (x11_screen->display, |
| 936 |
&toplevel->focus_window, |
| 937 |
window); |
| 938 |
} |
| 939 |
|
| 940 |
check_leader_window_title (x11_screen->display); |
| 941 |
|
| 942 |
/* FIXME: Is there any point in doing this? Do any WM's pay |
| 943 |
* attention to PSize, and even if they do, is this the |
| 944 |
* correct value??? |
| 945 |
*/ |
| 946 |
size_hints.flags = PSize; |
| 947 |
size_hints.width = window->width * impl->window_scale; |
| 948 |
size_hints.height = window->height * impl->window_scale; |
| 949 |
|
| 950 |
XSetWMNormalHints (xdisplay, xid, &size_hints); |
| 951 |
|
| 952 |
/* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */ |
| 953 |
XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
| 954 |
|
| 955 |
if (!gdk_running_in_sandbox ()) |
| 956 |
{ |
| 957 |
/* if sandboxed, we're likely in a pid namespace and would only confuse the wm with this */ |
| 958 |
long pid = getpid (); |
| 959 |
XChangeProperty (xdisplay, xid, |
| 960 |
gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "_NET_WM_PID"), |
| 961 |
XA_CARDINAL, 32, |
| 962 |
PropModeReplace, |
| 963 |
(guchar *)&pid, 1); |
| 964 |
} |
| 965 |
|
| 966 |
leader_window = GDK_X11_DISPLAY (x11_screen->display)->leader_window; |
| 967 |
if (!leader_window) |
| 968 |
leader_window = xid; |
| 969 |
XChangeProperty (xdisplay, xid, |
| 970 |
gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "WM_CLIENT_LEADER"), |
| 971 |
XA_WINDOW, 32, PropModeReplace, |
| 972 |
(guchar *) &leader_window, 1); |
| 973 |
|
| 974 |
if (toplevel->focus_window != None) |
| 975 |
XChangeProperty (xdisplay, xid, |
| 976 |
gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "_NET_WM_USER_TIME_WINDOW"), |
| 977 |
XA_WINDOW, 32, PropModeReplace, |
| 978 |
(guchar *) &toplevel->focus_window, 1); |
| 979 |
|
| 980 |
if (!window->focus_on_map) |
| 981 |
gdk_x11_window_set_user_time (window, 0); |
| 982 |
else if (GDK_X11_DISPLAY (x11_screen->display)->user_time != 0) |
| 983 |
gdk_x11_window_set_user_time (window, GDK_X11_DISPLAY (x11_screen->display)->user_time); |
| 984 |
|
| 985 |
ensure_sync_counter (window); |
| 986 |
|
| 987 |
/* Start off in a frozen state - we'll finish this when we first paint */ |
| 988 |
gdk_x11_window_begin_frame (window, TRUE); |
| 989 |
} |
| 990 |
|
| 991 |
static void |
| 992 |
on_frame_clock_before_paint (GdkFrameClock *clock, |
| 993 |
GdkWindow *window) |
| 994 |
{ |
| 995 |
gdk_x11_window_predict_presentation_time (window); |
| 996 |
gdk_x11_window_begin_frame (window, FALSE); |
| 997 |
} |
| 998 |
|
| 999 |
static void |
| 1000 |
on_frame_clock_after_paint (GdkFrameClock *clock, |
| 1001 |
GdkWindow *window) |
| 1002 |
{ |
| 1003 |
gdk_x11_window_end_frame (window); |
| 1004 |
|
| 1005 |
} |
| 1006 |
|
| 1007 |
static void |
| 1008 |
connect_frame_clock (GdkWindow *window) |
| 1009 |
{ |
| 1010 |
GdkWindowImplX11 *impl; |
| 1011 |
|
| 1012 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1013 |
if (WINDOW_IS_TOPLEVEL (window) && !impl->frame_clock_connected) |
| 1014 |
{ |
| 1015 |
GdkFrameClock *frame_clock = gdk_window_get_frame_clock (window); |
| 1016 |
|
| 1017 |
g_signal_connect (frame_clock, "before-paint", |
| 1018 |
G_CALLBACK (on_frame_clock_before_paint), window); |
| 1019 |
g_signal_connect (frame_clock, "after-paint", |
| 1020 |
G_CALLBACK (on_frame_clock_after_paint), window); |
| 1021 |
|
| 1022 |
impl->frame_clock_connected = TRUE; |
| 1023 |
} |
| 1024 |
} |
| 1025 |
|
| 1026 |
static void |
| 1027 |
clamp_window_size (GdkWindow *window, |
| 1028 |
gint *width, |
| 1029 |
gint *height) |
| 1030 |
{ |
| 1031 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1032 |
|
| 1033 |
if (*width * impl->window_scale > 32767 || |
| 1034 |
*height * impl->window_scale > 32767) |
| 1035 |
{ |
| 1036 |
g_warning ("Native Windows wider or taller than 32767 pixels are not supported"); |
| 1037 |
|
| 1038 |
if (*width * impl->window_scale > 32767) |
| 1039 |
*width = 32767 / impl->window_scale; |
| 1040 |
if (*height * impl->window_scale > 32767) |
| 1041 |
*height = 32767 / impl->window_scale; |
| 1042 |
} |
| 1043 |
} |
| 1044 |
|
| 1045 |
void |
| 1046 |
_gdk_x11_display_create_window_impl (GdkDisplay *display, |
| 1047 |
GdkWindow *window, |
| 1048 |
GdkWindow *real_parent, |
| 1049 |
GdkScreen *screen, |
| 1050 |
GdkEventMask event_mask, |
| 1051 |
GdkWindowAttr *attributes, |
| 1052 |
gint attributes_mask) |
| 1053 |
{ |
| 1054 |
GdkWindowImplX11 *impl; |
| 1055 |
GdkX11Screen *x11_screen; |
| 1056 |
GdkX11Display *display_x11; |
| 1057 |
|
| 1058 |
Window xparent; |
| 1059 |
Visual *xvisual; |
| 1060 |
Display *xdisplay; |
| 1061 |
|
| 1062 |
XSetWindowAttributes xattributes; |
| 1063 |
long xattributes_mask; |
| 1064 |
XClassHint *class_hint; |
| 1065 |
|
| 1066 |
unsigned int class; |
| 1067 |
const char *title; |
| 1068 |
|
| 1069 |
display_x11 = GDK_X11_DISPLAY (display); |
| 1070 |
xparent = GDK_WINDOW_XID (real_parent); |
| 1071 |
x11_screen = GDK_X11_SCREEN (screen); |
| 1072 |
|
| 1073 |
impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); |
| 1074 |
window->impl = GDK_WINDOW_IMPL (impl); |
| 1075 |
impl->wrapper = GDK_WINDOW (window); |
| 1076 |
impl->window_scale = x11_screen->window_scale; |
| 1077 |
|
| 1078 |
xdisplay = x11_screen->xdisplay; |
| 1079 |
|
| 1080 |
xattributes_mask = 0; |
| 1081 |
|
| 1082 |
xvisual = gdk_x11_visual_get_xvisual (window->visual); |
| 1083 |
|
| 1084 |
if (attributes_mask & GDK_WA_NOREDIR) |
| 1085 |
{ |
| 1086 |
xattributes.override_redirect = |
| 1087 |
(attributes->override_redirect == FALSE)?False:True; |
| 1088 |
xattributes_mask |= CWOverrideRedirect; |
| 1089 |
} |
| 1090 |
else |
| 1091 |
xattributes.override_redirect = False; |
| 1092 |
|
| 1093 |
impl->override_redirect = xattributes.override_redirect; |
| 1094 |
|
| 1095 |
/* This event mask will be set near the end of the function, but to avoid some |
| 1096 |
* races, the window has to be created with this mask already. |
| 1097 |
*/ |
| 1098 |
xattributes.event_mask = StructureNotifyMask | PropertyChangeMask; |
| 1099 |
xattributes_mask |= CWEventMask; |
| 1100 |
|
| 1101 |
/* Sanity checks */ |
| 1102 |
switch (window->window_type) |
| 1103 |
{ |
| 1104 |
case GDK_WINDOW_TOPLEVEL: |
| 1105 |
case GDK_WINDOW_TEMP: |
| 1106 |
if (GDK_WINDOW_TYPE (window->parent) != GDK_WINDOW_ROOT) |
| 1107 |
{ |
| 1108 |
/* The common code warns for this case */ |
| 1109 |
xparent = GDK_SCREEN_XROOTWIN (screen); |
| 1110 |
} |
| 1111 |
} |
| 1112 |
|
| 1113 |
if (!window->input_only) |
| 1114 |
{ |
| 1115 |
class = InputOutput; |
| 1116 |
|
| 1117 |
xattributes.background_pixel = BlackPixel (xdisplay, x11_screen->screen_num); |
| 1118 |
|
| 1119 |
xattributes.border_pixel = BlackPixel (xdisplay, x11_screen->screen_num); |
| 1120 |
xattributes_mask |= CWBorderPixel | CWBackPixel; |
| 1121 |
|
| 1122 |
xattributes.bit_gravity = NorthWestGravity; |
| 1123 |
xattributes_mask |= CWBitGravity; |
| 1124 |
|
| 1125 |
xattributes.colormap = _gdk_visual_get_x11_colormap (window->visual); |
| 1126 |
xattributes_mask |= CWColormap; |
| 1127 |
|
| 1128 |
if (window->window_type == GDK_WINDOW_TEMP) |
| 1129 |
{ |
| 1130 |
xattributes.save_under = True; |
| 1131 |
xattributes.override_redirect = True; |
| 1132 |
xattributes.cursor = None; |
| 1133 |
xattributes_mask |= CWSaveUnder | CWOverrideRedirect; |
| 1134 |
|
| 1135 |
impl->override_redirect = TRUE; |
| 1136 |
} |
| 1137 |
} |
| 1138 |
else |
| 1139 |
{ |
| 1140 |
class = InputOnly; |
| 1141 |
} |
| 1142 |
|
| 1143 |
clamp_window_size (window, &window->width, &window->height); |
| 1144 |
|
| 1145 |
impl->unscaled_width = window->width * impl->window_scale; |
| 1146 |
impl->unscaled_height = window->height * impl->window_scale; |
| 1147 |
|
| 1148 |
impl->xid = XCreateWindow (xdisplay, xparent, |
| 1149 |
(window->x + window->parent->abs_x) * impl->window_scale, |
| 1150 |
(window->y + window->parent->abs_y) * impl->window_scale, |
| 1151 |
window->width * impl->window_scale, window->height * impl->window_scale, |
| 1152 |
0, window->depth, class, xvisual, |
| 1153 |
xattributes_mask, &xattributes); |
| 1154 |
|
| 1155 |
g_object_ref (window); |
| 1156 |
_gdk_x11_display_add_window (x11_screen->display, &impl->xid, window); |
| 1157 |
|
| 1158 |
switch (GDK_WINDOW_TYPE (window)) |
| 1159 |
{ |
| 1160 |
case GDK_WINDOW_TOPLEVEL: |
| 1161 |
case GDK_WINDOW_TEMP: |
| 1162 |
if (attributes_mask & GDK_WA_TITLE) |
| 1163 |
title = attributes->title; |
| 1164 |
else |
| 1165 |
title = get_default_title (); |
| 1166 |
|
| 1167 |
gdk_window_set_title (window, title); |
| 1168 |
|
| 1169 |
if (attributes_mask & GDK_WA_WMCLASS) |
| 1170 |
{ |
| 1171 |
class_hint = XAllocClassHint (); |
| 1172 |
class_hint->res_name = attributes->wmclass_name; |
| 1173 |
class_hint->res_class = attributes->wmclass_class; |
| 1174 |
XSetClassHint (xdisplay, impl->xid, class_hint); |
| 1175 |
XFree (class_hint); |
| 1176 |
} |
| 1177 |
|
| 1178 |
setup_toplevel_window (window, window->parent); |
| 1179 |
break; |
| 1180 |
|
| 1181 |
case GDK_WINDOW_CHILD: |
| 1182 |
default: |
| 1183 |
break; |
| 1184 |
} |
| 1185 |
|
| 1186 |
if (attributes_mask & GDK_WA_TYPE_HINT) |
| 1187 |
gdk_window_set_type_hint (window, attributes->type_hint); |
| 1188 |
|
| 1189 |
if (!window->input_only) |
| 1190 |
gdk_window_x11_set_background (window, NULL); |
| 1191 |
|
| 1192 |
gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source, |
| 1193 |
GDK_WINDOW_XID (window), event_mask, |
| 1194 |
StructureNotifyMask | PropertyChangeMask); |
| 1195 |
|
| 1196 |
connect_frame_clock (window); |
| 1197 |
|
| 1198 |
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD) |
| 1199 |
gdk_window_freeze_toplevel_updates (window); |
| 1200 |
} |
| 1201 |
|
| 1202 |
static GdkEventMask |
| 1203 |
x_event_mask_to_gdk_event_mask (long mask) |
| 1204 |
{ |
| 1205 |
GdkEventMask event_mask = 0; |
| 1206 |
int i; |
| 1207 |
|
| 1208 |
for (i = 0; i < _gdk_x11_event_mask_table_size; i++) |
| 1209 |
{ |
| 1210 |
if (mask & _gdk_x11_event_mask_table[i]) |
| 1211 |
event_mask |= 1 << (i + 1); |
| 1212 |
} |
| 1213 |
|
| 1214 |
return event_mask; |
| 1215 |
} |
| 1216 |
|
| 1217 |
/** |
| 1218 |
* gdk_x11_window_foreign_new_for_display: |
| 1219 |
* @display: (type GdkX11Display): the #GdkDisplay where the window handle comes from. |
| 1220 |
* @window: an Xlib Window |
| 1221 |
* |
| 1222 |
* Wraps a native window in a #GdkWindow. The function will try to |
| 1223 |
* look up the window using gdk_x11_window_lookup_for_display() first. |
| 1224 |
* If it does not find it there, it will create a new window. |
| 1225 |
* |
| 1226 |
* This may fail if the window has been destroyed. If the window |
| 1227 |
* was already known to GDK, a new reference to the existing |
| 1228 |
* #GdkWindow is returned. |
| 1229 |
* |
| 1230 |
* Returns: (transfer full): a #GdkWindow wrapper for the native |
| 1231 |
* window, or %NULL if the window has been destroyed. The wrapper |
| 1232 |
* will be newly created, if one doesn’t exist already. |
| 1233 |
* |
| 1234 |
* Since: 2.24 |
| 1235 |
*/ |
| 1236 |
GdkWindow * |
| 1237 |
gdk_x11_window_foreign_new_for_display (GdkDisplay *display, |
| 1238 |
Window window) |
| 1239 |
{ |
| 1240 |
GdkScreen *screen; |
| 1241 |
GdkWindow *win; |
| 1242 |
GdkWindowImplX11 *impl; |
| 1243 |
GdkX11Display *display_x11; |
| 1244 |
XWindowAttributes attrs; |
| 1245 |
Window root, parent; |
| 1246 |
Window *children = NULL; |
| 1247 |
guint nchildren; |
| 1248 |
gboolean result; |
| 1249 |
|
| 1250 |
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); |
| 1251 |
|
| 1252 |
display_x11 = GDK_X11_DISPLAY (display); |
| 1253 |
|
| 1254 |
if ((win = gdk_x11_window_lookup_for_display (display, window)) != NULL) |
| 1255 |
return g_object_ref (win); |
| 1256 |
|
| 1257 |
gdk_x11_display_error_trap_push (display); |
| 1258 |
result = XGetWindowAttributes (display_x11->xdisplay, window, &attrs); |
| 1259 |
if (gdk_x11_display_error_trap_pop (display) || !result) |
| 1260 |
return NULL; |
| 1261 |
|
| 1262 |
/* FIXME: This is pretty expensive. |
| 1263 |
* Maybe the caller should supply the parent |
| 1264 |
*/ |
| 1265 |
gdk_x11_display_error_trap_push (display); |
| 1266 |
result = XQueryTree (display_x11->xdisplay, window, &root, &parent, &children, &nchildren); |
| 1267 |
if (gdk_x11_display_error_trap_pop (display) || !result) |
| 1268 |
return NULL; |
| 1269 |
|
| 1270 |
if (children) |
| 1271 |
XFree (children); |
| 1272 |
|
| 1273 |
screen = _gdk_x11_display_screen_for_xrootwin (display, root); |
| 1274 |
if (screen == NULL) |
| 1275 |
return NULL; |
| 1276 |
|
| 1277 |
win = _gdk_display_create_window (display); |
| 1278 |
win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); |
| 1279 |
win->impl_window = win; |
| 1280 |
win->visual = gdk_x11_screen_lookup_visual (screen, |
| 1281 |
XVisualIDFromVisual (attrs.visual)); |
| 1282 |
|
| 1283 |
impl = GDK_WINDOW_IMPL_X11 (win->impl); |
| 1284 |
impl->wrapper = win; |
| 1285 |
impl->window_scale = GDK_X11_SCREEN (screen)->window_scale; |
| 1286 |
|
| 1287 |
win->parent = gdk_x11_window_lookup_for_display (display, parent); |
| 1288 |
|
| 1289 |
if (!win->parent || GDK_WINDOW_TYPE (win->parent) == GDK_WINDOW_FOREIGN) |
| 1290 |
win->parent = gdk_screen_get_root_window (screen); |
| 1291 |
|
| 1292 |
win->parent->children = g_list_concat (&win->children_list_node, win->parent->children); |
| 1293 |
win->parent->impl_window->native_children = |
| 1294 |
g_list_prepend (win->parent->impl_window->native_children, win); |
| 1295 |
|
| 1296 |
impl->xid = window; |
| 1297 |
|
| 1298 |
win->x = attrs.x / impl->window_scale; |
| 1299 |
win->y = attrs.y / impl->window_scale; |
| 1300 |
impl->unscaled_width = attrs.width; |
| 1301 |
impl->unscaled_height = attrs.height; |
| 1302 |
win->width = attrs.width / impl->window_scale; |
| 1303 |
win->height = attrs.height / impl->window_scale; |
| 1304 |
win->window_type = GDK_WINDOW_FOREIGN; |
| 1305 |
win->destroyed = FALSE; |
| 1306 |
|
| 1307 |
win->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); |
| 1308 |
|
| 1309 |
if (attrs.map_state == IsUnmapped) |
| 1310 |
win->state = GDK_WINDOW_STATE_WITHDRAWN; |
| 1311 |
else |
| 1312 |
win->state = 0; |
| 1313 |
win->viewable = TRUE; |
| 1314 |
|
| 1315 |
win->depth = attrs.depth; |
| 1316 |
|
| 1317 |
g_object_ref (win); |
| 1318 |
_gdk_x11_display_add_window (display, &GDK_WINDOW_XID (win), win); |
| 1319 |
|
| 1320 |
/* Update the clip region, etc */ |
| 1321 |
_gdk_window_update_size (win); |
| 1322 |
|
| 1323 |
return win; |
| 1324 |
} |
| 1325 |
|
| 1326 |
static void |
| 1327 |
gdk_toplevel_x11_free_contents (GdkDisplay *display, |
| 1328 |
GdkToplevelX11 *toplevel) |
| 1329 |
{ |
| 1330 |
if (toplevel->icon_pixmap) |
| 1331 |
{ |
| 1332 |
cairo_surface_destroy (toplevel->icon_pixmap); |
| 1333 |
toplevel->icon_pixmap = NULL; |
| 1334 |
} |
| 1335 |
if (toplevel->icon_mask) |
| 1336 |
{ |
| 1337 |
cairo_surface_destroy (toplevel->icon_mask); |
| 1338 |
toplevel->icon_mask = NULL; |
| 1339 |
} |
| 1340 |
if (toplevel->group_leader) |
| 1341 |
{ |
| 1342 |
g_object_unref (toplevel->group_leader); |
| 1343 |
toplevel->group_leader = NULL; |
| 1344 |
} |
| 1345 |
#ifdef HAVE_XSYNC |
| 1346 |
if (toplevel->update_counter != None) |
| 1347 |
{ |
| 1348 |
XSyncDestroyCounter (GDK_DISPLAY_XDISPLAY (display), |
| 1349 |
toplevel->update_counter); |
| 1350 |
XSyncDestroyCounter (GDK_DISPLAY_XDISPLAY (display), |
| 1351 |
toplevel->extended_update_counter); |
| 1352 |
toplevel->update_counter = None; |
| 1353 |
toplevel->extended_update_counter = None; |
| 1354 |
|
| 1355 |
toplevel->current_counter_value = 0; |
| 1356 |
} |
| 1357 |
#endif |
| 1358 |
} |
| 1359 |
|
| 1360 |
static void |
| 1361 |
gdk_x11_window_destroy (GdkWindow *window, |
| 1362 |
gboolean recursing, |
| 1363 |
gboolean foreign_destroy) |
| 1364 |
{ |
| 1365 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1366 |
GdkToplevelX11 *toplevel; |
| 1367 |
|
| 1368 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 1369 |
|
| 1370 |
_gdk_x11_selection_window_destroyed (window); |
| 1371 |
|
| 1372 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 1373 |
if (toplevel) |
| 1374 |
gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel); |
| 1375 |
|
| 1376 |
unhook_surface_changed (window); |
| 1377 |
|
| 1378 |
if (impl->cairo_surface) |
| 1379 |
{ |
| 1380 |
cairo_surface_finish (impl->cairo_surface); |
| 1381 |
cairo_surface_destroy (impl->cairo_surface); |
| 1382 |
impl->cairo_surface = NULL; |
| 1383 |
} |
| 1384 |
|
| 1385 |
if (!recursing && !foreign_destroy) |
| 1386 |
XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); |
| 1387 |
} |
| 1388 |
|
| 1389 |
static void |
| 1390 |
gdk_x11_window_destroy_foreign (GdkWindow *window) |
| 1391 |
{ |
| 1392 |
/* It's somebody else's window, but in our hierarchy, |
| 1393 |
* so reparent it to the root window, and then send |
| 1394 |
* it a delete event, as if we were a WM |
| 1395 |
*/ |
| 1396 |
XClientMessageEvent xclient; |
| 1397 |
GdkDisplay *display; |
| 1398 |
|
| 1399 |
display = GDK_WINDOW_DISPLAY (window); |
| 1400 |
gdk_x11_display_error_trap_push (display); |
| 1401 |
gdk_window_hide (window); |
| 1402 |
gdk_window_reparent (window, NULL, 0, 0); |
| 1403 |
|
| 1404 |
memset (&xclient, 0, sizeof (xclient)); |
| 1405 |
xclient.type = ClientMessage; |
| 1406 |
xclient.window = GDK_WINDOW_XID (window); |
| 1407 |
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS"); |
| 1408 |
xclient.format = 32; |
| 1409 |
xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"); |
| 1410 |
xclient.data.l[1] = CurrentTime; |
| 1411 |
xclient.data.l[2] = 0; |
| 1412 |
xclient.data.l[3] = 0; |
| 1413 |
xclient.data.l[4] = 0; |
| 1414 |
|
| 1415 |
XSendEvent (GDK_WINDOW_XDISPLAY (window), |
| 1416 |
GDK_WINDOW_XID (window), |
| 1417 |
False, 0, (XEvent *)&xclient); |
| 1418 |
gdk_x11_display_error_trap_pop_ignored (display); |
| 1419 |
} |
| 1420 |
|
| 1421 |
static GdkWindow * |
| 1422 |
get_root (GdkWindow *window) |
| 1423 |
{ |
| 1424 |
GdkScreen *screen = gdk_window_get_screen (window); |
| 1425 |
|
| 1426 |
return gdk_screen_get_root_window (screen); |
| 1427 |
} |
| 1428 |
|
| 1429 |
/* This function is called when the XWindow is really gone. |
| 1430 |
*/ |
| 1431 |
static void |
| 1432 |
gdk_x11_window_destroy_notify (GdkWindow *window) |
| 1433 |
{ |
| 1434 |
GdkWindowImplX11 *window_impl; |
| 1435 |
|
| 1436 |
window_impl = GDK_WINDOW_IMPL_X11 ((window)->impl); |
| 1437 |
|
| 1438 |
if (!GDK_WINDOW_DESTROYED (window)) |
| 1439 |
{ |
| 1440 |
if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN) |
| 1441 |
g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window)); |
| 1442 |
|
| 1443 |
_gdk_window_destroy (window, TRUE); |
| 1444 |
} |
| 1445 |
|
| 1446 |
_gdk_x11_display_remove_window (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window)); |
| 1447 |
if (window_impl->toplevel && window_impl->toplevel->focus_window) |
| 1448 |
_gdk_x11_display_remove_window (GDK_WINDOW_DISPLAY (window), window_impl->toplevel->focus_window); |
| 1449 |
|
| 1450 |
_gdk_x11_window_grab_check_destroy (window); |
| 1451 |
|
| 1452 |
g_object_unref (window); |
| 1453 |
} |
| 1454 |
|
| 1455 |
static GdkDragProtocol |
| 1456 |
gdk_x11_window_get_drag_protocol (GdkWindow *window, |
| 1457 |
GdkWindow **target) |
| 1458 |
{ |
| 1459 |
GdkDragProtocol protocol; |
| 1460 |
GdkDisplay *display; |
| 1461 |
guint version; |
| 1462 |
Window xid; |
| 1463 |
|
| 1464 |
display = gdk_window_get_display (window); |
| 1465 |
xid = _gdk_x11_display_get_drag_protocol (display, |
| 1466 |
GDK_WINDOW_XID (window->impl_window), |
| 1467 |
&protocol, |
| 1468 |
&version); |
| 1469 |
|
| 1470 |
if (target) |
| 1471 |
{ |
| 1472 |
if (xid != None) |
| 1473 |
*target = gdk_x11_window_foreign_new_for_display (display, xid); |
| 1474 |
else |
| 1475 |
*target = NULL; |
| 1476 |
} |
| 1477 |
|
| 1478 |
return protocol; |
| 1479 |
} |
| 1480 |
|
| 1481 |
static void |
| 1482 |
update_wm_hints (GdkWindow *window, |
| 1483 |
gboolean force) |
| 1484 |
{ |
| 1485 |
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window); |
| 1486 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); |
| 1487 |
XWMHints wm_hints; |
| 1488 |
|
| 1489 |
if (!force && |
| 1490 |
!toplevel->is_leader && |
| 1491 |
window->state & GDK_WINDOW_STATE_WITHDRAWN) |
| 1492 |
return; |
| 1493 |
|
| 1494 |
wm_hints.flags = StateHint | InputHint; |
| 1495 |
wm_hints.input = window->accept_focus ? True : False; |
| 1496 |
wm_hints.initial_state = NormalState; |
| 1497 |
|
| 1498 |
if (window->state & GDK_WINDOW_STATE_ICONIFIED) |
| 1499 |
{ |
| 1500 |
wm_hints.flags |= StateHint; |
| 1501 |
wm_hints.initial_state = IconicState; |
| 1502 |
} |
| 1503 |
|
| 1504 |
if (toplevel->icon_pixmap) |
| 1505 |
{ |
| 1506 |
wm_hints.flags |= IconPixmapHint; |
| 1507 |
wm_hints.icon_pixmap = cairo_xlib_surface_get_drawable (toplevel->icon_pixmap); |
| 1508 |
} |
| 1509 |
|
| 1510 |
if (toplevel->icon_mask) |
| 1511 |
{ |
| 1512 |
wm_hints.flags |= IconMaskHint; |
| 1513 |
wm_hints.icon_mask = cairo_xlib_surface_get_drawable (toplevel->icon_mask); |
| 1514 |
} |
| 1515 |
|
| 1516 |
wm_hints.flags |= WindowGroupHint; |
| 1517 |
if (toplevel->group_leader && !GDK_WINDOW_DESTROYED (toplevel->group_leader)) |
| 1518 |
{ |
| 1519 |
wm_hints.flags |= WindowGroupHint; |
| 1520 |
wm_hints.window_group = GDK_WINDOW_XID (toplevel->group_leader); |
| 1521 |
} |
| 1522 |
else |
| 1523 |
wm_hints.window_group = GDK_X11_DISPLAY (display)->leader_window; |
| 1524 |
|
| 1525 |
if (toplevel->urgency_hint) |
| 1526 |
wm_hints.flags |= XUrgencyHint; |
| 1527 |
|
| 1528 |
XSetWMHints (GDK_WINDOW_XDISPLAY (window), |
| 1529 |
GDK_WINDOW_XID (window), |
| 1530 |
&wm_hints); |
| 1531 |
} |
| 1532 |
|
| 1533 |
static void |
| 1534 |
set_initial_hints (GdkWindow *window) |
| 1535 |
{ |
| 1536 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); |
| 1537 |
Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); |
| 1538 |
Window xwindow = GDK_WINDOW_XID (window); |
| 1539 |
GdkToplevelX11 *toplevel; |
| 1540 |
Atom atoms[9]; |
| 1541 |
gint i; |
| 1542 |
|
| 1543 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 1544 |
|
| 1545 |
if (!toplevel) |
| 1546 |
return; |
| 1547 |
|
| 1548 |
update_wm_hints (window, TRUE); |
| 1549 |
|
| 1550 |
/* We set the spec hints regardless of whether the spec is supported, |
| 1551 |
* since it can't hurt and it's kind of expensive to check whether |
| 1552 |
* it's supported. |
| 1553 |
*/ |
| 1554 |
|
| 1555 |
i = 0; |
| 1556 |
|
| 1557 |
if (window->state & GDK_WINDOW_STATE_MAXIMIZED) |
| 1558 |
{ |
| 1559 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1560 |
"_NET_WM_STATE_MAXIMIZED_VERT"); |
| 1561 |
++i; |
| 1562 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1563 |
"_NET_WM_STATE_MAXIMIZED_HORZ"); |
| 1564 |
++i; |
| 1565 |
toplevel->have_maxhorz = toplevel->have_maxvert = TRUE; |
| 1566 |
} |
| 1567 |
|
| 1568 |
if (window->state & GDK_WINDOW_STATE_ABOVE) |
| 1569 |
{ |
| 1570 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1571 |
"_NET_WM_STATE_ABOVE"); |
| 1572 |
++i; |
| 1573 |
} |
| 1574 |
|
| 1575 |
if (window->state & GDK_WINDOW_STATE_BELOW) |
| 1576 |
{ |
| 1577 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1578 |
"_NET_WM_STATE_BELOW"); |
| 1579 |
++i; |
| 1580 |
} |
| 1581 |
|
| 1582 |
if (window->state & GDK_WINDOW_STATE_STICKY) |
| 1583 |
{ |
| 1584 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1585 |
"_NET_WM_STATE_STICKY"); |
| 1586 |
++i; |
| 1587 |
toplevel->have_sticky = TRUE; |
| 1588 |
} |
| 1589 |
|
| 1590 |
if (window->state & GDK_WINDOW_STATE_FULLSCREEN) |
| 1591 |
{ |
| 1592 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1593 |
"_NET_WM_STATE_FULLSCREEN"); |
| 1594 |
++i; |
| 1595 |
toplevel->have_fullscreen = TRUE; |
| 1596 |
} |
| 1597 |
|
| 1598 |
if (window->modal_hint) |
| 1599 |
{ |
| 1600 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1601 |
"_NET_WM_STATE_MODAL"); |
| 1602 |
++i; |
| 1603 |
} |
| 1604 |
|
| 1605 |
if (toplevel->skip_taskbar_hint) |
| 1606 |
{ |
| 1607 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1608 |
"_NET_WM_STATE_SKIP_TASKBAR"); |
| 1609 |
++i; |
| 1610 |
} |
| 1611 |
|
| 1612 |
if (toplevel->skip_pager_hint) |
| 1613 |
{ |
| 1614 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1615 |
"_NET_WM_STATE_SKIP_PAGER"); |
| 1616 |
++i; |
| 1617 |
} |
| 1618 |
|
| 1619 |
if (window->state & GDK_WINDOW_STATE_ICONIFIED) |
| 1620 |
{ |
| 1621 |
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, |
| 1622 |
"_NET_WM_STATE_HIDDEN"); |
| 1623 |
++i; |
| 1624 |
toplevel->have_hidden = TRUE; |
| 1625 |
} |
| 1626 |
|
| 1627 |
if (i > 0) |
| 1628 |
{ |
| 1629 |
XChangeProperty (xdisplay, |
| 1630 |
xwindow, |
| 1631 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"), |
| 1632 |
XA_ATOM, 32, PropModeReplace, |
| 1633 |
(guchar*) atoms, i); |
| 1634 |
} |
| 1635 |
else |
| 1636 |
{ |
| 1637 |
XDeleteProperty (xdisplay, |
| 1638 |
xwindow, |
| 1639 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE")); |
| 1640 |
} |
| 1641 |
|
| 1642 |
if (window->state & GDK_WINDOW_STATE_STICKY) |
| 1643 |
{ |
| 1644 |
atoms[0] = 0xFFFFFFFF; |
| 1645 |
XChangeProperty (xdisplay, |
| 1646 |
xwindow, |
| 1647 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"), |
| 1648 |
XA_CARDINAL, 32, PropModeReplace, |
| 1649 |
(guchar*) atoms, 1); |
| 1650 |
toplevel->on_all_desktops = TRUE; |
| 1651 |
} |
| 1652 |
else |
| 1653 |
{ |
| 1654 |
XDeleteProperty (xdisplay, |
| 1655 |
xwindow, |
| 1656 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP")); |
| 1657 |
} |
| 1658 |
|
| 1659 |
toplevel->map_serial = NextRequest (xdisplay); |
| 1660 |
} |
| 1661 |
|
| 1662 |
static void |
| 1663 |
gdk_window_x11_show (GdkWindow *window, gboolean already_mapped) |
| 1664 |
{ |
| 1665 |
GdkDisplay *display; |
| 1666 |
GdkX11Display *display_x11; |
| 1667 |
GdkToplevelX11 *toplevel; |
| 1668 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1669 |
Display *xdisplay = GDK_WINDOW_XDISPLAY (window); |
| 1670 |
Window xwindow = GDK_WINDOW_XID (window); |
| 1671 |
gboolean unset_bg; |
| 1672 |
|
| 1673 |
if (!already_mapped) |
| 1674 |
set_initial_hints (window); |
| 1675 |
|
| 1676 |
if (WINDOW_IS_TOPLEVEL (window)) |
| 1677 |
{ |
| 1678 |
display = gdk_window_get_display (window); |
| 1679 |
display_x11 = GDK_X11_DISPLAY (display); |
| 1680 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 1681 |
|
| 1682 |
if (toplevel->user_time != 0 && |
| 1683 |
display_x11->user_time != 0 && |
| 1684 |
XSERVER_TIME_IS_LATER (display_x11->user_time, toplevel->user_time)) |
| 1685 |
gdk_x11_window_set_user_time (window, display_x11->user_time); |
| 1686 |
} |
| 1687 |
|
| 1688 |
unset_bg = !window->input_only && |
| 1689 |
(window->window_type == GDK_WINDOW_CHILD || |
| 1690 |
impl->override_redirect) && |
| 1691 |
gdk_window_is_viewable (window); |
| 1692 |
|
| 1693 |
if (unset_bg) |
| 1694 |
_gdk_x11_window_tmp_unset_bg (window, TRUE); |
| 1695 |
|
| 1696 |
XMapWindow (xdisplay, xwindow); |
| 1697 |
|
| 1698 |
if (unset_bg) |
| 1699 |
_gdk_x11_window_tmp_reset_bg (window, TRUE); |
| 1700 |
|
| 1701 |
/* Fullscreen on current monitor is the default, no need to apply this mode |
| 1702 |
* when mapping a window. This also ensures that the default behavior remains |
| 1703 |
* consistent with pre-fullscreen mode implementation. |
| 1704 |
*/ |
| 1705 |
if (window->fullscreen_mode != GDK_FULLSCREEN_ON_CURRENT_MONITOR) |
| 1706 |
gdk_x11_window_apply_fullscreen_mode (window); |
| 1707 |
} |
| 1708 |
|
| 1709 |
static void |
| 1710 |
pre_unmap (GdkWindow *window) |
| 1711 |
{ |
| 1712 |
GdkWindow *start_window = NULL; |
| 1713 |
|
| 1714 |
if (window->input_only) |
| 1715 |
return; |
| 1716 |
|
| 1717 |
if (window->window_type == GDK_WINDOW_CHILD) |
| 1718 |
start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent); |
| 1719 |
else if (window->window_type == GDK_WINDOW_TEMP) |
| 1720 |
start_window = get_root (window); |
| 1721 |
|
| 1722 |
if (start_window) |
| 1723 |
_gdk_x11_window_tmp_unset_bg (start_window, TRUE); |
| 1724 |
} |
| 1725 |
|
| 1726 |
static void |
| 1727 |
post_unmap (GdkWindow *window) |
| 1728 |
{ |
| 1729 |
GdkWindow *start_window = NULL; |
| 1730 |
|
| 1731 |
if (window->input_only) |
| 1732 |
return; |
| 1733 |
|
| 1734 |
if (window->window_type == GDK_WINDOW_CHILD) |
| 1735 |
start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent); |
| 1736 |
else if (window->window_type == GDK_WINDOW_TEMP) |
| 1737 |
start_window = get_root (window); |
| 1738 |
|
| 1739 |
if (start_window) |
| 1740 |
{ |
| 1741 |
_gdk_x11_window_tmp_reset_bg (start_window, TRUE); |
| 1742 |
|
| 1743 |
if (window->window_type == GDK_WINDOW_CHILD && window->parent) |
| 1744 |
{ |
| 1745 |
GdkRectangle invalid_rect; |
| 1746 |
|
| 1747 |
gdk_window_get_position (window, &invalid_rect.x, &invalid_rect.y); |
| 1748 |
invalid_rect.width = gdk_window_get_width (window); |
| 1749 |
invalid_rect.height = gdk_window_get_height (window); |
| 1750 |
gdk_window_invalidate_rect ((GdkWindow *)window->parent, |
| 1751 |
&invalid_rect, TRUE); |
| 1752 |
} |
| 1753 |
} |
| 1754 |
} |
| 1755 |
|
| 1756 |
static void |
| 1757 |
gdk_window_x11_hide (GdkWindow *window) |
| 1758 |
{ |
| 1759 |
/* We'll get the unmap notify eventually, and handle it then, |
| 1760 |
* but checking here makes things more consistent if we are |
| 1761 |
* just doing stuff ourself. |
| 1762 |
*/ |
| 1763 |
_gdk_x11_window_grab_check_unmap (window, |
| 1764 |
NextRequest (GDK_WINDOW_XDISPLAY (window))); |
| 1765 |
|
| 1766 |
/* You can't simply unmap toplevel windows. */ |
| 1767 |
switch (window->window_type) |
| 1768 |
{ |
| 1769 |
case GDK_WINDOW_TOPLEVEL: |
| 1770 |
case GDK_WINDOW_TEMP: /* ? */ |
| 1771 |
gdk_window_withdraw (window); |
| 1772 |
return; |
| 1773 |
|
| 1774 |
case GDK_WINDOW_FOREIGN: |
| 1775 |
case GDK_WINDOW_ROOT: |
| 1776 |
case GDK_WINDOW_CHILD: |
| 1777 |
break; |
| 1778 |
} |
| 1779 |
|
| 1780 |
_gdk_window_clear_update_area (window); |
| 1781 |
|
| 1782 |
pre_unmap (window); |
| 1783 |
XUnmapWindow (GDK_WINDOW_XDISPLAY (window), |
| 1784 |
GDK_WINDOW_XID (window)); |
| 1785 |
post_unmap (window); |
| 1786 |
} |
| 1787 |
|
| 1788 |
static void |
| 1789 |
gdk_window_x11_withdraw (GdkWindow *window) |
| 1790 |
{ |
| 1791 |
if (!window->destroyed) |
| 1792 |
{ |
| 1793 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 1794 |
gdk_synthesize_window_state (window, |
| 1795 |
0, |
| 1796 |
GDK_WINDOW_STATE_WITHDRAWN); |
| 1797 |
|
| 1798 |
g_assert (!GDK_WINDOW_IS_MAPPED (window)); |
| 1799 |
|
| 1800 |
pre_unmap (window); |
| 1801 |
|
| 1802 |
XWithdrawWindow (GDK_WINDOW_XDISPLAY (window), |
| 1803 |
GDK_WINDOW_XID (window), 0); |
| 1804 |
|
| 1805 |
post_unmap (window); |
| 1806 |
} |
| 1807 |
} |
| 1808 |
|
| 1809 |
static inline void |
| 1810 |
window_x11_move (GdkWindow *window, |
| 1811 |
gint x, |
| 1812 |
gint y) |
| 1813 |
{ |
| 1814 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1815 |
|
| 1816 |
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) |
| 1817 |
{ |
| 1818 |
/* The window isn't actually damaged, but it's parent is */ |
| 1819 |
window_pre_damage (window); |
| 1820 |
_gdk_x11_window_move_resize_child (window, |
| 1821 |
x, y, |
| 1822 |
window->width, window->height); |
| 1823 |
} |
| 1824 |
else |
| 1825 |
{ |
| 1826 |
XMoveWindow (GDK_WINDOW_XDISPLAY (window), |
| 1827 |
GDK_WINDOW_XID (window), |
| 1828 |
x * impl->window_scale, y * impl->window_scale); |
| 1829 |
|
| 1830 |
if (impl->override_redirect) |
| 1831 |
{ |
| 1832 |
window->x = x; |
| 1833 |
window->y = y; |
| 1834 |
} |
| 1835 |
} |
| 1836 |
} |
| 1837 |
|
| 1838 |
static inline void |
| 1839 |
window_x11_resize (GdkWindow *window, |
| 1840 |
gint width, |
| 1841 |
gint height) |
| 1842 |
{ |
| 1843 |
if (width < 1) |
| 1844 |
width = 1; |
| 1845 |
|
| 1846 |
if (height < 1) |
| 1847 |
height = 1; |
| 1848 |
|
| 1849 |
window_pre_damage (window); |
| 1850 |
|
| 1851 |
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) |
| 1852 |
{ |
| 1853 |
_gdk_x11_window_move_resize_child (window, |
| 1854 |
window->x, window->y, |
| 1855 |
width, height); |
| 1856 |
} |
| 1857 |
else |
| 1858 |
{ |
| 1859 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1860 |
|
| 1861 |
XResizeWindow (GDK_WINDOW_XDISPLAY (window), |
| 1862 |
GDK_WINDOW_XID (window), |
| 1863 |
width * impl->window_scale, height * impl->window_scale); |
| 1864 |
|
| 1865 |
if (impl->override_redirect) |
| 1866 |
{ |
| 1867 |
impl->unscaled_width = width * impl->window_scale; |
| 1868 |
impl->unscaled_height = height * impl->window_scale; |
| 1869 |
window->width = width; |
| 1870 |
window->height = height; |
| 1871 |
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); |
| 1872 |
} |
| 1873 |
else |
| 1874 |
{ |
| 1875 |
if (width * impl->window_scale != impl->unscaled_width || height * impl->window_scale != impl->unscaled_height) |
| 1876 |
window->resize_count += 1; |
| 1877 |
} |
| 1878 |
} |
| 1879 |
} |
| 1880 |
|
| 1881 |
static inline void |
| 1882 |
window_x11_move_resize (GdkWindow *window, |
| 1883 |
gint x, |
| 1884 |
gint y, |
| 1885 |
gint width, |
| 1886 |
gint height) |
| 1887 |
{ |
| 1888 |
if (width < 1) |
| 1889 |
width = 1; |
| 1890 |
|
| 1891 |
if (height < 1) |
| 1892 |
height = 1; |
| 1893 |
|
| 1894 |
window_pre_damage (window); |
| 1895 |
|
| 1896 |
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) |
| 1897 |
{ |
| 1898 |
_gdk_x11_window_move_resize_child (window, x, y, width, height); |
| 1899 |
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); |
| 1900 |
} |
| 1901 |
else |
| 1902 |
{ |
| 1903 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1904 |
|
| 1905 |
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), |
| 1906 |
GDK_WINDOW_XID (window), |
| 1907 |
x * impl->window_scale, y * impl->window_scale, |
| 1908 |
width * impl->window_scale, height * impl->window_scale); |
| 1909 |
|
| 1910 |
if (impl->override_redirect) |
| 1911 |
{ |
| 1912 |
window->x = x; |
| 1913 |
window->y = y; |
| 1914 |
|
| 1915 |
impl->unscaled_width = width * impl->window_scale; |
| 1916 |
impl->unscaled_height = height * impl->window_scale; |
| 1917 |
window->width = width; |
| 1918 |
window->height = height; |
| 1919 |
|
| 1920 |
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); |
| 1921 |
} |
| 1922 |
else |
| 1923 |
{ |
| 1924 |
if (width * impl->window_scale != impl->unscaled_width || height * impl->window_scale != impl->unscaled_height) |
| 1925 |
window->resize_count += 1; |
| 1926 |
} |
| 1927 |
} |
| 1928 |
} |
| 1929 |
|
| 1930 |
static void |
| 1931 |
gdk_window_x11_move_resize (GdkWindow *window, |
| 1932 |
gboolean with_move, |
| 1933 |
gint x, |
| 1934 |
gint y, |
| 1935 |
gint width, |
| 1936 |
gint height) |
| 1937 |
{ |
| 1938 |
if (with_move && (width < 0 && height < 0)) |
| 1939 |
window_x11_move (window, x, y); |
| 1940 |
else |
| 1941 |
{ |
| 1942 |
clamp_window_size (window, &width, &height); |
| 1943 |
|
| 1944 |
if (with_move) |
| 1945 |
window_x11_move_resize (window, x, y, width, height); |
| 1946 |
else |
| 1947 |
window_x11_resize (window, width, height); |
| 1948 |
} |
| 1949 |
} |
| 1950 |
|
| 1951 |
static void |
| 1952 |
set_scale_recursive (GdkWindow *window, int scale) |
| 1953 |
{ |
| 1954 |
GdkWindow *child; |
| 1955 |
GList *l; |
| 1956 |
|
| 1957 |
for (l = window->children; l; l = l->next) |
| 1958 |
{ |
| 1959 |
child = l->data; |
| 1960 |
|
| 1961 |
if (child->impl != window->impl) |
| 1962 |
_gdk_x11_window_set_window_scale (child, scale); |
| 1963 |
else |
| 1964 |
set_scale_recursive (child, scale); |
| 1965 |
} |
| 1966 |
} |
| 1967 |
|
| 1968 |
void |
| 1969 |
_gdk_x11_window_set_window_scale (GdkWindow *window, |
| 1970 |
int scale) |
| 1971 |
{ |
| 1972 |
GdkWindowImplX11 *impl; |
| 1973 |
GdkToplevelX11 *toplevel; |
| 1974 |
GdkWindowHints geom_mask; |
| 1975 |
|
| 1976 |
if (window->window_type == GDK_WINDOW_OFFSCREEN) |
| 1977 |
return; |
| 1978 |
|
| 1979 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 1980 |
|
| 1981 |
impl->window_scale = scale; |
| 1982 |
if (impl->cairo_surface) |
| 1983 |
cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale); |
| 1984 |
_gdk_window_update_size (window); |
| 1985 |
|
| 1986 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 1987 |
if (toplevel && window->window_type != GDK_WINDOW_FOREIGN) |
| 1988 |
{ |
| 1989 |
/* These are affected by window scale: */ |
| 1990 |
geom_mask = toplevel->last_geometry_hints_mask & |
| 1991 |
(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC); |
| 1992 |
if (geom_mask) |
| 1993 |
gdk_window_set_geometry_hints (window, |
| 1994 |
&toplevel->last_geometry_hints, |
| 1995 |
geom_mask); |
| 1996 |
} |
| 1997 |
|
| 1998 |
if (window->window_type == GDK_WINDOW_FOREIGN) |
| 1999 |
XMoveWindow (GDK_WINDOW_XDISPLAY (window), |
| 2000 |
GDK_WINDOW_XID (window), |
| 2001 |
(window->x + window->parent->abs_x) * impl->window_scale, |
| 2002 |
(window->y + window->parent->abs_y) * impl->window_scale); |
| 2003 |
else if (WINDOW_IS_TOPLEVEL(window)) |
| 2004 |
{ |
| 2005 |
if (impl->override_redirect) |
| 2006 |
{ |
| 2007 |
impl->unscaled_width = window->width * impl->window_scale; |
| 2008 |
impl->unscaled_height = window->height * impl->window_scale; |
| 2009 |
} |
| 2010 |
|
| 2011 |
XResizeWindow (GDK_WINDOW_XDISPLAY (window), |
| 2012 |
GDK_WINDOW_XID (window), |
| 2013 |
window->width * impl->window_scale, |
| 2014 |
window->height * impl->window_scale); |
| 2015 |
} |
| 2016 |
else |
| 2017 |
{ |
| 2018 |
impl->unscaled_width = window->width * impl->window_scale; |
| 2019 |
impl->unscaled_height = window->height * impl->window_scale; |
| 2020 |
|
| 2021 |
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), |
| 2022 |
GDK_WINDOW_XID (window), |
| 2023 |
(window->x + window->parent->abs_x) * impl->window_scale, |
| 2024 |
(window->y + window->parent->abs_y) * impl->window_scale, |
| 2025 |
window->width * impl->window_scale, |
| 2026 |
window->height * impl->window_scale); |
| 2027 |
} |
| 2028 |
|
| 2029 |
gdk_window_invalidate_rect (window, NULL, TRUE); |
| 2030 |
|
| 2031 |
set_scale_recursive (window, scale); |
| 2032 |
} |
| 2033 |
|
| 2034 |
static gboolean |
| 2035 |
gdk_window_x11_reparent (GdkWindow *window, |
| 2036 |
GdkWindow *new_parent, |
| 2037 |
gint x, |
| 2038 |
gint y) |
| 2039 |
{ |
| 2040 |
GdkWindowImplX11 *impl; |
| 2041 |
|
| 2042 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 2043 |
|
| 2044 |
_gdk_x11_window_tmp_unset_bg (window, TRUE); |
| 2045 |
_gdk_x11_window_tmp_unset_parent_bg (window); |
| 2046 |
XReparentWindow (GDK_WINDOW_XDISPLAY (window), |
| 2047 |
GDK_WINDOW_XID (window), |
| 2048 |
GDK_WINDOW_XID (new_parent), |
| 2049 |
(new_parent->abs_x + x) * impl->window_scale, |
| 2050 |
(new_parent->abs_y + y) * impl->window_scale); |
| 2051 |
_gdk_x11_window_tmp_reset_parent_bg (window); |
| 2052 |
_gdk_x11_window_tmp_reset_bg (window, TRUE); |
| 2053 |
|
| 2054 |
if (WINDOW_IS_TOPLEVEL (window)) |
| 2055 |
connect_frame_clock (window); |
| 2056 |
else |
| 2057 |
/* old frame clock was disposed, our signal handlers removed */ |
| 2058 |
impl->frame_clock_connected = FALSE; |
| 2059 |
|
| 2060 |
if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN) |
| 2061 |
new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window)); |
| 2062 |
|
| 2063 |
window->parent = new_parent; |
| 2064 |
|
| 2065 |
/* Switch the window type as appropriate */ |
| 2066 |
|
| 2067 |
switch (GDK_WINDOW_TYPE (new_parent)) |
| 2068 |
{ |
| 2069 |
case GDK_WINDOW_ROOT: |
| 2070 |
case GDK_WINDOW_FOREIGN: |
| 2071 |
/* Reparenting to toplevel */ |
| 2072 |
|
| 2073 |
if (!WINDOW_IS_TOPLEVEL (window) && |
| 2074 |
GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN) |
| 2075 |
{ |
| 2076 |
/* This is also done in common code at a later stage, but we |
| 2077 |
need it in setup_toplevel, so do it here too */ |
| 2078 |
if (window->toplevel_window_type != -1) |
| 2079 |
GDK_WINDOW_TYPE (window) = window->toplevel_window_type; |
| 2080 |
else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) |
| 2081 |
GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL; |
| 2082 |
|
| 2083 |
/* Wasn't a toplevel, set up */ |
| 2084 |
setup_toplevel_window (window, new_parent); |
| 2085 |
} |
| 2086 |
|
| 2087 |
break; |
| 2088 |
|
| 2089 |
case GDK_WINDOW_TOPLEVEL: |
| 2090 |
case GDK_WINDOW_CHILD: |
| 2091 |
case GDK_WINDOW_TEMP: |
| 2092 |
if (WINDOW_IS_TOPLEVEL (window) && |
| 2093 |
impl->toplevel) |
| 2094 |
{ |
| 2095 |
if (impl->toplevel->focus_window) |
| 2096 |
{ |
| 2097 |
XDestroyWindow (GDK_WINDOW_XDISPLAY (window), impl->toplevel->focus_window); |
| 2098 |
_gdk_x11_display_remove_window (GDK_WINDOW_DISPLAY (window), impl->toplevel->focus_window); |
| 2099 |
} |
| 2100 |
|
| 2101 |
gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), |
| 2102 |
impl->toplevel); |
| 2103 |
g_free (impl->toplevel); |
| 2104 |
impl->toplevel = NULL; |
| 2105 |
} |
| 2106 |
} |
| 2107 |
|
| 2108 |
return FALSE; |
| 2109 |
} |
| 2110 |
|
| 2111 |
static void |
| 2112 |
gdk_window_x11_raise (GdkWindow *window) |
| 2113 |
{ |
| 2114 |
XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); |
| 2115 |
} |
| 2116 |
|
| 2117 |
static void |
| 2118 |
gdk_window_x11_restack_under (GdkWindow *window, |
| 2119 |
GList *native_siblings /* in requested order, first is bottom-most */) |
| 2120 |
{ |
| 2121 |
Window *windows; |
| 2122 |
int n_windows, i; |
| 2123 |
GList *l; |
| 2124 |
|
| 2125 |
n_windows = g_list_length (native_siblings) + 1; |
| 2126 |
windows = g_new (Window, n_windows); |
| 2127 |
|
| 2128 |
windows[0] = GDK_WINDOW_XID (window); |
| 2129 |
/* Reverse order, as input order is bottom-most first */ |
| 2130 |
i = n_windows - 1; |
| 2131 |
for (l = native_siblings; l != NULL; l = l->next) |
| 2132 |
windows[i--] = GDK_WINDOW_XID (l->data); |
| 2133 |
|
| 2134 |
XRestackWindows (GDK_WINDOW_XDISPLAY (window), windows, n_windows); |
| 2135 |
|
| 2136 |
g_free (windows); |
| 2137 |
} |
| 2138 |
|
| 2139 |
static void |
| 2140 |
gdk_window_x11_restack_toplevel (GdkWindow *window, |
| 2141 |
GdkWindow *sibling, |
| 2142 |
gboolean above) |
| 2143 |
{ |
| 2144 |
XWindowChanges changes; |
| 2145 |
|
| 2146 |
changes.sibling = GDK_WINDOW_XID (sibling); |
| 2147 |
changes.stack_mode = above ? Above : Below; |
| 2148 |
XReconfigureWMWindow (GDK_WINDOW_XDISPLAY (window), |
| 2149 |
GDK_WINDOW_XID (window), |
| 2150 |
gdk_x11_screen_get_number (GDK_WINDOW_SCREEN (window)), |
| 2151 |
CWStackMode | CWSibling, &changes); |
| 2152 |
} |
| 2153 |
|
| 2154 |
static void |
| 2155 |
gdk_window_x11_lower (GdkWindow *window) |
| 2156 |
{ |
| 2157 |
XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); |
| 2158 |
} |
| 2159 |
|
| 2160 |
/** |
| 2161 |
* gdk_x11_window_move_to_current_desktop: |
| 2162 |
* @window: (type GdkX11Window): a #GdkWindow |
| 2163 |
* |
| 2164 |
* Moves the window to the correct workspace when running under a |
| 2165 |
* window manager that supports multiple workspaces, as described |
| 2166 |
* in the [Extended Window Manager Hints](https://specifications.freedesktop.org/wm/latest/) specification. |
| 2167 |
* Will not do anything if the window is already on all workspaces. |
| 2168 |
* |
| 2169 |
* Since: 2.8 |
| 2170 |
*/ |
| 2171 |
void |
| 2172 |
gdk_x11_window_move_to_current_desktop (GdkWindow *window) |
| 2173 |
{ |
| 2174 |
GdkToplevelX11 *toplevel; |
| 2175 |
|
| 2176 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2177 |
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); |
| 2178 |
|
| 2179 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 2180 |
|
| 2181 |
if (toplevel->on_all_desktops) |
| 2182 |
return; |
| 2183 |
|
| 2184 |
move_to_current_desktop (window); |
| 2185 |
} |
| 2186 |
|
| 2187 |
static void |
| 2188 |
move_to_current_desktop (GdkWindow *window) |
| 2189 |
{ |
| 2190 |
guint32 desktop; |
| 2191 |
|
| 2192 |
desktop = gdk_x11_screen_get_current_desktop (GDK_WINDOW_SCREEN (window)); |
| 2193 |
gdk_x11_window_move_to_desktop (window, desktop); |
| 2194 |
} |
| 2195 |
|
| 2196 |
static guint32 |
| 2197 |
get_netwm_cardinal_property (GdkWindow *window, |
| 2198 |
const gchar *name) |
| 2199 |
{ |
| 2200 |
GdkScreen *screen = GDK_WINDOW_SCREEN (window); |
| 2201 |
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen); |
| 2202 |
GdkAtom atom; |
| 2203 |
guint32 prop = 0; |
| 2204 |
Atom type; |
| 2205 |
gint format; |
| 2206 |
gulong nitems; |
| 2207 |
gulong bytes_after; |
| 2208 |
guchar *data; |
| 2209 |
|
| 2210 |
atom = gdk_atom_intern_static_string (name); |
| 2211 |
|
| 2212 |
if (!gdk_x11_screen_supports_net_wm_hint (screen, atom)) |
| 2213 |
return 0; |
| 2214 |
|
| 2215 |
XGetWindowProperty (x11_screen->xdisplay, |
| 2216 |
GDK_WINDOW_XID (window), |
| 2217 |
gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), name), |
| 2218 |
0, G_MAXLONG, |
| 2219 |
False, XA_CARDINAL, &type, &format, &nitems, |
| 2220 |
&bytes_after, &data); |
| 2221 |
if (type == XA_CARDINAL) |
| 2222 |
{ |
| 2223 |
prop = *(gulong *)data; |
| 2224 |
XFree (data); |
| 2225 |
} |
| 2226 |
|
| 2227 |
return prop; |
| 2228 |
} |
| 2229 |
|
| 2230 |
/** |
| 2231 |
* gdk_x11_window_get_desktop: |
| 2232 |
* @window: (type GdkX11Window): a #GdkWindow |
| 2233 |
* |
| 2234 |
* Gets the number of the workspace @window is on. |
| 2235 |
* |
| 2236 |
* Returns: the current workspace of @window |
| 2237 |
* |
| 2238 |
* Since: 3.10 |
| 2239 |
*/ |
| 2240 |
guint32 |
| 2241 |
gdk_x11_window_get_desktop (GdkWindow *window) |
| 2242 |
{ |
| 2243 |
g_return_val_if_fail (GDK_IS_WINDOW (window), 0); |
| 2244 |
|
| 2245 |
return get_netwm_cardinal_property (window, "_NET_WM_DESKTOP"); |
| 2246 |
} |
| 2247 |
|
| 2248 |
/** |
| 2249 |
* gdk_x11_window_move_to_desktop: |
| 2250 |
* @window: (type GdkX11Window): a #GdkWindow |
| 2251 |
* @desktop: the number of the workspace to move the window to |
| 2252 |
* |
| 2253 |
* Moves the window to the given workspace when running unde a |
| 2254 |
* window manager that supports multiple workspaces, as described |
| 2255 |
* in the [Extended Window Manager Hints](https://specifications.freedesktop.org/wm/latest/) specification. |
| 2256 |
* |
| 2257 |
* Since: 3.10 |
| 2258 |
*/ |
| 2259 |
void |
| 2260 |
gdk_x11_window_move_to_desktop (GdkWindow *window, |
| 2261 |
guint32 desktop) |
| 2262 |
{ |
| 2263 |
GdkAtom atom; |
| 2264 |
XClientMessageEvent xclient; |
| 2265 |
|
| 2266 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2267 |
|
| 2268 |
atom = gdk_atom_intern_static_string ("_NET_WM_DESKTOP"); |
| 2269 |
if (!gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), atom)) |
| 2270 |
return; |
| 2271 |
|
| 2272 |
memset (&xclient, 0, sizeof (xclient)); |
| 2273 |
xclient.type = ClientMessage; |
| 2274 |
xclient.serial = 0; |
| 2275 |
xclient.send_event = True; |
| 2276 |
xclient.window = GDK_WINDOW_XID (window); |
| 2277 |
xclient.message_type = gdk_x11_atom_to_xatom_for_display (GDK_WINDOW_DISPLAY (window), atom); |
| 2278 |
xclient.format = 32; |
| 2279 |
|
| 2280 |
xclient.data.l[0] = desktop; |
| 2281 |
xclient.data.l[1] = 1; /* source indication */ |
| 2282 |
xclient.data.l[2] = 0; |
| 2283 |
xclient.data.l[3] = 0; |
| 2284 |
xclient.data.l[4] = 0; |
| 2285 |
|
| 2286 |
XSendEvent (GDK_WINDOW_XDISPLAY (window), |
| 2287 |
GDK_WINDOW_XROOTWIN (window), |
| 2288 |
False, |
| 2289 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 2290 |
(XEvent *)&xclient); |
| 2291 |
} |
| 2292 |
|
| 2293 |
static void |
| 2294 |
gdk_x11_window_focus (GdkWindow *window, |
| 2295 |
guint32 timestamp) |
| 2296 |
{ |
| 2297 |
GdkDisplay *display; |
| 2298 |
|
| 2299 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2300 |
|
| 2301 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2302 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2303 |
return; |
| 2304 |
|
| 2305 |
display = GDK_WINDOW_DISPLAY (window); |
| 2306 |
|
| 2307 |
if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), |
| 2308 |
gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW"))) |
| 2309 |
{ |
| 2310 |
XClientMessageEvent xclient; |
| 2311 |
|
| 2312 |
memset (&xclient, 0, sizeof (xclient)); |
| 2313 |
xclient.type = ClientMessage; |
| 2314 |
xclient.window = GDK_WINDOW_XID (window); |
| 2315 |
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, |
| 2316 |
"_NET_ACTIVE_WINDOW"); |
| 2317 |
xclient.format = 32; |
| 2318 |
xclient.data.l[0] = 1; /* requestor type; we're an app */ |
| 2319 |
xclient.data.l[1] = timestamp; |
| 2320 |
xclient.data.l[2] = None; /* currently active window */ |
| 2321 |
xclient.data.l[3] = 0; |
| 2322 |
xclient.data.l[4] = 0; |
| 2323 |
|
| 2324 |
XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False, |
| 2325 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 2326 |
(XEvent *)&xclient); |
| 2327 |
} |
| 2328 |
else |
| 2329 |
{ |
| 2330 |
XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window)); |
| 2331 |
|
| 2332 |
/* There is no way of knowing reliably whether we are viewable; |
| 2333 |
* so trap errors asynchronously around the XSetInputFocus call |
| 2334 |
*/ |
| 2335 |
gdk_x11_display_error_trap_push (display); |
| 2336 |
XSetInputFocus (GDK_DISPLAY_XDISPLAY (display), |
| 2337 |
GDK_WINDOW_XID (window), |
| 2338 |
RevertToParent, |
| 2339 |
timestamp); |
| 2340 |
gdk_x11_display_error_trap_pop_ignored (display); |
| 2341 |
} |
| 2342 |
} |
| 2343 |
|
| 2344 |
static void |
| 2345 |
gdk_x11_window_set_type_hint (GdkWindow *window, |
| 2346 |
GdkWindowTypeHint hint) |
| 2347 |
{ |
| 2348 |
GdkDisplay *display; |
| 2349 |
Atom atom; |
| 2350 |
|
| 2351 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2352 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2353 |
return; |
| 2354 |
|
| 2355 |
display = gdk_window_get_display (window); |
| 2356 |
|
| 2357 |
switch (hint) |
| 2358 |
{ |
| 2359 |
case GDK_WINDOW_TYPE_HINT_DIALOG: |
| 2360 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG"); |
| 2361 |
break; |
| 2362 |
case GDK_WINDOW_TYPE_HINT_MENU: |
| 2363 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU"); |
| 2364 |
break; |
| 2365 |
case GDK_WINDOW_TYPE_HINT_TOOLBAR: |
| 2366 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR"); |
| 2367 |
break; |
| 2368 |
case GDK_WINDOW_TYPE_HINT_UTILITY: |
| 2369 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY"); |
| 2370 |
break; |
| 2371 |
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: |
| 2372 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH"); |
| 2373 |
break; |
| 2374 |
case GDK_WINDOW_TYPE_HINT_DOCK: |
| 2375 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK"); |
| 2376 |
break; |
| 2377 |
case GDK_WINDOW_TYPE_HINT_DESKTOP: |
| 2378 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP"); |
| 2379 |
break; |
| 2380 |
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: |
| 2381 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"); |
| 2382 |
break; |
| 2383 |
case GDK_WINDOW_TYPE_HINT_POPUP_MENU: |
| 2384 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_POPUP_MENU"); |
| 2385 |
break; |
| 2386 |
case GDK_WINDOW_TYPE_HINT_TOOLTIP: |
| 2387 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLTIP"); |
| 2388 |
break; |
| 2389 |
case GDK_WINDOW_TYPE_HINT_NOTIFICATION: |
| 2390 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NOTIFICATION"); |
| 2391 |
break; |
| 2392 |
case GDK_WINDOW_TYPE_HINT_COMBO: |
| 2393 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_COMBO"); |
| 2394 |
break; |
| 2395 |
case GDK_WINDOW_TYPE_HINT_DND: |
| 2396 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DND"); |
| 2397 |
break; |
| 2398 |
default: |
| 2399 |
g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint); |
| 2400 |
/* Fall thru */ |
| 2401 |
case GDK_WINDOW_TYPE_HINT_NORMAL: |
| 2402 |
atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NORMAL"); |
| 2403 |
break; |
| 2404 |
} |
| 2405 |
|
| 2406 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 2407 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"), |
| 2408 |
XA_ATOM, 32, PropModeReplace, |
| 2409 |
(guchar *)&atom, 1); |
| 2410 |
} |
| 2411 |
|
| 2412 |
static GdkWindowTypeHint |
| 2413 |
gdk_x11_window_get_type_hint (GdkWindow *window) |
| 2414 |
{ |
| 2415 |
GdkDisplay *display; |
| 2416 |
GdkWindowTypeHint type; |
| 2417 |
Atom type_return; |
| 2418 |
gint format_return; |
| 2419 |
gulong nitems_return; |
| 2420 |
gulong bytes_after_return; |
| 2421 |
guchar *data = NULL; |
| 2422 |
|
| 2423 |
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL); |
| 2424 |
|
| 2425 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2426 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2427 |
return GDK_WINDOW_TYPE_HINT_NORMAL; |
| 2428 |
|
| 2429 |
type = GDK_WINDOW_TYPE_HINT_NORMAL; |
| 2430 |
|
| 2431 |
display = gdk_window_get_display (window); |
| 2432 |
|
| 2433 |
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 2434 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"), |
| 2435 |
0, G_MAXLONG, False, XA_ATOM, &type_return, |
| 2436 |
&format_return, &nitems_return, &bytes_after_return, |
| 2437 |
&data) == Success) |
| 2438 |
{ |
| 2439 |
if ((type_return == XA_ATOM) && (format_return == 32) && |
| 2440 |
(data) && (nitems_return == 1)) |
| 2441 |
{ |
| 2442 |
Atom atom = *(Atom*)data; |
| 2443 |
|
| 2444 |
if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG")) |
| 2445 |
type = GDK_WINDOW_TYPE_HINT_DIALOG; |
| 2446 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU")) |
| 2447 |
type = GDK_WINDOW_TYPE_HINT_MENU; |
| 2448 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR")) |
| 2449 |
type = GDK_WINDOW_TYPE_HINT_TOOLBAR; |
| 2450 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY")) |
| 2451 |
type = GDK_WINDOW_TYPE_HINT_UTILITY; |
| 2452 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH")) |
| 2453 |
type = GDK_WINDOW_TYPE_HINT_SPLASHSCREEN; |
| 2454 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK")) |
| 2455 |
type = GDK_WINDOW_TYPE_HINT_DOCK; |
| 2456 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP")) |
| 2457 |
type = GDK_WINDOW_TYPE_HINT_DESKTOP; |
| 2458 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU")) |
| 2459 |
type = GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU; |
| 2460 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_POPUP_MENU")) |
| 2461 |
type = GDK_WINDOW_TYPE_HINT_POPUP_MENU; |
| 2462 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLTIP")) |
| 2463 |
type = GDK_WINDOW_TYPE_HINT_TOOLTIP; |
| 2464 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NOTIFICATION")) |
| 2465 |
type = GDK_WINDOW_TYPE_HINT_NOTIFICATION; |
| 2466 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_COMBO")) |
| 2467 |
type = GDK_WINDOW_TYPE_HINT_COMBO; |
| 2468 |
else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DND")) |
| 2469 |
type = GDK_WINDOW_TYPE_HINT_DND; |
| 2470 |
} |
| 2471 |
|
| 2472 |
if (type_return != None && data != NULL) |
| 2473 |
XFree (data); |
| 2474 |
} |
| 2475 |
|
| 2476 |
return type; |
| 2477 |
} |
| 2478 |
|
| 2479 |
static void |
| 2480 |
gdk_wmspec_change_state (gboolean add, |
| 2481 |
GdkWindow *window, |
| 2482 |
GdkAtom state1, |
| 2483 |
GdkAtom state2) |
| 2484 |
{ |
| 2485 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); |
| 2486 |
XClientMessageEvent xclient; |
| 2487 |
|
| 2488 |
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ |
| 2489 |
#define _NET_WM_STATE_ADD 1 /* add/set property */ |
| 2490 |
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */ |
| 2491 |
|
| 2492 |
memset (&xclient, 0, sizeof (xclient)); |
| 2493 |
xclient.type = ClientMessage; |
| 2494 |
xclient.window = GDK_WINDOW_XID (window); |
| 2495 |
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"); |
| 2496 |
xclient.format = 32; |
| 2497 |
xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; |
| 2498 |
xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1); |
| 2499 |
xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2); |
| 2500 |
xclient.data.l[3] = 1; /* source indication */ |
| 2501 |
xclient.data.l[4] = 0; |
| 2502 |
|
| 2503 |
XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False, |
| 2504 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 2505 |
(XEvent *)&xclient); |
| 2506 |
} |
| 2507 |
|
| 2508 |
static void |
| 2509 |
gdk_x11_window_set_modal_hint (GdkWindow *window, |
| 2510 |
gboolean modal) |
| 2511 |
{ |
| 2512 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2513 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2514 |
return; |
| 2515 |
|
| 2516 |
window->modal_hint = modal; |
| 2517 |
|
| 2518 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2519 |
gdk_wmspec_change_state (modal, window, |
| 2520 |
gdk_atom_intern_static_string ("_NET_WM_STATE_MODAL"), |
| 2521 |
GDK_NONE); |
| 2522 |
} |
| 2523 |
|
| 2524 |
static void |
| 2525 |
gdk_x11_window_set_skip_taskbar_hint (GdkWindow *window, |
| 2526 |
gboolean skips_taskbar) |
| 2527 |
{ |
| 2528 |
GdkToplevelX11 *toplevel; |
| 2529 |
|
| 2530 |
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); |
| 2531 |
|
| 2532 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2533 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2534 |
return; |
| 2535 |
|
| 2536 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 2537 |
toplevel->skip_taskbar_hint = skips_taskbar; |
| 2538 |
|
| 2539 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2540 |
gdk_wmspec_change_state (skips_taskbar, window, |
| 2541 |
gdk_atom_intern_static_string ("_NET_WM_STATE_SKIP_TASKBAR"), |
| 2542 |
GDK_NONE); |
| 2543 |
} |
| 2544 |
|
| 2545 |
static void |
| 2546 |
gdk_x11_window_set_skip_pager_hint (GdkWindow *window, |
| 2547 |
gboolean skips_pager) |
| 2548 |
{ |
| 2549 |
GdkToplevelX11 *toplevel; |
| 2550 |
|
| 2551 |
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); |
| 2552 |
|
| 2553 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2554 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2555 |
return; |
| 2556 |
|
| 2557 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 2558 |
toplevel->skip_pager_hint = skips_pager; |
| 2559 |
|
| 2560 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2561 |
gdk_wmspec_change_state (skips_pager, window, |
| 2562 |
gdk_atom_intern_static_string ("_NET_WM_STATE_SKIP_PAGER"), |
| 2563 |
GDK_NONE); |
| 2564 |
} |
| 2565 |
|
| 2566 |
static void |
| 2567 |
gdk_x11_window_set_urgency_hint (GdkWindow *window, |
| 2568 |
gboolean urgent) |
| 2569 |
{ |
| 2570 |
GdkToplevelX11 *toplevel; |
| 2571 |
|
| 2572 |
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); |
| 2573 |
|
| 2574 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2575 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2576 |
return; |
| 2577 |
|
| 2578 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 2579 |
toplevel->urgency_hint = urgent; |
| 2580 |
|
| 2581 |
update_wm_hints (window, FALSE); |
| 2582 |
} |
| 2583 |
|
| 2584 |
static void |
| 2585 |
gdk_x11_window_set_geometry_hints (GdkWindow *window, |
| 2586 |
const GdkGeometry *geometry, |
| 2587 |
GdkWindowHints geom_mask) |
| 2588 |
{ |
| 2589 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 2590 |
XSizeHints size_hints; |
| 2591 |
GdkToplevelX11 *toplevel; |
| 2592 |
|
| 2593 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2594 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2595 |
return; |
| 2596 |
|
| 2597 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 2598 |
if (toplevel) |
| 2599 |
{ |
| 2600 |
if (geometry) |
| 2601 |
toplevel->last_geometry_hints = *geometry; |
| 2602 |
toplevel->last_geometry_hints_mask = geom_mask; |
| 2603 |
} |
| 2604 |
|
| 2605 |
size_hints.flags = 0; |
| 2606 |
|
| 2607 |
if (geom_mask & GDK_HINT_POS) |
| 2608 |
{ |
| 2609 |
size_hints.flags |= PPosition; |
| 2610 |
/* We need to initialize the following obsolete fields because KWM |
| 2611 |
* apparently uses these fields if they are non-zero. |
| 2612 |
* #@#!#!$!. |
| 2613 |
*/ |
| 2614 |
size_hints.x = 0; |
| 2615 |
size_hints.y = 0; |
| 2616 |
} |
| 2617 |
|
| 2618 |
if (geom_mask & GDK_HINT_USER_POS) |
| 2619 |
{ |
| 2620 |
size_hints.flags |= USPosition; |
| 2621 |
} |
| 2622 |
|
| 2623 |
if (geom_mask & GDK_HINT_USER_SIZE) |
| 2624 |
{ |
| 2625 |
size_hints.flags |= USSize; |
| 2626 |
} |
| 2627 |
|
| 2628 |
if (geom_mask & GDK_HINT_MIN_SIZE) |
| 2629 |
{ |
| 2630 |
size_hints.flags |= PMinSize; |
| 2631 |
size_hints.min_width = geometry->min_width * impl->window_scale; |
| 2632 |
size_hints.min_height = geometry->min_height * impl->window_scale; |
| 2633 |
} |
| 2634 |
|
| 2635 |
if (geom_mask & GDK_HINT_MAX_SIZE) |
| 2636 |
{ |
| 2637 |
size_hints.flags |= PMaxSize; |
| 2638 |
size_hints.max_width = MAX (geometry->max_width, 1) * impl->window_scale; |
| 2639 |
size_hints.max_height = MAX (geometry->max_height, 1) * impl->window_scale; |
| 2640 |
} |
| 2641 |
|
| 2642 |
if (geom_mask & GDK_HINT_BASE_SIZE) |
| 2643 |
{ |
| 2644 |
size_hints.flags |= PBaseSize; |
| 2645 |
size_hints.base_width = geometry->base_width * impl->window_scale; |
| 2646 |
size_hints.base_height = geometry->base_height * impl->window_scale; |
| 2647 |
} |
| 2648 |
|
| 2649 |
if (geom_mask & GDK_HINT_RESIZE_INC) |
| 2650 |
{ |
| 2651 |
size_hints.flags |= PResizeInc; |
| 2652 |
size_hints.width_inc = geometry->width_inc * impl->window_scale; |
| 2653 |
size_hints.height_inc = geometry->height_inc * impl->window_scale; |
| 2654 |
} |
| 2655 |
else if (impl->window_scale > 1) |
| 2656 |
{ |
| 2657 |
size_hints.flags |= PResizeInc; |
| 2658 |
size_hints.width_inc = impl->window_scale; |
| 2659 |
size_hints.height_inc = impl->window_scale; |
| 2660 |
} |
| 2661 |
|
| 2662 |
if (geom_mask & GDK_HINT_ASPECT) |
| 2663 |
{ |
| 2664 |
size_hints.flags |= PAspect; |
| 2665 |
if (geometry->min_aspect <= 1) |
| 2666 |
{ |
| 2667 |
size_hints.min_aspect.x = 65536 * geometry->min_aspect; |
| 2668 |
size_hints.min_aspect.y = 65536; |
| 2669 |
} |
| 2670 |
else |
| 2671 |
{ |
| 2672 |
size_hints.min_aspect.x = 65536; |
| 2673 |
size_hints.min_aspect.y = 65536 / geometry->min_aspect;; |
| 2674 |
} |
| 2675 |
if (geometry->max_aspect <= 1) |
| 2676 |
{ |
| 2677 |
size_hints.max_aspect.x = 65536 * geometry->max_aspect; |
| 2678 |
size_hints.max_aspect.y = 65536; |
| 2679 |
} |
| 2680 |
else |
| 2681 |
{ |
| 2682 |
size_hints.max_aspect.x = 65536; |
| 2683 |
size_hints.max_aspect.y = 65536 / geometry->max_aspect;; |
| 2684 |
} |
| 2685 |
} |
| 2686 |
|
| 2687 |
if (geom_mask & GDK_HINT_WIN_GRAVITY) |
| 2688 |
{ |
| 2689 |
size_hints.flags |= PWinGravity; |
| 2690 |
size_hints.win_gravity = geometry->win_gravity; |
| 2691 |
} |
| 2692 |
|
| 2693 |
/* FIXME: Would it be better to delete this property if |
| 2694 |
* geom_mask == 0? It would save space on the server |
| 2695 |
*/ |
| 2696 |
XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window), |
| 2697 |
GDK_WINDOW_XID (window), |
| 2698 |
&size_hints); |
| 2699 |
} |
| 2700 |
|
| 2701 |
static void |
| 2702 |
gdk_window_get_geometry_hints (GdkWindow *window, |
| 2703 |
GdkGeometry *geometry, |
| 2704 |
GdkWindowHints *geom_mask) |
| 2705 |
{ |
| 2706 |
GdkWindowImplX11 *impl; |
| 2707 |
XSizeHints *size_hints; |
| 2708 |
glong junk_supplied_mask = 0; |
| 2709 |
|
| 2710 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2711 |
g_return_if_fail (geometry != NULL); |
| 2712 |
g_return_if_fail (geom_mask != NULL); |
| 2713 |
|
| 2714 |
*geom_mask = 0; |
| 2715 |
|
| 2716 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2717 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2718 |
return; |
| 2719 |
|
| 2720 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 2721 |
|
| 2722 |
size_hints = XAllocSizeHints (); |
| 2723 |
if (!size_hints) |
| 2724 |
return; |
| 2725 |
|
| 2726 |
if (!XGetWMNormalHints (GDK_WINDOW_XDISPLAY (window), |
| 2727 |
GDK_WINDOW_XID (window), |
| 2728 |
size_hints, |
| 2729 |
&junk_supplied_mask)) |
| 2730 |
size_hints->flags = 0; |
| 2731 |
|
| 2732 |
if (size_hints->flags & PMinSize) |
| 2733 |
{ |
| 2734 |
*geom_mask |= GDK_HINT_MIN_SIZE; |
| 2735 |
geometry->min_width = size_hints->min_width / impl->window_scale; |
| 2736 |
geometry->min_height = size_hints->min_height / impl->window_scale; |
| 2737 |
} |
| 2738 |
|
| 2739 |
if (size_hints->flags & PMaxSize) |
| 2740 |
{ |
| 2741 |
*geom_mask |= GDK_HINT_MAX_SIZE; |
| 2742 |
geometry->max_width = MAX (size_hints->max_width, 1) / impl->window_scale; |
| 2743 |
geometry->max_height = MAX (size_hints->max_height, 1) / impl->window_scale; |
| 2744 |
} |
| 2745 |
|
| 2746 |
if (size_hints->flags & PResizeInc) |
| 2747 |
{ |
| 2748 |
*geom_mask |= GDK_HINT_RESIZE_INC; |
| 2749 |
geometry->width_inc = size_hints->width_inc / impl->window_scale; |
| 2750 |
geometry->height_inc = size_hints->height_inc / impl->window_scale; |
| 2751 |
} |
| 2752 |
|
| 2753 |
if (size_hints->flags & PAspect) |
| 2754 |
{ |
| 2755 |
*geom_mask |= GDK_HINT_ASPECT; |
| 2756 |
|
| 2757 |
geometry->min_aspect = (gdouble) size_hints->min_aspect.x / (gdouble) size_hints->min_aspect.y; |
| 2758 |
geometry->max_aspect = (gdouble) size_hints->max_aspect.x / (gdouble) size_hints->max_aspect.y; |
| 2759 |
} |
| 2760 |
|
| 2761 |
if (size_hints->flags & PWinGravity) |
| 2762 |
{ |
| 2763 |
*geom_mask |= GDK_HINT_WIN_GRAVITY; |
| 2764 |
geometry->win_gravity = size_hints->win_gravity; |
| 2765 |
} |
| 2766 |
|
| 2767 |
XFree (size_hints); |
| 2768 |
} |
| 2769 |
|
| 2770 |
static gboolean |
| 2771 |
utf8_is_latin1 (const gchar *str) |
| 2772 |
{ |
| 2773 |
const char *p = str; |
| 2774 |
|
| 2775 |
while (*p) |
| 2776 |
{ |
| 2777 |
gunichar ch = g_utf8_get_char (p); |
| 2778 |
|
| 2779 |
if (ch > 0xff) |
| 2780 |
return FALSE; |
| 2781 |
|
| 2782 |
p = g_utf8_next_char (p); |
| 2783 |
} |
| 2784 |
|
| 2785 |
return TRUE; |
| 2786 |
} |
| 2787 |
|
| 2788 |
/* Set the property to @utf8_str as STRING if the @utf8_str is fully |
| 2789 |
* convertable to STRING, otherwise, set it as compound text |
| 2790 |
*/ |
| 2791 |
static void |
| 2792 |
set_text_property (GdkDisplay *display, |
| 2793 |
Window xwindow, |
| 2794 |
Atom property, |
| 2795 |
const gchar *utf8_str) |
| 2796 |
{ |
| 2797 |
gchar *prop_text = NULL; |
| 2798 |
Atom prop_type; |
| 2799 |
gint prop_length; |
| 2800 |
gint prop_format; |
| 2801 |
gboolean is_compound_text; |
| 2802 |
|
| 2803 |
if (utf8_is_latin1 (utf8_str)) |
| 2804 |
{ |
| 2805 |
prop_type = XA_STRING; |
| 2806 |
prop_text = _gdk_x11_display_utf8_to_string_target (display, utf8_str); |
| 2807 |
prop_length = prop_text ? strlen (prop_text) : 0; |
| 2808 |
prop_format = 8; |
| 2809 |
is_compound_text = FALSE; |
| 2810 |
} |
| 2811 |
else |
| 2812 |
{ |
| 2813 |
GdkAtom gdk_type; |
| 2814 |
|
| 2815 |
gdk_x11_display_utf8_to_compound_text (display, |
| 2816 |
utf8_str, &gdk_type, &prop_format, |
| 2817 |
(guchar **)&prop_text, &prop_length); |
| 2818 |
prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type); |
| 2819 |
is_compound_text = TRUE; |
| 2820 |
} |
| 2821 |
|
| 2822 |
if (prop_text) |
| 2823 |
{ |
| 2824 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 2825 |
xwindow, |
| 2826 |
property, |
| 2827 |
prop_type, prop_format, |
| 2828 |
PropModeReplace, (guchar *)prop_text, |
| 2829 |
prop_length); |
| 2830 |
|
| 2831 |
if (is_compound_text) |
| 2832 |
gdk_x11_free_compound_text ((guchar *)prop_text); |
| 2833 |
else |
| 2834 |
g_free (prop_text); |
| 2835 |
} |
| 2836 |
} |
| 2837 |
|
| 2838 |
/* Set WM_NAME and _NET_WM_NAME |
| 2839 |
*/ |
| 2840 |
static void |
| 2841 |
set_wm_name (GdkDisplay *display, |
| 2842 |
Window xwindow, |
| 2843 |
const gchar *name) |
| 2844 |
{ |
| 2845 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow, |
| 2846 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_NAME"), |
| 2847 |
gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, |
| 2848 |
PropModeReplace, (guchar *)name, strlen (name)); |
| 2849 |
|
| 2850 |
set_text_property (display, xwindow, |
| 2851 |
gdk_x11_get_xatom_by_name_for_display (display, "WM_NAME"), |
| 2852 |
name); |
| 2853 |
} |
| 2854 |
|
| 2855 |
static void |
| 2856 |
gdk_x11_window_set_title (GdkWindow *window, |
| 2857 |
const gchar *title) |
| 2858 |
{ |
| 2859 |
GdkDisplay *display; |
| 2860 |
Display *xdisplay; |
| 2861 |
Window xwindow; |
| 2862 |
|
| 2863 |
g_return_if_fail (title != NULL); |
| 2864 |
|
| 2865 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2866 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2867 |
return; |
| 2868 |
|
| 2869 |
display = gdk_window_get_display (window); |
| 2870 |
xdisplay = GDK_DISPLAY_XDISPLAY (display); |
| 2871 |
xwindow = GDK_WINDOW_XID (window); |
| 2872 |
|
| 2873 |
set_wm_name (display, xwindow, title); |
| 2874 |
|
| 2875 |
if (!gdk_window_icon_name_set (window)) |
| 2876 |
{ |
| 2877 |
XChangeProperty (xdisplay, xwindow, |
| 2878 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"), |
| 2879 |
gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, |
| 2880 |
PropModeReplace, (guchar *)title, strlen (title)); |
| 2881 |
|
| 2882 |
set_text_property (display, xwindow, |
| 2883 |
gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"), |
| 2884 |
title); |
| 2885 |
} |
| 2886 |
} |
| 2887 |
|
| 2888 |
static void |
| 2889 |
gdk_x11_window_set_role (GdkWindow *window, |
| 2890 |
const gchar *role) |
| 2891 |
{ |
| 2892 |
GdkDisplay *display; |
| 2893 |
|
| 2894 |
display = gdk_window_get_display (window); |
| 2895 |
|
| 2896 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2897 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2898 |
return; |
| 2899 |
|
| 2900 |
if (role) |
| 2901 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 2902 |
gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"), |
| 2903 |
XA_STRING, 8, PropModeReplace, (guchar *)role, strlen (role)); |
| 2904 |
else |
| 2905 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 2906 |
gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE")); |
| 2907 |
} |
| 2908 |
|
| 2909 |
static void |
| 2910 |
gdk_x11_window_set_startup_id (GdkWindow *window, |
| 2911 |
const gchar *startup_id) |
| 2912 |
{ |
| 2913 |
GdkDisplay *display; |
| 2914 |
gchar *free_this = NULL; |
| 2915 |
|
| 2916 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2917 |
|
| 2918 |
display = gdk_window_get_display (window); |
| 2919 |
|
| 2920 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2921 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2922 |
return; |
| 2923 |
|
| 2924 |
if (startup_id) |
| 2925 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 2926 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"), |
| 2927 |
gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, |
| 2928 |
PropModeReplace, (unsigned char *)startup_id, strlen (startup_id)); |
| 2929 |
else |
| 2930 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 2931 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID")); |
| 2932 |
|
| 2933 |
if (startup_id == NULL) |
| 2934 |
{ |
| 2935 |
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); |
| 2936 |
|
| 2937 |
startup_id = free_this = display_x11->startup_notification_id; |
| 2938 |
display_x11->startup_notification_id = NULL; |
| 2939 |
|
| 2940 |
if (startup_id == NULL) |
| 2941 |
return; |
| 2942 |
} |
| 2943 |
|
| 2944 |
gdk_x11_display_broadcast_startup_message (display, "remove", |
| 2945 |
"ID", startup_id, |
| 2946 |
NULL); |
| 2947 |
|
| 2948 |
g_free (free_this); |
| 2949 |
} |
| 2950 |
|
| 2951 |
static void |
| 2952 |
gdk_x11_window_set_transient_for (GdkWindow *window, |
| 2953 |
GdkWindow *parent) |
| 2954 |
{ |
| 2955 |
if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent) && |
| 2956 |
WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 2957 |
XSetTransientForHint (GDK_WINDOW_XDISPLAY (window), |
| 2958 |
GDK_WINDOW_XID (window), |
| 2959 |
GDK_WINDOW_XID (parent)); |
| 2960 |
} |
| 2961 |
|
| 2962 |
static gboolean |
| 2963 |
gdk_window_x11_set_back_color (GdkWindow *window, |
| 2964 |
double red, |
| 2965 |
double green, |
| 2966 |
double blue, |
| 2967 |
double alpha) |
| 2968 |
{ |
| 2969 |
GdkVisual *visual = gdk_window_get_visual (window); |
| 2970 |
|
| 2971 |
/* I suppose we could handle these, but that'd require fiddling with |
| 2972 |
* xrender formats... */ |
| 2973 |
if (alpha != 1.0) |
| 2974 |
return FALSE; |
| 2975 |
|
| 2976 |
switch (visual->type) |
| 2977 |
{ |
| 2978 |
case GDK_VISUAL_DIRECT_COLOR: |
| 2979 |
case GDK_VISUAL_TRUE_COLOR: |
| 2980 |
{ |
| 2981 |
/* If bits not used for color are used for something other than padding, |
| 2982 |
* it's likely alpha, so we set them to 1s. |
| 2983 |
*/ |
| 2984 |
guint padding, pixel; |
| 2985 |
gint red_prec, red_shift, green_prec, green_shift, blue_prec, blue_shift; |
| 2986 |
|
| 2987 |
/* Shifting by >= width-of-type isn't defined in C */ |
| 2988 |
if (visual->depth >= 32) |
| 2989 |
padding = 0; |
| 2990 |
else |
| 2991 |
padding = ((~(guint32)0)) << visual->depth; |
| 2992 |
|
| 2993 |
pixel = ~ (visual->red_mask | visual->green_mask | visual->blue_mask | padding); |
| 2994 |
|
| 2995 |
gdk_visual_get_red_pixel_details (visual, NULL, &red_shift, &red_prec); |
| 2996 |
gdk_visual_get_green_pixel_details (visual, NULL, &green_shift, &green_prec); |
| 2997 |
gdk_visual_get_blue_pixel_details (visual, NULL, &blue_shift, &blue_prec); |
| 2998 |
|
| 2999 |
pixel += (((int) (red * ((1 << red_prec ) - 1))) << red_shift ) + |
| 3000 |
(((int) (green * ((1 << green_prec) - 1))) << green_shift) + |
| 3001 |
(((int) (blue * ((1 << blue_prec ) - 1))) << blue_shift ); |
| 3002 |
|
| 3003 |
XSetWindowBackground (GDK_WINDOW_XDISPLAY (window), |
| 3004 |
GDK_WINDOW_XID (window), pixel); |
| 3005 |
} |
| 3006 |
return TRUE; |
| 3007 |
|
| 3008 |
/* These require fiddling with the colormap, and as they're essentially unused |
| 3009 |
* we're just gonna skip them for now. |
| 3010 |
*/ |
| 3011 |
case GDK_VISUAL_PSEUDO_COLOR: |
| 3012 |
case GDK_VISUAL_GRAYSCALE: |
| 3013 |
case GDK_VISUAL_STATIC_GRAY: |
| 3014 |
case GDK_VISUAL_STATIC_COLOR: |
| 3015 |
default: |
| 3016 |
break; |
| 3017 |
} |
| 3018 |
|
| 3019 |
return FALSE; |
| 3020 |
} |
| 3021 |
|
| 3022 |
static gboolean |
| 3023 |
matrix_is_identity (cairo_matrix_t *matrix) |
| 3024 |
{ |
| 3025 |
return matrix->xx == 1.0 && matrix->yy == 1.0 && |
| 3026 |
matrix->yx == 0.0 && matrix->xy == 0.0 && |
| 3027 |
matrix->x0 == 0.0 && matrix->y0 == 0.0; |
| 3028 |
} |
| 3029 |
|
| 3030 |
static void |
| 3031 |
gdk_window_x11_set_background (GdkWindow *window, |
| 3032 |
cairo_pattern_t *pattern) |
| 3033 |
{ |
| 3034 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3035 |
double r, g, b, a; |
| 3036 |
cairo_surface_t *surface; |
| 3037 |
cairo_matrix_t matrix; |
| 3038 |
cairo_pattern_t *parent_relative_pattern; |
| 3039 |
|
| 3040 |
if (GDK_WINDOW_DESTROYED (window)) |
| 3041 |
return; |
| 3042 |
|
| 3043 |
if (pattern == NULL) |
| 3044 |
{ |
| 3045 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 3046 |
GDK_WINDOW_XID (window), None); |
| 3047 |
return; |
| 3048 |
} |
| 3049 |
|
| 3050 |
G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
| 3051 |
parent_relative_pattern = gdk_x11_get_parent_relative_pattern (); |
| 3052 |
G_GNUC_END_IGNORE_DEPRECATIONS |
| 3053 |
|
| 3054 |
if (pattern == parent_relative_pattern) |
| 3055 |
{ |
| 3056 |
Window xroot, xparent, *xchildren; |
| 3057 |
guint nxchildren, xparent_depth; |
| 3058 |
XWindowAttributes xattrs; |
| 3059 |
|
| 3060 |
if (!XQueryTree (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), |
| 3061 |
&xroot, &xparent, &xchildren, &nxchildren)) |
| 3062 |
{ |
| 3063 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 3064 |
GDK_WINDOW_XID (window), None); |
| 3065 |
return; |
| 3066 |
} |
| 3067 |
|
| 3068 |
if (xchildren) |
| 3069 |
XFree (xchildren); |
| 3070 |
|
| 3071 |
if (xparent) { |
| 3072 |
XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), xparent, &xattrs); |
| 3073 |
xparent_depth = xattrs.depth; |
| 3074 |
} |
| 3075 |
|
| 3076 |
/* X throws BadMatch if the parent has a different depth when |
| 3077 |
* using ParentRelative */ |
| 3078 |
if (xparent && window->depth == xparent_depth && |
| 3079 |
cairo_pattern_status (pattern) == CAIRO_STATUS_SUCCESS) |
| 3080 |
{ |
| 3081 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 3082 |
GDK_WINDOW_XID (window), ParentRelative); |
| 3083 |
return; |
| 3084 |
} |
| 3085 |
else |
| 3086 |
{ |
| 3087 |
g_warning ("Can't set ParentRelative background for window %#lx, depth of parent doesn't match", |
| 3088 |
GDK_WINDOW_XID (window)); |
| 3089 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 3090 |
GDK_WINDOW_XID (window), None); |
| 3091 |
return; |
| 3092 |
} |
| 3093 |
} |
| 3094 |
|
| 3095 |
switch (cairo_pattern_get_type (pattern)) |
| 3096 |
{ |
| 3097 |
case CAIRO_PATTERN_TYPE_SOLID: |
| 3098 |
cairo_pattern_get_rgba (pattern, &r, &g, &b, &a); |
| 3099 |
if (gdk_window_x11_set_back_color (window, r, g, b, a)) |
| 3100 |
return; |
| 3101 |
break; |
| 3102 |
case CAIRO_PATTERN_TYPE_SURFACE: |
| 3103 |
cairo_pattern_get_matrix (pattern, &matrix); |
| 3104 |
if (cairo_pattern_get_surface (pattern, &surface) == CAIRO_STATUS_SUCCESS && |
| 3105 |
matrix_is_identity (&matrix) && |
| 3106 |
cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB && |
| 3107 |
cairo_xlib_surface_get_visual (surface) == GDK_VISUAL_XVISUAL (gdk_window_get_visual ((window))) && |
| 3108 |
cairo_xlib_surface_get_display (surface) == GDK_WINDOW_XDISPLAY (window)) |
| 3109 |
{ |
| 3110 |
double x, y, sx, sy; |
| 3111 |
|
| 3112 |
cairo_surface_get_device_offset (surface, &x, &y); |
| 3113 |
sx = sy = 1.; |
| 3114 |
cairo_surface_get_device_scale (surface, &sx, &sy); |
| 3115 |
/* XXX: This still bombs for non-pixmaps, but there's no way to |
| 3116 |
* detect we're not a pixmap in Cairo... */ |
| 3117 |
if (x == 0.0 && y == 0.0 && |
| 3118 |
sx == impl->window_scale && sy == impl->window_scale) |
| 3119 |
{ |
| 3120 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 3121 |
GDK_WINDOW_XID (window), |
| 3122 |
cairo_xlib_surface_get_drawable (surface)); |
| 3123 |
return; |
| 3124 |
} |
| 3125 |
} |
| 3126 |
/* fall through */ |
| 3127 |
case CAIRO_PATTERN_TYPE_LINEAR: |
| 3128 |
case CAIRO_PATTERN_TYPE_RADIAL: |
| 3129 |
default: |
| 3130 |
/* fallback: just use black */ |
| 3131 |
break; |
| 3132 |
} |
| 3133 |
|
| 3134 |
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), |
| 3135 |
GDK_WINDOW_XID (window), None); |
| 3136 |
} |
| 3137 |
|
| 3138 |
static void |
| 3139 |
gdk_window_x11_set_device_cursor (GdkWindow *window, |
| 3140 |
GdkDevice *device, |
| 3141 |
GdkCursor *cursor) |
| 3142 |
{ |
| 3143 |
GdkWindowImplX11 *impl; |
| 3144 |
|
| 3145 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 3146 |
g_return_if_fail (GDK_IS_DEVICE (device)); |
| 3147 |
|
| 3148 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3149 |
|
| 3150 |
if (!cursor) |
| 3151 |
g_hash_table_remove (impl->device_cursor, device); |
| 3152 |
else |
| 3153 |
{ |
| 3154 |
_gdk_x11_cursor_update_theme (cursor); |
| 3155 |
g_hash_table_replace (impl->device_cursor, |
| 3156 |
device, g_object_ref (cursor)); |
| 3157 |
} |
| 3158 |
|
| 3159 |
if (!GDK_WINDOW_DESTROYED (window)) |
| 3160 |
GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor); |
| 3161 |
} |
| 3162 |
|
| 3163 |
GdkCursor * |
| 3164 |
_gdk_x11_window_get_cursor (GdkWindow *window) |
| 3165 |
{ |
| 3166 |
GdkWindowImplX11 *impl; |
| 3167 |
|
| 3168 |
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); |
| 3169 |
|
| 3170 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3171 |
|
| 3172 |
return impl->cursor; |
| 3173 |
} |
| 3174 |
|
| 3175 |
static void |
| 3176 |
gdk_window_x11_get_geometry (GdkWindow *window, |
| 3177 |
gint *x, |
| 3178 |
gint *y, |
| 3179 |
gint *width, |
| 3180 |
gint *height) |
| 3181 |
{ |
| 3182 |
GdkWindowImplX11 *impl; |
| 3183 |
Window root; |
| 3184 |
gint tx; |
| 3185 |
gint ty; |
| 3186 |
guint twidth; |
| 3187 |
guint theight; |
| 3188 |
guint tborder_width; |
| 3189 |
guint tdepth; |
| 3190 |
|
| 3191 |
if (!GDK_WINDOW_DESTROYED (window)) |
| 3192 |
{ |
| 3193 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3194 |
|
| 3195 |
XGetGeometry (GDK_WINDOW_XDISPLAY (window), |
| 3196 |
GDK_WINDOW_XID (window), |
| 3197 |
&root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth); |
| 3198 |
|
| 3199 |
if (x) |
| 3200 |
*x = (tx + tborder_width) / impl->window_scale; |
| 3201 |
if (y) |
| 3202 |
*y = (ty + tborder_width) / impl->window_scale; |
| 3203 |
if (width) |
| 3204 |
*width = twidth / impl->window_scale; |
| 3205 |
if (height) |
| 3206 |
*height = theight / impl->window_scale; |
| 3207 |
} |
| 3208 |
} |
| 3209 |
|
| 3210 |
static void |
| 3211 |
gdk_window_x11_get_root_coords (GdkWindow *window, |
| 3212 |
gint x, |
| 3213 |
gint y, |
| 3214 |
gint *root_x, |
| 3215 |
gint *root_y) |
| 3216 |
{ |
| 3217 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3218 |
Window child; |
| 3219 |
gint tx; |
| 3220 |
gint ty; |
| 3221 |
|
| 3222 |
XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window), |
| 3223 |
GDK_WINDOW_XID (window), |
| 3224 |
GDK_WINDOW_XROOTWIN (window), |
| 3225 |
x * impl->window_scale, y * impl->window_scale, &tx, &ty, |
| 3226 |
&child); |
| 3227 |
|
| 3228 |
if (root_x) |
| 3229 |
*root_x = tx / impl->window_scale; |
| 3230 |
if (root_y) |
| 3231 |
*root_y = ty / impl->window_scale; |
| 3232 |
} |
| 3233 |
|
| 3234 |
static void |
| 3235 |
gdk_x11_window_get_frame_extents (GdkWindow *window, |
| 3236 |
GdkRectangle *rect) |
| 3237 |
{ |
| 3238 |
GdkDisplay *display; |
| 3239 |
GdkWindowImplX11 *impl; |
| 3240 |
Window xwindow; |
| 3241 |
Window xparent; |
| 3242 |
Window root; |
| 3243 |
Window child; |
| 3244 |
Window *children; |
| 3245 |
guchar *data; |
| 3246 |
Window *vroots; |
| 3247 |
Atom type_return; |
| 3248 |
guint nchildren; |
| 3249 |
guint nvroots; |
| 3250 |
gulong nitems_return; |
| 3251 |
gulong bytes_after_return; |
| 3252 |
gint format_return; |
| 3253 |
gint i; |
| 3254 |
guint ww, wh, wb, wd; |
| 3255 |
gint wx, wy; |
| 3256 |
gboolean got_frame_extents = FALSE; |
| 3257 |
|
| 3258 |
g_return_if_fail (rect != NULL); |
| 3259 |
|
| 3260 |
rect->x = 0; |
| 3261 |
rect->y = 0; |
| 3262 |
rect->width = 1; |
| 3263 |
rect->height = 1; |
| 3264 |
|
| 3265 |
while (window->parent && (window->parent)->parent) |
| 3266 |
window = window->parent; |
| 3267 |
|
| 3268 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3269 |
|
| 3270 |
/* Refine our fallback answer a bit using local information */ |
| 3271 |
rect->x = window->x; |
| 3272 |
rect->y = window->y; |
| 3273 |
rect->width = window->width; |
| 3274 |
rect->height = window->height; |
| 3275 |
|
| 3276 |
if (GDK_WINDOW_DESTROYED (window) || impl->override_redirect) |
| 3277 |
return; |
| 3278 |
|
| 3279 |
rect->x *= impl->window_scale; |
| 3280 |
rect->y *= impl->window_scale; |
| 3281 |
rect->width *= impl->window_scale; |
| 3282 |
rect->height *= impl->window_scale; |
| 3283 |
|
| 3284 |
nvroots = 0; |
| 3285 |
vroots = NULL; |
| 3286 |
|
| 3287 |
display = gdk_window_get_display (window); |
| 3288 |
|
| 3289 |
gdk_x11_display_error_trap_push (display); |
| 3290 |
|
| 3291 |
xwindow = GDK_WINDOW_XID (window); |
| 3292 |
|
| 3293 |
/* first try: use _NET_FRAME_EXTENTS */ |
| 3294 |
if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), |
| 3295 |
gdk_atom_intern_static_string ("_NET_FRAME_EXTENTS")) && |
| 3296 |
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xwindow, |
| 3297 |
gdk_x11_get_xatom_by_name_for_display (display, |
| 3298 |
"_NET_FRAME_EXTENTS"), |
| 3299 |
0, G_MAXLONG, False, XA_CARDINAL, &type_return, |
| 3300 |
&format_return, &nitems_return, &bytes_after_return, |
| 3301 |
&data) |
| 3302 |
== Success) |
| 3303 |
{ |
| 3304 |
if ((type_return == XA_CARDINAL) && (format_return == 32) && |
| 3305 |
(nitems_return == 4) && (data)) |
| 3306 |
{ |
| 3307 |
gulong *ldata = (gulong *) data; |
| 3308 |
got_frame_extents = TRUE; |
| 3309 |
|
| 3310 |
/* try to get the real client window geometry */ |
| 3311 |
if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow, |
| 3312 |
&root, &wx, &wy, &ww, &wh, &wb, &wd) && |
| 3313 |
XTranslateCoordinates (GDK_DISPLAY_XDISPLAY (display), |
| 3314 |
xwindow, root, 0, 0, &wx, &wy, &child)) |
| 3315 |
{ |
| 3316 |
rect->x = wx; |
| 3317 |
rect->y = wy; |
| 3318 |
rect->width = ww + wb * 2; |
| 3319 |
rect->height = wh + wb * 2; |
| 3320 |
} |
| 3321 |
|
| 3322 |
/* _NET_FRAME_EXTENTS format is left, right, top, bottom */ |
| 3323 |
rect->x -= ldata[0]; |
| 3324 |
rect->y -= ldata[2]; |
| 3325 |
rect->width += ldata[0] + ldata[1]; |
| 3326 |
rect->height += ldata[2] + ldata[3]; |
| 3327 |
} |
| 3328 |
|
| 3329 |
if (data) |
| 3330 |
XFree (data); |
| 3331 |
} |
| 3332 |
|
| 3333 |
if (got_frame_extents) |
| 3334 |
goto out; |
| 3335 |
|
| 3336 |
/* no frame extents property available, which means we either have a WM that |
| 3337 |
is not EWMH compliant or is broken - try fallback and walk up the window |
| 3338 |
tree to get our window's parent which hopefully is the window frame */ |
| 3339 |
|
| 3340 |
/* use NETWM_VIRTUAL_ROOTS if available */ |
| 3341 |
root = GDK_WINDOW_XROOTWIN (window); |
| 3342 |
|
| 3343 |
if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), |
| 3344 |
gdk_atom_intern_static_string ("_NET_VIRTUAL_ROOTS")) && |
| 3345 |
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), root, |
| 3346 |
gdk_x11_get_xatom_by_name_for_display (display, |
| 3347 |
"_NET_VIRTUAL_ROOTS"), |
| 3348 |
0, G_MAXLONG, False, XA_WINDOW, &type_return, |
| 3349 |
&format_return, &nitems_return, &bytes_after_return, |
| 3350 |
&data) |
| 3351 |
== Success) |
| 3352 |
{ |
| 3353 |
if ((type_return == XA_WINDOW) && (format_return == 32) && (data)) |
| 3354 |
{ |
| 3355 |
nvroots = nitems_return; |
| 3356 |
vroots = (Window *)data; |
| 3357 |
} |
| 3358 |
} |
| 3359 |
|
| 3360 |
xparent = GDK_WINDOW_XID (window); |
| 3361 |
|
| 3362 |
do |
| 3363 |
{ |
| 3364 |
xwindow = xparent; |
| 3365 |
|
| 3366 |
if (!XQueryTree (GDK_DISPLAY_XDISPLAY (display), xwindow, |
| 3367 |
&root, &xparent, |
| 3368 |
&children, &nchildren)) |
| 3369 |
goto out; |
| 3370 |
|
| 3371 |
if (children) |
| 3372 |
XFree (children); |
| 3373 |
|
| 3374 |
/* check virtual roots */ |
| 3375 |
for (i = 0; i < nvroots; i++) |
| 3376 |
{ |
| 3377 |
if (xparent == vroots[i]) |
| 3378 |
{ |
| 3379 |
root = xparent; |
| 3380 |
break; |
| 3381 |
} |
| 3382 |
} |
| 3383 |
} |
| 3384 |
while (xparent != root); |
| 3385 |
|
| 3386 |
if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow, |
| 3387 |
&root, &wx, &wy, &ww, &wh, &wb, &wd)) |
| 3388 |
{ |
| 3389 |
rect->x = wx; |
| 3390 |
rect->y = wy; |
| 3391 |
rect->width = ww + wb * 2; |
| 3392 |
rect->height = wh + wb * 2; |
| 3393 |
} |
| 3394 |
|
| 3395 |
out: |
| 3396 |
if (vroots) |
| 3397 |
XFree (vroots); |
| 3398 |
|
| 3399 |
/* Here we extend the size to include the extra pixels if we round x/y down |
| 3400 |
as well as round the size up when we divide by scale so that the returned |
| 3401 |
size is guaranteed to cover the real pixels, but it may overshoot a bit |
| 3402 |
in case the window is not positioned/sized according to the scale */ |
| 3403 |
rect->width = (rect->width + rect->x % impl->window_scale + impl->window_scale - 1) / impl->window_scale; |
| 3404 |
rect->height = (rect->height + rect->y % impl->window_scale + impl->window_scale - 1) / impl->window_scale; |
| 3405 |
rect->x = rect->x / impl->window_scale; |
| 3406 |
rect->y = rect->y / impl->window_scale; |
| 3407 |
gdk_x11_display_error_trap_pop_ignored (display); |
| 3408 |
} |
| 3409 |
|
| 3410 |
static gboolean |
| 3411 |
gdk_window_x11_get_device_state (GdkWindow *window, |
| 3412 |
GdkDevice *device, |
| 3413 |
gdouble *x, |
| 3414 |
gdouble *y, |
| 3415 |
GdkModifierType *mask) |
| 3416 |
{ |
| 3417 |
GdkWindow *child; |
| 3418 |
|
| 3419 |
if (GDK_WINDOW_DESTROYED (window)) |
| 3420 |
return FALSE; |
| 3421 |
|
| 3422 |
/*HIDPI: handle coords here?*/ |
| 3423 |
GDK_DEVICE_GET_CLASS (device)->query_state (device, window, |
| 3424 |
NULL, &child, |
| 3425 |
NULL, NULL, |
| 3426 |
x, y, mask); |
| 3427 |
return child != NULL; |
| 3428 |
} |
| 3429 |
|
| 3430 |
static GdkEventMask |
| 3431 |
gdk_window_x11_get_events (GdkWindow *window) |
| 3432 |
{ |
| 3433 |
XWindowAttributes attrs; |
| 3434 |
GdkEventMask event_mask; |
| 3435 |
GdkEventMask filtered; |
| 3436 |
|
| 3437 |
if (GDK_WINDOW_DESTROYED (window)) |
| 3438 |
return 0; |
| 3439 |
else |
| 3440 |
{ |
| 3441 |
XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), |
| 3442 |
GDK_WINDOW_XID (window), |
| 3443 |
&attrs); |
| 3444 |
event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); |
| 3445 |
/* if property change was filtered out before, keep it filtered out */ |
| 3446 |
filtered = GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK; |
| 3447 |
window->event_mask = event_mask & ((window->event_mask & filtered) | ~filtered); |
| 3448 |
|
| 3449 |
return event_mask; |
| 3450 |
} |
| 3451 |
} |
| 3452 |
static void |
| 3453 |
gdk_window_x11_set_events (GdkWindow *window, |
| 3454 |
GdkEventMask event_mask) |
| 3455 |
{ |
| 3456 |
long xevent_mask = 0; |
| 3457 |
|
| 3458 |
if (!GDK_WINDOW_DESTROYED (window)) |
| 3459 |
{ |
| 3460 |
GdkX11Display *display_x11; |
| 3461 |
|
| 3462 |
if (GDK_WINDOW_XID (window) != GDK_WINDOW_XROOTWIN (window)) |
| 3463 |
xevent_mask = StructureNotifyMask | PropertyChangeMask; |
| 3464 |
|
| 3465 |
display_x11 = GDK_X11_DISPLAY (gdk_window_get_display (window)); |
| 3466 |
gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source, |
| 3467 |
GDK_WINDOW_XID (window), event_mask, |
| 3468 |
xevent_mask); |
| 3469 |
} |
| 3470 |
} |
| 3471 |
|
| 3472 |
static inline void |
| 3473 |
do_shape_combine_region (GdkWindow *window, |
| 3474 |
const cairo_region_t *shape_region, |
| 3475 |
gint offset_x, |
| 3476 |
gint offset_y, |
| 3477 |
gint shape) |
| 3478 |
{ |
| 3479 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3480 |
|
| 3481 |
if (GDK_WINDOW_DESTROYED (window)) |
| 3482 |
return; |
| 3483 |
|
| 3484 |
if (shape_region == NULL) |
| 3485 |
{ |
| 3486 |
/* Use NULL mask to unset the shape */ |
| 3487 |
if (shape == ShapeBounding |
| 3488 |
? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)) |
| 3489 |
: gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window))) |
| 3490 |
{ |
| 3491 |
if (shape == ShapeBounding) |
| 3492 |
{ |
| 3493 |
_gdk_x11_window_tmp_unset_parent_bg (window); |
| 3494 |
_gdk_x11_window_tmp_unset_bg (window, TRUE); |
| 3495 |
} |
| 3496 |
XShapeCombineMask (GDK_WINDOW_XDISPLAY (window), |
| 3497 |
GDK_WINDOW_XID (window), |
| 3498 |
shape, |
| 3499 |
0, 0, |
| 3500 |
None, |
| 3501 |
ShapeSet); |
| 3502 |
if (shape == ShapeBounding) |
| 3503 |
{ |
| 3504 |
_gdk_x11_window_tmp_reset_parent_bg (window); |
| 3505 |
_gdk_x11_window_tmp_reset_bg (window, TRUE); |
| 3506 |
} |
| 3507 |
} |
| 3508 |
return; |
| 3509 |
} |
| 3510 |
|
| 3511 |
if (shape == ShapeBounding |
| 3512 |
? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)) |
| 3513 |
: gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window))) |
| 3514 |
{ |
| 3515 |
gint n_rects = 0; |
| 3516 |
XRectangle *xrects = NULL; |
| 3517 |
|
| 3518 |
_gdk_x11_region_get_xrectangles (shape_region, |
| 3519 |
0, 0, impl->window_scale, |
| 3520 |
&xrects, &n_rects); |
| 3521 |
|
| 3522 |
if (shape == ShapeBounding) |
| 3523 |
{ |
| 3524 |
_gdk_x11_window_tmp_unset_parent_bg (window); |
| 3525 |
_gdk_x11_window_tmp_unset_bg (window, TRUE); |
| 3526 |
} |
| 3527 |
XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window), |
| 3528 |
GDK_WINDOW_XID (window), |
| 3529 |
shape, |
| 3530 |
offset_x * impl->window_scale, |
| 3531 |
offset_y * impl->window_scale, |
| 3532 |
xrects, n_rects, |
| 3533 |
ShapeSet, |
| 3534 |
YXBanded); |
| 3535 |
|
| 3536 |
if (shape == ShapeBounding) |
| 3537 |
{ |
| 3538 |
_gdk_x11_window_tmp_reset_parent_bg (window); |
| 3539 |
_gdk_x11_window_tmp_reset_bg (window, TRUE); |
| 3540 |
} |
| 3541 |
|
| 3542 |
g_free (xrects); |
| 3543 |
} |
| 3544 |
} |
| 3545 |
|
| 3546 |
static void |
| 3547 |
gdk_window_x11_shape_combine_region (GdkWindow *window, |
| 3548 |
const cairo_region_t *shape_region, |
| 3549 |
gint offset_x, |
| 3550 |
gint offset_y) |
| 3551 |
{ |
| 3552 |
do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeBounding); |
| 3553 |
} |
| 3554 |
|
| 3555 |
static void |
| 3556 |
gdk_window_x11_input_shape_combine_region (GdkWindow *window, |
| 3557 |
const cairo_region_t *shape_region, |
| 3558 |
gint offset_x, |
| 3559 |
gint offset_y) |
| 3560 |
{ |
| 3561 |
#ifdef ShapeInput |
| 3562 |
do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeInput); |
| 3563 |
#endif |
| 3564 |
} |
| 3565 |
|
| 3566 |
|
| 3567 |
static void |
| 3568 |
gdk_x11_window_set_override_redirect (GdkWindow *window, |
| 3569 |
gboolean override_redirect) |
| 3570 |
{ |
| 3571 |
XSetWindowAttributes attr; |
| 3572 |
|
| 3573 |
if (!GDK_WINDOW_DESTROYED (window) && |
| 3574 |
WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 3575 |
{ |
| 3576 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3577 |
|
| 3578 |
attr.override_redirect = (override_redirect? True : False); |
| 3579 |
XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), |
| 3580 |
GDK_WINDOW_XID (window), |
| 3581 |
CWOverrideRedirect, |
| 3582 |
&attr); |
| 3583 |
|
| 3584 |
impl->override_redirect = attr.override_redirect; |
| 3585 |
} |
| 3586 |
} |
| 3587 |
|
| 3588 |
static void |
| 3589 |
gdk_x11_window_set_accept_focus (GdkWindow *window, |
| 3590 |
gboolean accept_focus) |
| 3591 |
{ |
| 3592 |
accept_focus = accept_focus != FALSE; |
| 3593 |
|
| 3594 |
if (window->accept_focus != accept_focus) |
| 3595 |
{ |
| 3596 |
window->accept_focus = accept_focus; |
| 3597 |
|
| 3598 |
if (!GDK_WINDOW_DESTROYED (window) && |
| 3599 |
WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 3600 |
update_wm_hints (window, FALSE); |
| 3601 |
} |
| 3602 |
} |
| 3603 |
|
| 3604 |
static void |
| 3605 |
gdk_x11_window_set_focus_on_map (GdkWindow *window, |
| 3606 |
gboolean focus_on_map) |
| 3607 |
{ |
| 3608 |
focus_on_map = focus_on_map != FALSE; |
| 3609 |
|
| 3610 |
if (window->focus_on_map != focus_on_map) |
| 3611 |
{ |
| 3612 |
window->focus_on_map = focus_on_map; |
| 3613 |
|
| 3614 |
if ((!GDK_WINDOW_DESTROYED (window)) && |
| 3615 |
(!window->focus_on_map) && |
| 3616 |
WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 3617 |
gdk_x11_window_set_user_time (window, 0); |
| 3618 |
} |
| 3619 |
} |
| 3620 |
|
| 3621 |
/** |
| 3622 |
* gdk_x11_window_set_user_time: |
| 3623 |
* @window: (type GdkX11Window): A toplevel #GdkWindow |
| 3624 |
* @timestamp: An XServer timestamp to which the property should be set |
| 3625 |
* |
| 3626 |
* The application can use this call to update the _NET_WM_USER_TIME |
| 3627 |
* property on a toplevel window. This property stores an Xserver |
| 3628 |
* time which represents the time of the last user input event |
| 3629 |
* received for this window. This property may be used by the window |
| 3630 |
* manager to alter the focus, stacking, and/or placement behavior of |
| 3631 |
* windows when they are mapped depending on whether the new window |
| 3632 |
* was created by a user action or is a "pop-up" window activated by a |
| 3633 |
* timer or some other event. |
| 3634 |
* |
| 3635 |
* Note that this property is automatically updated by GDK, so this |
| 3636 |
* function should only be used by applications which handle input |
| 3637 |
* events bypassing GDK. |
| 3638 |
* |
| 3639 |
* Since: 2.6 |
| 3640 |
**/ |
| 3641 |
void |
| 3642 |
gdk_x11_window_set_user_time (GdkWindow *window, |
| 3643 |
guint32 timestamp) |
| 3644 |
{ |
| 3645 |
GdkDisplay *display; |
| 3646 |
GdkX11Display *display_x11; |
| 3647 |
GdkToplevelX11 *toplevel; |
| 3648 |
glong timestamp_long = (glong)timestamp; |
| 3649 |
Window xid; |
| 3650 |
|
| 3651 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3652 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 3653 |
return; |
| 3654 |
|
| 3655 |
display = gdk_window_get_display (window); |
| 3656 |
display_x11 = GDK_X11_DISPLAY (display); |
| 3657 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 3658 |
|
| 3659 |
if (!toplevel) |
| 3660 |
{ |
| 3661 |
g_warning ("gdk_window_set_user_time called on non-toplevel\n"); |
| 3662 |
return; |
| 3663 |
} |
| 3664 |
|
| 3665 |
if (toplevel->focus_window != None && |
| 3666 |
gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), |
| 3667 |
gdk_atom_intern_static_string ("_NET_WM_USER_TIME_WINDOW"))) |
| 3668 |
xid = toplevel->focus_window; |
| 3669 |
else |
| 3670 |
xid = GDK_WINDOW_XID (window); |
| 3671 |
|
| 3672 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xid, |
| 3673 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_USER_TIME"), |
| 3674 |
XA_CARDINAL, 32, PropModeReplace, |
| 3675 |
(guchar *)×tamp_long, 1); |
| 3676 |
|
| 3677 |
if (timestamp_long != GDK_CURRENT_TIME && |
| 3678 |
(display_x11->user_time == GDK_CURRENT_TIME || |
| 3679 |
XSERVER_TIME_IS_LATER (timestamp_long, display_x11->user_time))) |
| 3680 |
display_x11->user_time = timestamp_long; |
| 3681 |
|
| 3682 |
if (toplevel) |
| 3683 |
toplevel->user_time = timestamp_long; |
| 3684 |
} |
| 3685 |
|
| 3686 |
/** |
| 3687 |
* gdk_x11_window_set_utf8_property: |
| 3688 |
* @window: (type GdkX11Window): a #GdkWindow |
| 3689 |
* @name: Property name, will be interned as an X atom |
| 3690 |
* @value: (allow-none): Property value, or %NULL to delete |
| 3691 |
* |
| 3692 |
* This function modifies or removes an arbitrary X11 window |
| 3693 |
* property of type UTF8_STRING. If the given @window is |
| 3694 |
* not a toplevel window, it is ignored. |
| 3695 |
* |
| 3696 |
* Since: 3.4 |
| 3697 |
*/ |
| 3698 |
void |
| 3699 |
gdk_x11_window_set_utf8_property (GdkWindow *window, |
| 3700 |
const gchar *name, |
| 3701 |
const gchar *value) |
| 3702 |
{ |
| 3703 |
GdkDisplay *display; |
| 3704 |
|
| 3705 |
if (!WINDOW_IS_TOPLEVEL (window)) |
| 3706 |
return; |
| 3707 |
|
| 3708 |
display = gdk_window_get_display (window); |
| 3709 |
|
| 3710 |
if (value != NULL) |
| 3711 |
{ |
| 3712 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 3713 |
GDK_WINDOW_XID (window), |
| 3714 |
gdk_x11_get_xatom_by_name_for_display (display, name), |
| 3715 |
gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, |
| 3716 |
PropModeReplace, (guchar *)value, strlen (value)); |
| 3717 |
} |
| 3718 |
else |
| 3719 |
{ |
| 3720 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), |
| 3721 |
GDK_WINDOW_XID (window), |
| 3722 |
gdk_x11_get_xatom_by_name_for_display (display, name)); |
| 3723 |
} |
| 3724 |
} |
| 3725 |
|
| 3726 |
/** |
| 3727 |
* gdk_x11_window_set_hide_titlebar_when_maximized: |
| 3728 |
* @window: (type GdkX11Window): a #GdkWindow |
| 3729 |
* @hide_titlebar_when_maximized: whether to hide the titlebar when |
| 3730 |
* maximized |
| 3731 |
* |
| 3732 |
* Set a hint for the window manager, requesting that the titlebar |
| 3733 |
* should be hidden when the window is maximized. |
| 3734 |
* |
| 3735 |
* Note that this property is automatically updated by GTK+, so this |
| 3736 |
* function should only be used by applications which do not use GTK+ |
| 3737 |
* to create toplevel windows. |
| 3738 |
* |
| 3739 |
* Since: 3.4 |
| 3740 |
*/ |
| 3741 |
void |
| 3742 |
gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window, |
| 3743 |
gboolean hide_titlebar_when_maximized) |
| 3744 |
{ |
| 3745 |
GdkDisplay *display; |
| 3746 |
|
| 3747 |
if (!WINDOW_IS_TOPLEVEL (window)) |
| 3748 |
return; |
| 3749 |
|
| 3750 |
display = gdk_window_get_display (window); |
| 3751 |
|
| 3752 |
if (hide_titlebar_when_maximized) |
| 3753 |
{ |
| 3754 |
gulong hide = 1; |
| 3755 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 3756 |
GDK_WINDOW_XID (window), |
| 3757 |
gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"), |
| 3758 |
XA_CARDINAL, 32, |
| 3759 |
PropModeReplace, (guchar *)&hide, 1); |
| 3760 |
} |
| 3761 |
else |
| 3762 |
{ |
| 3763 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), |
| 3764 |
GDK_WINDOW_XID (window), |
| 3765 |
gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED")); |
| 3766 |
} |
| 3767 |
} |
| 3768 |
|
| 3769 |
static void |
| 3770 |
gdk_x11_window_set_shadow_width (GdkWindow *window, |
| 3771 |
int left, |
| 3772 |
int right, |
| 3773 |
int top, |
| 3774 |
int bottom) |
| 3775 |
{ |
| 3776 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 3777 |
Atom frame_extents; |
| 3778 |
gulong data[4] = { |
| 3779 |
left * impl->window_scale, |
| 3780 |
right * impl->window_scale, |
| 3781 |
top * impl->window_scale, |
| 3782 |
bottom * impl->window_scale |
| 3783 |
}; |
| 3784 |
|
| 3785 |
frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window), |
| 3786 |
"_GTK_FRAME_EXTENTS"); |
| 3787 |
XChangeProperty (GDK_WINDOW_XDISPLAY (window), |
| 3788 |
GDK_WINDOW_XID (window), |
| 3789 |
frame_extents, XA_CARDINAL, |
| 3790 |
32, PropModeReplace, |
| 3791 |
(guchar *) &data, 4); |
| 3792 |
} |
| 3793 |
|
| 3794 |
/** |
| 3795 |
* gdk_x11_window_set_frame_extents: |
| 3796 |
* @window: (type GdkX11Window): a #GdkWindow |
| 3797 |
* @left: The left extent |
| 3798 |
* @right: The right extent |
| 3799 |
* @top: The top extent |
| 3800 |
* @bottom: The bottom extent |
| 3801 |
* |
| 3802 |
* This is the same as gdk_window_set_shadow_width() but it only works |
| 3803 |
* on GdkX11Window. |
| 3804 |
* |
| 3805 |
* Since: 3.10 |
| 3806 |
* |
| 3807 |
* Deprecated: 3.12: Use gdk_window_set_shadow_width() instead. |
| 3808 |
*/ |
| 3809 |
void |
| 3810 |
gdk_x11_window_set_frame_extents (GdkWindow *window, |
| 3811 |
int left, |
| 3812 |
int right, |
| 3813 |
int top, |
| 3814 |
int bottom) |
| 3815 |
{ |
| 3816 |
gdk_x11_window_set_shadow_width (window, left, right, top, bottom); |
| 3817 |
} |
| 3818 |
|
| 3819 |
/** |
| 3820 |
* gdk_x11_window_set_theme_variant: |
| 3821 |
* @window: (type GdkX11Window): a #GdkWindow |
| 3822 |
* @variant: the theme variant to export |
| 3823 |
* |
| 3824 |
* GTK+ applications can request a dark theme variant. In order to |
| 3825 |
* make other applications - namely window managers using GTK+ for |
| 3826 |
* themeing - aware of this choice, GTK+ uses this function to |
| 3827 |
* export the requested theme variant as _GTK_THEME_VARIANT property |
| 3828 |
* on toplevel windows. |
| 3829 |
* |
| 3830 |
* Note that this property is automatically updated by GTK+, so this |
| 3831 |
* function should only be used by applications which do not use GTK+ |
| 3832 |
* to create toplevel windows. |
| 3833 |
* |
| 3834 |
* Since: 3.2 |
| 3835 |
*/ |
| 3836 |
void |
| 3837 |
gdk_x11_window_set_theme_variant (GdkWindow *window, |
| 3838 |
char *variant) |
| 3839 |
{ |
| 3840 |
gdk_x11_window_set_utf8_property (window, "_GTK_THEME_VARIANT", |
| 3841 |
variant ? variant : ""); |
| 3842 |
} |
| 3843 |
|
| 3844 |
#define GDK_SELECTION_MAX_SIZE(display) \ |
| 3845 |
MIN(262144, \ |
| 3846 |
XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \ |
| 3847 |
? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \ |
| 3848 |
: XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100) |
| 3849 |
|
| 3850 |
static void |
| 3851 |
gdk_window_update_icon (GdkWindow *window, |
| 3852 |
GList *icon_list) |
| 3853 |
{ |
| 3854 |
GdkToplevelX11 *toplevel; |
| 3855 |
GdkPixbuf *best_icon; |
| 3856 |
GList *tmp_list; |
| 3857 |
int best_size; |
| 3858 |
|
| 3859 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 3860 |
|
| 3861 |
if (toplevel->icon_pixmap != NULL) |
| 3862 |
{ |
| 3863 |
cairo_surface_destroy (toplevel->icon_pixmap); |
| 3864 |
toplevel->icon_pixmap = NULL; |
| 3865 |
} |
| 3866 |
|
| 3867 |
if (toplevel->icon_mask != NULL) |
| 3868 |
{ |
| 3869 |
cairo_surface_destroy (toplevel->icon_mask); |
| 3870 |
toplevel->icon_mask = NULL; |
| 3871 |
} |
| 3872 |
|
| 3873 |
#define IDEAL_SIZE 48 |
| 3874 |
|
| 3875 |
best_size = G_MAXINT; |
| 3876 |
best_icon = NULL; |
| 3877 |
for (tmp_list = icon_list; tmp_list; tmp_list = tmp_list->next) |
| 3878 |
{ |
| 3879 |
GdkPixbuf *pixbuf = tmp_list->data; |
| 3880 |
int this; |
| 3881 |
|
| 3882 |
/* average width and height - if someone passes in a rectangular |
| 3883 |
* icon they deserve what they get. |
| 3884 |
*/ |
| 3885 |
this = gdk_pixbuf_get_width (pixbuf) + gdk_pixbuf_get_height (pixbuf); |
| 3886 |
this /= 2; |
| 3887 |
|
| 3888 |
if (best_icon == NULL) |
| 3889 |
{ |
| 3890 |
best_icon = pixbuf; |
| 3891 |
best_size = this; |
| 3892 |
} |
| 3893 |
else |
| 3894 |
{ |
| 3895 |
/* icon is better if it's 32 pixels or larger, and closer to |
| 3896 |
* the ideal size than the current best. |
| 3897 |
*/ |
| 3898 |
if (this >= 32 && |
| 3899 |
(ABS (best_size - IDEAL_SIZE) < |
| 3900 |
ABS (this - IDEAL_SIZE))) |
| 3901 |
{ |
| 3902 |
best_icon = pixbuf; |
| 3903 |
best_size = this; |
| 3904 |
} |
| 3905 |
} |
| 3906 |
} |
| 3907 |
|
| 3908 |
if (best_icon) |
| 3909 |
{ |
| 3910 |
int width = gdk_pixbuf_get_width (best_icon); |
| 3911 |
int height = gdk_pixbuf_get_height (best_icon); |
| 3912 |
cairo_t *cr; |
| 3913 |
|
| 3914 |
toplevel->icon_pixmap = gdk_x11_window_create_pixmap_surface (window, |
| 3915 |
width, |
| 3916 |
height); |
| 3917 |
|
| 3918 |
cr = cairo_create (toplevel->icon_pixmap); |
| 3919 |
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); |
| 3920 |
gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0); |
| 3921 |
if (gdk_pixbuf_get_has_alpha (best_icon)) |
| 3922 |
{ |
| 3923 |
/* Saturate the image, so it has bilevel alpha */ |
| 3924 |
cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA); |
| 3925 |
cairo_paint (cr); |
| 3926 |
cairo_set_operator (cr, CAIRO_OPERATOR_SATURATE); |
| 3927 |
cairo_paint (cr); |
| 3928 |
cairo_pop_group_to_source (cr); |
| 3929 |
} |
| 3930 |
cairo_paint (cr); |
| 3931 |
cairo_destroy (cr); |
| 3932 |
|
| 3933 |
if (gdk_pixbuf_get_has_alpha (best_icon)) |
| 3934 |
{ |
| 3935 |
toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window, |
| 3936 |
width, |
| 3937 |
height); |
| 3938 |
|
| 3939 |
cr = cairo_create (toplevel->icon_mask); |
| 3940 |
gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0); |
| 3941 |
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); |
| 3942 |
cairo_paint (cr); |
| 3943 |
cairo_destroy (cr); |
| 3944 |
} |
| 3945 |
} |
| 3946 |
|
| 3947 |
update_wm_hints (window, FALSE); |
| 3948 |
} |
| 3949 |
|
| 3950 |
static void |
| 3951 |
gdk_x11_window_set_icon_list (GdkWindow *window, |
| 3952 |
GList *pixbufs) |
| 3953 |
{ |
| 3954 |
gulong *data; |
| 3955 |
guchar *pixels; |
| 3956 |
gulong *p; |
| 3957 |
gint size; |
| 3958 |
GList *l; |
| 3959 |
GdkPixbuf *pixbuf; |
| 3960 |
gint width, height, stride; |
| 3961 |
gint x, y; |
| 3962 |
gint n_channels; |
| 3963 |
GdkDisplay *display; |
| 3964 |
gint n; |
| 3965 |
|
| 3966 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3967 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 3968 |
return; |
| 3969 |
|
| 3970 |
display = gdk_window_get_display (window); |
| 3971 |
|
| 3972 |
l = pixbufs; |
| 3973 |
size = 0; |
| 3974 |
n = 0; |
| 3975 |
while (l) |
| 3976 |
{ |
| 3977 |
pixbuf = l->data; |
| 3978 |
g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); |
| 3979 |
|
| 3980 |
width = gdk_pixbuf_get_width (pixbuf); |
| 3981 |
height = gdk_pixbuf_get_height (pixbuf); |
| 3982 |
|
| 3983 |
/* silently ignore overlarge icons */ |
| 3984 |
if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display)) |
| 3985 |
break; |
| 3986 |
|
| 3987 |
n++; |
| 3988 |
size += 2 + width * height; |
| 3989 |
|
| 3990 |
l = l->next; |
| 3991 |
} |
| 3992 |
|
| 3993 |
data = g_malloc (size * sizeof (gulong)); |
| 3994 |
|
| 3995 |
l = pixbufs; |
| 3996 |
p = data; |
| 3997 |
while (l && n > 0) |
| 3998 |
{ |
| 3999 |
pixbuf = l->data; |
| 4000 |
|
| 4001 |
width = gdk_pixbuf_get_width (pixbuf); |
| 4002 |
height = gdk_pixbuf_get_height (pixbuf); |
| 4003 |
stride = gdk_pixbuf_get_rowstride (pixbuf); |
| 4004 |
n_channels = gdk_pixbuf_get_n_channels (pixbuf); |
| 4005 |
|
| 4006 |
*p++ = width; |
| 4007 |
*p++ = height; |
| 4008 |
|
| 4009 |
pixels = gdk_pixbuf_get_pixels (pixbuf); |
| 4010 |
|
| 4011 |
for (y = 0; y < height; y++) |
| 4012 |
{ |
| 4013 |
for (x = 0; x < width; x++) |
| 4014 |
{ |
| 4015 |
guchar r, g, b, a; |
| 4016 |
|
| 4017 |
r = pixels[y*stride + x*n_channels + 0]; |
| 4018 |
g = pixels[y*stride + x*n_channels + 1]; |
| 4019 |
b = pixels[y*stride + x*n_channels + 2]; |
| 4020 |
if (n_channels >= 4) |
| 4021 |
a = pixels[y*stride + x*n_channels + 3]; |
| 4022 |
else |
| 4023 |
a = 255; |
| 4024 |
|
| 4025 |
*p++ = a << 24 | r << 16 | g << 8 | b ; |
| 4026 |
} |
| 4027 |
} |
| 4028 |
|
| 4029 |
l = l->next; |
| 4030 |
n--; |
| 4031 |
} |
| 4032 |
|
| 4033 |
if (size > 0) |
| 4034 |
{ |
| 4035 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 4036 |
GDK_WINDOW_XID (window), |
| 4037 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"), |
| 4038 |
XA_CARDINAL, 32, |
| 4039 |
PropModeReplace, |
| 4040 |
(guchar*) data, size); |
| 4041 |
} |
| 4042 |
else |
| 4043 |
{ |
| 4044 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), |
| 4045 |
GDK_WINDOW_XID (window), |
| 4046 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON")); |
| 4047 |
} |
| 4048 |
|
| 4049 |
g_free (data); |
| 4050 |
|
| 4051 |
gdk_window_update_icon (window, pixbufs); |
| 4052 |
} |
| 4053 |
|
| 4054 |
static gboolean |
| 4055 |
gdk_window_icon_name_set (GdkWindow *window) |
| 4056 |
{ |
| 4057 |
return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window), |
| 4058 |
g_quark_from_static_string ("gdk-icon-name-set"))); |
| 4059 |
} |
| 4060 |
|
| 4061 |
static void |
| 4062 |
gdk_x11_window_set_icon_name (GdkWindow *window, |
| 4063 |
const gchar *name) |
| 4064 |
{ |
| 4065 |
GdkDisplay *display; |
| 4066 |
|
| 4067 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4068 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4069 |
return; |
| 4070 |
|
| 4071 |
display = gdk_window_get_display (window); |
| 4072 |
|
| 4073 |
g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"), |
| 4074 |
GUINT_TO_POINTER (name != NULL)); |
| 4075 |
|
| 4076 |
if (name != NULL) |
| 4077 |
{ |
| 4078 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 4079 |
GDK_WINDOW_XID (window), |
| 4080 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"), |
| 4081 |
gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, |
| 4082 |
PropModeReplace, (guchar *)name, strlen (name)); |
| 4083 |
|
| 4084 |
set_text_property (display, GDK_WINDOW_XID (window), |
| 4085 |
gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"), |
| 4086 |
name); |
| 4087 |
} |
| 4088 |
else |
| 4089 |
{ |
| 4090 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), |
| 4091 |
GDK_WINDOW_XID (window), |
| 4092 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME")); |
| 4093 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), |
| 4094 |
GDK_WINDOW_XID (window), |
| 4095 |
gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME")); |
| 4096 |
} |
| 4097 |
} |
| 4098 |
|
| 4099 |
static void |
| 4100 |
gdk_x11_window_iconify (GdkWindow *window) |
| 4101 |
{ |
| 4102 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4103 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4104 |
return; |
| 4105 |
|
| 4106 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4107 |
{ |
| 4108 |
XIconifyWindow (GDK_WINDOW_XDISPLAY (window), |
| 4109 |
GDK_WINDOW_XID (window), |
| 4110 |
gdk_x11_screen_get_number (GDK_WINDOW_SCREEN (window))); |
| 4111 |
} |
| 4112 |
else |
| 4113 |
{ |
| 4114 |
/* Flip our client side flag, the real work happens on map. */ |
| 4115 |
gdk_synthesize_window_state (window, |
| 4116 |
0, |
| 4117 |
GDK_WINDOW_STATE_ICONIFIED); |
| 4118 |
gdk_wmspec_change_state (TRUE, window, |
| 4119 |
gdk_atom_intern_static_string ("_NET_WM_STATE_HIDDEN"), |
| 4120 |
GDK_NONE); |
| 4121 |
} |
| 4122 |
} |
| 4123 |
|
| 4124 |
static void |
| 4125 |
gdk_x11_window_deiconify (GdkWindow *window) |
| 4126 |
{ |
| 4127 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4128 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4129 |
return; |
| 4130 |
|
| 4131 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4132 |
{ |
| 4133 |
gdk_window_show (window); |
| 4134 |
gdk_wmspec_change_state (FALSE, window, |
| 4135 |
gdk_atom_intern_static_string ("_NET_WM_STATE_HIDDEN"), |
| 4136 |
GDK_NONE); |
| 4137 |
} |
| 4138 |
else |
| 4139 |
{ |
| 4140 |
/* Flip our client side flag, the real work happens on map. */ |
| 4141 |
gdk_synthesize_window_state (window, |
| 4142 |
GDK_WINDOW_STATE_ICONIFIED, |
| 4143 |
0); |
| 4144 |
gdk_wmspec_change_state (FALSE, window, |
| 4145 |
gdk_atom_intern_static_string ("_NET_WM_STATE_HIDDEN"), |
| 4146 |
GDK_NONE); |
| 4147 |
} |
| 4148 |
} |
| 4149 |
|
| 4150 |
static void |
| 4151 |
gdk_x11_window_stick (GdkWindow *window) |
| 4152 |
{ |
| 4153 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4154 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4155 |
return; |
| 4156 |
|
| 4157 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4158 |
{ |
| 4159 |
/* "stick" means stick to all desktops _and_ do not scroll with the |
| 4160 |
* viewport. i.e. glue to the monitor glass in all cases. |
| 4161 |
*/ |
| 4162 |
|
| 4163 |
XClientMessageEvent xclient; |
| 4164 |
|
| 4165 |
/* Request stick during viewport scroll */ |
| 4166 |
gdk_wmspec_change_state (TRUE, window, |
| 4167 |
gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"), |
| 4168 |
GDK_NONE); |
| 4169 |
|
| 4170 |
/* Request desktop 0xFFFFFFFF */ |
| 4171 |
memset (&xclient, 0, sizeof (xclient)); |
| 4172 |
xclient.type = ClientMessage; |
| 4173 |
xclient.window = GDK_WINDOW_XID (window); |
| 4174 |
xclient.display = GDK_WINDOW_XDISPLAY (window); |
| 4175 |
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), |
| 4176 |
"_NET_WM_DESKTOP"); |
| 4177 |
xclient.format = 32; |
| 4178 |
|
| 4179 |
xclient.data.l[0] = 0xFFFFFFFF; |
| 4180 |
xclient.data.l[1] = 0; |
| 4181 |
xclient.data.l[2] = 0; |
| 4182 |
xclient.data.l[3] = 0; |
| 4183 |
xclient.data.l[4] = 0; |
| 4184 |
|
| 4185 |
XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False, |
| 4186 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 4187 |
(XEvent *)&xclient); |
| 4188 |
} |
| 4189 |
else |
| 4190 |
{ |
| 4191 |
/* Flip our client side flag, the real work happens on map. */ |
| 4192 |
gdk_synthesize_window_state (window, |
| 4193 |
0, |
| 4194 |
GDK_WINDOW_STATE_STICKY); |
| 4195 |
} |
| 4196 |
} |
| 4197 |
|
| 4198 |
static void |
| 4199 |
gdk_x11_window_unstick (GdkWindow *window) |
| 4200 |
{ |
| 4201 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4202 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4203 |
return; |
| 4204 |
|
| 4205 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4206 |
{ |
| 4207 |
/* Request unstick from viewport */ |
| 4208 |
gdk_wmspec_change_state (FALSE, window, |
| 4209 |
gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"), |
| 4210 |
GDK_NONE); |
| 4211 |
|
| 4212 |
move_to_current_desktop (window); |
| 4213 |
} |
| 4214 |
else |
| 4215 |
{ |
| 4216 |
/* Flip our client side flag, the real work happens on map. */ |
| 4217 |
gdk_synthesize_window_state (window, |
| 4218 |
GDK_WINDOW_STATE_STICKY, |
| 4219 |
0); |
| 4220 |
|
| 4221 |
} |
| 4222 |
} |
| 4223 |
|
| 4224 |
static void |
| 4225 |
gdk_x11_window_maximize (GdkWindow *window) |
| 4226 |
{ |
| 4227 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4228 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4229 |
return; |
| 4230 |
|
| 4231 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4232 |
gdk_wmspec_change_state (TRUE, window, |
| 4233 |
gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"), |
| 4234 |
gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ")); |
| 4235 |
else |
| 4236 |
gdk_synthesize_window_state (window, |
| 4237 |
0, |
| 4238 |
GDK_WINDOW_STATE_MAXIMIZED); |
| 4239 |
} |
| 4240 |
|
| 4241 |
static void |
| 4242 |
gdk_x11_window_unmaximize (GdkWindow *window) |
| 4243 |
{ |
| 4244 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4245 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4246 |
return; |
| 4247 |
|
| 4248 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4249 |
gdk_wmspec_change_state (FALSE, window, |
| 4250 |
gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"), |
| 4251 |
gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ")); |
| 4252 |
else |
| 4253 |
gdk_synthesize_window_state (window, |
| 4254 |
GDK_WINDOW_STATE_MAXIMIZED, |
| 4255 |
0); |
| 4256 |
} |
| 4257 |
|
| 4258 |
static void |
| 4259 |
gdk_x11_window_apply_fullscreen_mode (GdkWindow *window) |
| 4260 |
{ |
| 4261 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4262 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4263 |
return; |
| 4264 |
|
| 4265 |
/* _NET_WM_FULLSCREEN_MONITORS gives an indication to the window manager as |
| 4266 |
* to which monitors so span across when the window is fullscreen, but it's |
| 4267 |
* not a state in itself so this would have no effect if the window is not |
| 4268 |
* mapped. |
| 4269 |
*/ |
| 4270 |
|
| 4271 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4272 |
{ |
| 4273 |
XClientMessageEvent xclient; |
| 4274 |
gint monitors[4]; |
| 4275 |
gint i; |
| 4276 |
|
| 4277 |
memset (&xclient, 0, sizeof (xclient)); |
| 4278 |
xclient.type = ClientMessage; |
| 4279 |
xclient.window = GDK_WINDOW_XID (window); |
| 4280 |
xclient.display = GDK_WINDOW_XDISPLAY (window); |
| 4281 |
xclient.format = 32; |
| 4282 |
|
| 4283 |
switch (window->fullscreen_mode) |
| 4284 |
{ |
| 4285 |
case GDK_FULLSCREEN_ON_CURRENT_MONITOR: |
| 4286 |
|
| 4287 |
/* FIXME: This is not part of the EWMH spec! |
| 4288 |
* |
| 4289 |
* There is no documented mechanism to remove the property |
| 4290 |
* _NET_WM_FULLSCREEN_MONITORS once set, so we use use a set of |
| 4291 |
* invalid, largest possible value. |
| 4292 |
* |
| 4293 |
* When given values larger than actual possible monitor values, most |
| 4294 |
* window managers who support the _NET_WM_FULLSCREEN_MONITORS spec |
| 4295 |
* will simply unset _NET_WM_FULLSCREEN_MONITORS and revert to their |
| 4296 |
* default behavior. |
| 4297 |
* |
| 4298 |
* Successfully tested on mutter/metacity, kwin, compiz and xfwm4. |
| 4299 |
* |
| 4300 |
* Note, this (non documented) mechanism is unlikely to be an issue |
| 4301 |
* as it's used only for transitionning back from "all monitors" to |
| 4302 |
* "current monitor" mode. |
| 4303 |
* |
| 4304 |
* Applications who don't change the default mode won't trigger this |
| 4305 |
* mechanism. |
| 4306 |
*/ |
| 4307 |
for (i = 0; i < 4; ++i) |
| 4308 |
xclient.data.l[i] = G_MAXLONG; |
| 4309 |
|
| 4310 |
break; |
| 4311 |
|
| 4312 |
case GDK_FULLSCREEN_ON_ALL_MONITORS: |
| 4313 |
|
| 4314 |
_gdk_x11_screen_get_edge_monitors (GDK_WINDOW_SCREEN (window), |
| 4315 |
&monitors[0], |
| 4316 |
&monitors[1], |
| 4317 |
&monitors[2], |
| 4318 |
&monitors[3]); |
| 4319 |
/* Translate all 4 monitors from the GDK set into XINERAMA indices */ |
| 4320 |
for (i = 0; i < 4; ++i) |
| 4321 |
{ |
| 4322 |
xclient.data.l[i] = monitors[i]; |
| 4323 |
/* Sanity check, if XINERAMA is not available, we could have invalid |
| 4324 |
* negative values for the XINERAMA indices. |
| 4325 |
*/ |
| 4326 |
if (xclient.data.l[i] < 0) |
| 4327 |
{ |
| 4328 |
g_warning ("gdk_x11_window_apply_fullscreen_mode: Invalid XINERAMA monitor index"); |
| 4329 |
return; |
| 4330 |
} |
| 4331 |
} |
| 4332 |
break; |
| 4333 |
|
| 4334 |
default: |
| 4335 |
g_warning ("gdk_x11_window_apply_fullscreen_mode: Unhandled fullscreen mode %d", |
| 4336 |
window->fullscreen_mode); |
| 4337 |
return; |
| 4338 |
} |
| 4339 |
|
| 4340 |
/* Send fullscreen monitors client message */ |
| 4341 |
xclient.data.l[4] = 1; /* source indication */ |
| 4342 |
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), |
| 4343 |
"_NET_WM_FULLSCREEN_MONITORS"); |
| 4344 |
XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False, |
| 4345 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 4346 |
(XEvent *)&xclient); |
| 4347 |
} |
| 4348 |
} |
| 4349 |
|
| 4350 |
static void |
| 4351 |
gdk_x11_window_fullscreen (GdkWindow *window) |
| 4352 |
{ |
| 4353 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4354 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4355 |
return; |
| 4356 |
|
| 4357 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4358 |
{ |
| 4359 |
gdk_wmspec_change_state (TRUE, window, |
| 4360 |
gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"), |
| 4361 |
GDK_NONE); |
| 4362 |
/* Actual XRandR layout may have change since we computed the fullscreen |
| 4363 |
* monitors in GDK_FULLSCREEN_ON_ALL_MONITORS mode. |
| 4364 |
*/ |
| 4365 |
if (window->fullscreen_mode == GDK_FULLSCREEN_ON_ALL_MONITORS) |
| 4366 |
gdk_x11_window_apply_fullscreen_mode (window); |
| 4367 |
} |
| 4368 |
else |
| 4369 |
gdk_synthesize_window_state (window, |
| 4370 |
0, |
| 4371 |
GDK_WINDOW_STATE_FULLSCREEN); |
| 4372 |
} |
| 4373 |
|
| 4374 |
static void |
| 4375 |
gdk_x11_window_fullscreen_on_monitor (GdkWindow *window, |
| 4376 |
gint monitor) |
| 4377 |
{ |
| 4378 |
GdkRectangle monitor_geom; |
| 4379 |
|
| 4380 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4381 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4382 |
return; |
| 4383 |
|
| 4384 |
G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
| 4385 |
gdk_screen_get_monitor_geometry (GDK_WINDOW_SCREEN (window), monitor, &monitor_geom); |
| 4386 |
gdk_window_move (window, monitor_geom.x, monitor_geom.y); |
| 4387 |
G_GNUC_END_IGNORE_DEPRECATIONS |
| 4388 |
|
| 4389 |
gdk_window_set_fullscreen_mode (window, GDK_FULLSCREEN_ON_CURRENT_MONITOR); |
| 4390 |
gdk_x11_window_fullscreen (window); |
| 4391 |
} |
| 4392 |
|
| 4393 |
static void |
| 4394 |
gdk_x11_window_unfullscreen (GdkWindow *window) |
| 4395 |
{ |
| 4396 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4397 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4398 |
return; |
| 4399 |
|
| 4400 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4401 |
gdk_wmspec_change_state (FALSE, window, |
| 4402 |
gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"), |
| 4403 |
GDK_NONE); |
| 4404 |
|
| 4405 |
else |
| 4406 |
gdk_synthesize_window_state (window, |
| 4407 |
GDK_WINDOW_STATE_FULLSCREEN, |
| 4408 |
0); |
| 4409 |
} |
| 4410 |
|
| 4411 |
static void |
| 4412 |
gdk_x11_window_set_keep_above (GdkWindow *window, |
| 4413 |
gboolean setting) |
| 4414 |
{ |
| 4415 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 4416 |
|
| 4417 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4418 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4419 |
return; |
| 4420 |
|
| 4421 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4422 |
{ |
| 4423 |
if (setting) |
| 4424 |
gdk_wmspec_change_state (FALSE, window, |
| 4425 |
gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"), |
| 4426 |
GDK_NONE); |
| 4427 |
gdk_wmspec_change_state (setting, window, |
| 4428 |
gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"), |
| 4429 |
GDK_NONE); |
| 4430 |
} |
| 4431 |
else |
| 4432 |
gdk_synthesize_window_state (window, |
| 4433 |
setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE, |
| 4434 |
setting ? GDK_WINDOW_STATE_ABOVE : 0); |
| 4435 |
} |
| 4436 |
|
| 4437 |
static void |
| 4438 |
gdk_x11_window_set_keep_below (GdkWindow *window, gboolean setting) |
| 4439 |
{ |
| 4440 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 4441 |
|
| 4442 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4443 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4444 |
return; |
| 4445 |
|
| 4446 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 4447 |
{ |
| 4448 |
if (setting) |
| 4449 |
gdk_wmspec_change_state (FALSE, window, |
| 4450 |
gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"), |
| 4451 |
GDK_NONE); |
| 4452 |
gdk_wmspec_change_state (setting, window, |
| 4453 |
gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"), |
| 4454 |
GDK_NONE); |
| 4455 |
} |
| 4456 |
else |
| 4457 |
gdk_synthesize_window_state (window, |
| 4458 |
setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW, |
| 4459 |
setting ? GDK_WINDOW_STATE_BELOW : 0); |
| 4460 |
} |
| 4461 |
|
| 4462 |
static GdkWindow * |
| 4463 |
gdk_x11_window_get_group (GdkWindow *window) |
| 4464 |
{ |
| 4465 |
GdkToplevelX11 *toplevel; |
| 4466 |
|
| 4467 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4468 |
!WINDOW_IS_TOPLEVEL (window)) |
| 4469 |
return NULL; |
| 4470 |
|
| 4471 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 4472 |
|
| 4473 |
return toplevel->group_leader; |
| 4474 |
} |
| 4475 |
|
| 4476 |
static void |
| 4477 |
gdk_x11_window_set_group (GdkWindow *window, |
| 4478 |
GdkWindow *leader) |
| 4479 |
{ |
| 4480 |
GdkToplevelX11 *toplevel; |
| 4481 |
|
| 4482 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 4483 |
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD); |
| 4484 |
g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader)); |
| 4485 |
|
| 4486 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4487 |
(leader != NULL && GDK_WINDOW_DESTROYED (leader)) || |
| 4488 |
!WINDOW_IS_TOPLEVEL (window)) |
| 4489 |
return; |
| 4490 |
|
| 4491 |
toplevel = _gdk_x11_window_get_toplevel (window); |
| 4492 |
|
| 4493 |
if (leader == NULL) |
| 4494 |
leader = gdk_display_get_default_group (gdk_window_get_display (window)); |
| 4495 |
|
| 4496 |
if (toplevel->group_leader != leader) |
| 4497 |
{ |
| 4498 |
if (toplevel->group_leader) |
| 4499 |
g_object_unref (toplevel->group_leader); |
| 4500 |
toplevel->group_leader = g_object_ref (leader); |
| 4501 |
(_gdk_x11_window_get_toplevel (leader))->is_leader = TRUE; |
| 4502 |
} |
| 4503 |
|
| 4504 |
update_wm_hints (window, FALSE); |
| 4505 |
} |
| 4506 |
|
| 4507 |
static MotifWmHints * |
| 4508 |
gdk_window_get_mwm_hints (GdkWindow *window) |
| 4509 |
{ |
| 4510 |
GdkDisplay *display; |
| 4511 |
Atom hints_atom = None; |
| 4512 |
guchar *data; |
| 4513 |
Atom type; |
| 4514 |
gint format; |
| 4515 |
gulong nitems; |
| 4516 |
gulong bytes_after; |
| 4517 |
|
| 4518 |
if (GDK_WINDOW_DESTROYED (window)) |
| 4519 |
return NULL; |
| 4520 |
|
| 4521 |
display = gdk_window_get_display (window); |
| 4522 |
|
| 4523 |
hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS); |
| 4524 |
|
| 4525 |
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), |
| 4526 |
hints_atom, 0, sizeof (MotifWmHints)/sizeof (long), |
| 4527 |
False, AnyPropertyType, &type, &format, &nitems, |
| 4528 |
&bytes_after, &data); |
| 4529 |
|
| 4530 |
if (type == None) |
| 4531 |
return NULL; |
| 4532 |
|
| 4533 |
return (MotifWmHints *)data; |
| 4534 |
} |
| 4535 |
|
| 4536 |
static void |
| 4537 |
gdk_window_set_mwm_hints (GdkWindow *window, |
| 4538 |
MotifWmHints *new_hints) |
| 4539 |
{ |
| 4540 |
GdkDisplay *display; |
| 4541 |
Atom hints_atom = None; |
| 4542 |
guchar *data; |
| 4543 |
MotifWmHints *hints; |
| 4544 |
Atom type; |
| 4545 |
gint format; |
| 4546 |
gulong nitems; |
| 4547 |
gulong bytes_after; |
| 4548 |
|
| 4549 |
if (GDK_WINDOW_DESTROYED (window)) |
| 4550 |
return; |
| 4551 |
|
| 4552 |
display = gdk_window_get_display (window); |
| 4553 |
|
| 4554 |
hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS); |
| 4555 |
|
| 4556 |
XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), |
| 4557 |
hints_atom, 0, sizeof (MotifWmHints)/sizeof (long), |
| 4558 |
False, AnyPropertyType, &type, &format, &nitems, |
| 4559 |
&bytes_after, &data); |
| 4560 |
|
| 4561 |
if (type == None) |
| 4562 |
hints = new_hints; |
| 4563 |
else |
| 4564 |
{ |
| 4565 |
hints = (MotifWmHints *)data; |
| 4566 |
|
| 4567 |
if (new_hints->flags & MWM_HINTS_FUNCTIONS) |
| 4568 |
{ |
| 4569 |
hints->flags |= MWM_HINTS_FUNCTIONS; |
| 4570 |
hints->functions = new_hints->functions; |
| 4571 |
} |
| 4572 |
if (new_hints->flags & MWM_HINTS_DECORATIONS) |
| 4573 |
{ |
| 4574 |
hints->flags |= MWM_HINTS_DECORATIONS; |
| 4575 |
hints->decorations = new_hints->decorations; |
| 4576 |
} |
| 4577 |
} |
| 4578 |
|
| 4579 |
XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), |
| 4580 |
hints_atom, hints_atom, 32, PropModeReplace, |
| 4581 |
(guchar *)hints, sizeof (MotifWmHints)/sizeof (long)); |
| 4582 |
|
| 4583 |
if (hints != new_hints) |
| 4584 |
XFree (hints); |
| 4585 |
} |
| 4586 |
|
| 4587 |
static void |
| 4588 |
gdk_x11_window_set_decorations (GdkWindow *window, |
| 4589 |
GdkWMDecoration decorations) |
| 4590 |
{ |
| 4591 |
MotifWmHints hints; |
| 4592 |
|
| 4593 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4594 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4595 |
return; |
| 4596 |
|
| 4597 |
/* initialize to zero to avoid writing uninitialized data to socket */ |
| 4598 |
memset(&hints, 0, sizeof(hints)); |
| 4599 |
hints.flags = MWM_HINTS_DECORATIONS; |
| 4600 |
hints.decorations = decorations; |
| 4601 |
|
| 4602 |
gdk_window_set_mwm_hints (window, &hints); |
| 4603 |
} |
| 4604 |
|
| 4605 |
static gboolean |
| 4606 |
gdk_x11_window_get_decorations(GdkWindow *window, |
| 4607 |
GdkWMDecoration *decorations) |
| 4608 |
{ |
| 4609 |
MotifWmHints *hints; |
| 4610 |
gboolean result = FALSE; |
| 4611 |
|
| 4612 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4613 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4614 |
return FALSE; |
| 4615 |
|
| 4616 |
hints = gdk_window_get_mwm_hints (window); |
| 4617 |
|
| 4618 |
if (hints) |
| 4619 |
{ |
| 4620 |
if (hints->flags & MWM_HINTS_DECORATIONS) |
| 4621 |
{ |
| 4622 |
if (decorations) |
| 4623 |
*decorations = hints->decorations; |
| 4624 |
result = TRUE; |
| 4625 |
} |
| 4626 |
|
| 4627 |
XFree (hints); |
| 4628 |
} |
| 4629 |
|
| 4630 |
return result; |
| 4631 |
} |
| 4632 |
|
| 4633 |
static void |
| 4634 |
gdk_x11_window_set_functions (GdkWindow *window, |
| 4635 |
GdkWMFunction functions) |
| 4636 |
{ |
| 4637 |
MotifWmHints hints; |
| 4638 |
|
| 4639 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 4640 |
|
| 4641 |
if (GDK_WINDOW_DESTROYED (window) || |
| 4642 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 4643 |
return; |
| 4644 |
|
| 4645 |
/* initialize to zero to avoid writing uninitialized data to socket */ |
| 4646 |
memset(&hints, 0, sizeof(hints)); |
| 4647 |
hints.flags = MWM_HINTS_FUNCTIONS; |
| 4648 |
hints.functions = functions; |
| 4649 |
|
| 4650 |
gdk_window_set_mwm_hints (window, &hints); |
| 4651 |
} |
| 4652 |
|
| 4653 |
cairo_region_t * |
| 4654 |
_gdk_x11_xwindow_get_shape (Display *xdisplay, |
| 4655 |
Window window, |
| 4656 |
gint scale, |
| 4657 |
gint shape_type) |
| 4658 |
{ |
| 4659 |
cairo_region_t *shape; |
| 4660 |
GdkRectangle *rl; |
| 4661 |
XRectangle *xrl; |
| 4662 |
gint rn, ord, i; |
| 4663 |
|
| 4664 |
shape = NULL; |
| 4665 |
rn = 0; |
| 4666 |
|
| 4667 |
/* Note that XShapeGetRectangles returns NULL in two situations: |
| 4668 |
* - the server doesn't support the SHAPE extension |
| 4669 |
* - the shape is empty |
| 4670 |
* |
| 4671 |
* Since we can't discriminate these here, we always return |
| 4672 |
* an empty shape. It is the callers responsibility to check |
| 4673 |
* whether the server supports the SHAPE extensions beforehand. |
| 4674 |
*/ |
| 4675 |
xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord); |
| 4676 |
|
| 4677 |
if (rn == 0) |
| 4678 |
return cairo_region_create (); /* Empty */ |
| 4679 |
|
| 4680 |
if (ord != YXBanded) |
| 4681 |
{ |
| 4682 |
/* This really shouldn't happen with any xserver, as they |
| 4683 |
* generally convert regions to YXBanded internally |
| 4684 |
*/ |
| 4685 |
g_warning ("non YXBanded shape masks not supported"); |
| 4686 |
XFree (xrl); |
| 4687 |
return NULL; |
| 4688 |
} |
| 4689 |
|
| 4690 |
/* NOTE: The scale divisions here may lose some precision if someone |
| 4691 |
else set the shape to be non-scale precision */ |
| 4692 |
rl = g_new (GdkRectangle, rn); |
| 4693 |
for (i = 0; i < rn; i++) |
| 4694 |
{ |
| 4695 |
rl[i].x = xrl[i].x / scale; |
| 4696 |
rl[i].y = xrl[i].y / scale; |
| 4697 |
rl[i].width = xrl[i].width / scale; |
| 4698 |
rl[i].height = xrl[i].height / scale; |
| 4699 |
} |
| 4700 |
XFree (xrl); |
| 4701 |
|
| 4702 |
shape = cairo_region_create_rectangles (rl, rn); |
| 4703 |
g_free (rl); |
| 4704 |
|
| 4705 |
return shape; |
| 4706 |
} |
| 4707 |
|
| 4708 |
|
| 4709 |
static cairo_region_t * |
| 4710 |
gdk_x11_window_get_shape (GdkWindow *window) |
| 4711 |
{ |
| 4712 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 4713 |
|
| 4714 |
if (!GDK_WINDOW_DESTROYED (window) && |
| 4715 |
gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))) |
| 4716 |
return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window), |
| 4717 |
GDK_WINDOW_XID (window), |
| 4718 |
impl->window_scale, |
| 4719 |
ShapeBounding); |
| 4720 |
|
| 4721 |
return NULL; |
| 4722 |
} |
| 4723 |
|
| 4724 |
static cairo_region_t * |
| 4725 |
gdk_x11_window_get_input_shape (GdkWindow *window) |
| 4726 |
{ |
| 4727 |
#if defined(ShapeInput) |
| 4728 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 4729 |
|
| 4730 |
if (!GDK_WINDOW_DESTROYED (window) && |
| 4731 |
gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window))) |
| 4732 |
return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window), |
| 4733 |
GDK_WINDOW_XID (window), |
| 4734 |
impl->window_scale, |
| 4735 |
ShapeInput); |
| 4736 |
#endif |
| 4737 |
|
| 4738 |
return NULL; |
| 4739 |
} |
| 4740 |
|
| 4741 |
/* From the WM spec */ |
| 4742 |
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 |
| 4743 |
#define _NET_WM_MOVERESIZE_SIZE_TOP 1 |
| 4744 |
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 |
| 4745 |
#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 |
| 4746 |
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 |
| 4747 |
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 |
| 4748 |
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 |
| 4749 |
#define _NET_WM_MOVERESIZE_SIZE_LEFT 7 |
| 4750 |
#define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */ |
| 4751 |
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */ |
| 4752 |
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */ |
| 4753 |
#define _NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */ |
| 4754 |
|
| 4755 |
static void |
| 4756 |
wmspec_send_message (GdkDisplay *display, |
| 4757 |
GdkWindow *window, |
| 4758 |
gint root_x, |
| 4759 |
gint root_y, |
| 4760 |
gint action, |
| 4761 |
gint button) |
| 4762 |
{ |
| 4763 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 4764 |
XClientMessageEvent xclient; |
| 4765 |
|
| 4766 |
memset (&xclient, 0, sizeof (xclient)); |
| 4767 |
xclient.type = ClientMessage; |
| 4768 |
xclient.window = GDK_WINDOW_XID (window); |
| 4769 |
xclient.message_type = |
| 4770 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE"); |
| 4771 |
xclient.format = 32; |
| 4772 |
xclient.data.l[0] = root_x * impl->window_scale; |
| 4773 |
xclient.data.l[1] = root_y * impl->window_scale; |
| 4774 |
xclient.data.l[2] = action; |
| 4775 |
xclient.data.l[3] = button; |
| 4776 |
xclient.data.l[4] = 1; /* source indication */ |
| 4777 |
|
| 4778 |
XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False, |
| 4779 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 4780 |
(XEvent *)&xclient); |
| 4781 |
} |
| 4782 |
|
| 4783 |
static void |
| 4784 |
handle_wmspec_button_release (GdkDisplay *display, |
| 4785 |
XEvent *xevent) |
| 4786 |
{ |
| 4787 |
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); |
| 4788 |
GdkWindow *window; |
| 4789 |
|
| 4790 |
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2) |
| 4791 |
XIEvent *xiev = (XIEvent *) xevent->xcookie.data; |
| 4792 |
XIDeviceEvent *xidev = (XIDeviceEvent *) xiev; |
| 4793 |
|
| 4794 |
if (xevent->xany.type == GenericEvent) |
| 4795 |
window = gdk_x11_window_lookup_for_display (display, xidev->event); |
| 4796 |
else |
| 4797 |
#endif |
| 4798 |
window = gdk_x11_window_lookup_for_display (display, xevent->xany.window); |
| 4799 |
|
| 4800 |
if (display_x11->wm_moveresize_button != 0 && window != NULL) |
| 4801 |
{ |
| 4802 |
if ((xevent->xany.type == ButtonRelease && |
| 4803 |
xevent->xbutton.button == display_x11->wm_moveresize_button) |
| 4804 |
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2) |
| 4805 |
|| |
| 4806 |
(xevent->xany.type == GenericEvent && |
| 4807 |
xiev->evtype == XI_ButtonRelease && |
| 4808 |
xidev->detail == display_x11->wm_moveresize_button) |
| 4809 |
#endif |
| 4810 |
) |
| 4811 |
{ |
| 4812 |
display_x11->wm_moveresize_button = 0; |
| 4813 |
wmspec_send_message (display, window, 0, 0, _NET_WM_MOVERESIZE_CANCEL, 0); |
| 4814 |
} |
| 4815 |
} |
| 4816 |
} |
| 4817 |
|
| 4818 |
static void |
| 4819 |
wmspec_moveresize (GdkWindow *window, |
| 4820 |
gint direction, |
| 4821 |
GdkDevice *device, |
| 4822 |
gint button, |
| 4823 |
gint root_x, |
| 4824 |
gint root_y, |
| 4825 |
guint32 timestamp) |
| 4826 |
{ |
| 4827 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); |
| 4828 |
|
| 4829 |
if (button != 0) |
| 4830 |
gdk_seat_ungrab (gdk_device_get_seat (device)); /* Release passive grab */ |
| 4831 |
GDK_X11_DISPLAY (display)->wm_moveresize_button = button; |
| 4832 |
|
| 4833 |
wmspec_send_message (display, window, root_x, root_y, direction, button); |
| 4834 |
} |
| 4835 |
|
| 4836 |
static void |
| 4837 |
wmspec_resize_drag (GdkWindow *window, |
| 4838 |
GdkWindowEdge edge, |
| 4839 |
GdkDevice *device, |
| 4840 |
gint button, |
| 4841 |
gint root_x, |
| 4842 |
gint root_y, |
| 4843 |
guint32 timestamp) |
| 4844 |
{ |
| 4845 |
gint direction; |
| 4846 |
|
| 4847 |
if (button == 0) |
| 4848 |
direction = _NET_WM_MOVERESIZE_SIZE_KEYBOARD; |
| 4849 |
else |
| 4850 |
switch (edge) |
| 4851 |
{ |
| 4852 |
/* Let the compiler turn a switch into a table, instead |
| 4853 |
* of doing the table manually, this way is easier to verify. |
| 4854 |
*/ |
| 4855 |
case GDK_WINDOW_EDGE_NORTH_WEST: |
| 4856 |
direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT; |
| 4857 |
break; |
| 4858 |
|
| 4859 |
case GDK_WINDOW_EDGE_NORTH: |
| 4860 |
direction = _NET_WM_MOVERESIZE_SIZE_TOP; |
| 4861 |
break; |
| 4862 |
|
| 4863 |
case GDK_WINDOW_EDGE_NORTH_EAST: |
| 4864 |
direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT; |
| 4865 |
break; |
| 4866 |
|
| 4867 |
case GDK_WINDOW_EDGE_WEST: |
| 4868 |
direction = _NET_WM_MOVERESIZE_SIZE_LEFT; |
| 4869 |
break; |
| 4870 |
|
| 4871 |
case GDK_WINDOW_EDGE_EAST: |
| 4872 |
direction = _NET_WM_MOVERESIZE_SIZE_RIGHT; |
| 4873 |
break; |
| 4874 |
|
| 4875 |
case GDK_WINDOW_EDGE_SOUTH_WEST: |
| 4876 |
direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT; |
| 4877 |
break; |
| 4878 |
|
| 4879 |
case GDK_WINDOW_EDGE_SOUTH: |
| 4880 |
direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM; |
| 4881 |
break; |
| 4882 |
|
| 4883 |
case GDK_WINDOW_EDGE_SOUTH_EAST: |
| 4884 |
direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT; |
| 4885 |
break; |
| 4886 |
|
| 4887 |
default: |
| 4888 |
g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!", |
| 4889 |
edge); |
| 4890 |
return; |
| 4891 |
} |
| 4892 |
|
| 4893 |
wmspec_moveresize (window, direction, device, button, root_x, root_y, timestamp); |
| 4894 |
} |
| 4895 |
|
| 4896 |
typedef struct _MoveResizeData MoveResizeData; |
| 4897 |
|
| 4898 |
struct _MoveResizeData |
| 4899 |
{ |
| 4900 |
GdkDisplay *display; |
| 4901 |
|
| 4902 |
GdkWindow *moveresize_window; |
| 4903 |
GdkWindow *moveresize_emulation_window; |
| 4904 |
gboolean is_resize; |
| 4905 |
GdkWindowEdge resize_edge; |
| 4906 |
GdkDevice *device; |
| 4907 |
gint moveresize_button; |
| 4908 |
gint moveresize_x; |
| 4909 |
gint moveresize_y; |
| 4910 |
gint moveresize_orig_x; |
| 4911 |
gint moveresize_orig_y; |
| 4912 |
gint moveresize_orig_width; |
| 4913 |
gint moveresize_orig_height; |
| 4914 |
GdkWindowHints moveresize_geom_mask; |
| 4915 |
GdkGeometry moveresize_geometry; |
| 4916 |
Time moveresize_process_time; |
| 4917 |
XEvent *moveresize_pending_event; |
| 4918 |
}; |
| 4919 |
|
| 4920 |
static MoveResizeData * |
| 4921 |
get_move_resize_data (GdkDisplay *display, |
| 4922 |
gboolean create) |
| 4923 |
{ |
| 4924 |
MoveResizeData *mv_resize; |
| 4925 |
static GQuark move_resize_quark = 0; |
| 4926 |
|
| 4927 |
if (!move_resize_quark) |
| 4928 |
move_resize_quark = g_quark_from_static_string ("gdk-window-moveresize"); |
| 4929 |
|
| 4930 |
mv_resize = g_object_get_qdata (G_OBJECT (display), move_resize_quark); |
| 4931 |
|
| 4932 |
if (!mv_resize && create) |
| 4933 |
{ |
| 4934 |
mv_resize = g_new0 (MoveResizeData, 1); |
| 4935 |
mv_resize->display = display; |
| 4936 |
|
| 4937 |
g_object_set_qdata (G_OBJECT (display), move_resize_quark, mv_resize); |
| 4938 |
} |
| 4939 |
|
| 4940 |
return mv_resize; |
| 4941 |
} |
| 4942 |
|
| 4943 |
static void |
| 4944 |
check_maximize (MoveResizeData *mv_resize, |
| 4945 |
gdouble x_root, |
| 4946 |
gdouble y_root) |
| 4947 |
{ |
| 4948 |
GdkWindowState state; |
| 4949 |
gint y; |
| 4950 |
|
| 4951 |
if (mv_resize->is_resize) |
| 4952 |
return; |
| 4953 |
|
| 4954 |
state = gdk_window_get_state (mv_resize->moveresize_window); |
| 4955 |
|
| 4956 |
if (state & GDK_WINDOW_STATE_MAXIMIZED) |
| 4957 |
return; |
| 4958 |
|
| 4959 |
y = mv_resize->moveresize_orig_y + (y_root - mv_resize->moveresize_y); |
| 4960 |
|
| 4961 |
if (y < 10) |
| 4962 |
gdk_window_maximize (mv_resize->moveresize_window); |
| 4963 |
} |
| 4964 |
|
| 4965 |
static void |
| 4966 |
check_unmaximize (MoveResizeData *mv_resize, |
| 4967 |
gdouble x_root, |
| 4968 |
gdouble y_root) |
| 4969 |
{ |
| 4970 |
GdkWindowState state; |
| 4971 |
gint dx, dy; |
| 4972 |
|
| 4973 |
if (mv_resize->is_resize) |
| 4974 |
return; |
| 4975 |
|
| 4976 |
state = gdk_window_get_state (mv_resize->moveresize_window); |
| 4977 |
|
| 4978 |
if ((state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_TILED)) == 0) |
| 4979 |
return; |
| 4980 |
|
| 4981 |
dx = x_root - mv_resize->moveresize_x; |
| 4982 |
dy = y_root - mv_resize->moveresize_y; |
| 4983 |
|
| 4984 |
if (ABS (dx) > 20 || ABS (dy) > 20) |
| 4985 |
gdk_window_unmaximize (mv_resize->moveresize_window); |
| 4986 |
} |
| 4987 |
|
| 4988 |
static void |
| 4989 |
update_pos (MoveResizeData *mv_resize, |
| 4990 |
gint new_root_x, |
| 4991 |
gint new_root_y) |
| 4992 |
{ |
| 4993 |
gint dx, dy; |
| 4994 |
|
| 4995 |
check_unmaximize (mv_resize, new_root_x, new_root_y); |
| 4996 |
dx = new_root_x - mv_resize->moveresize_x; |
| 4997 |
dy = new_root_y - mv_resize->moveresize_y; |
| 4998 |
|
| 4999 |
if (mv_resize->is_resize) |
| 5000 |
{ |
| 5001 |
gint x, y, w, h; |
| 5002 |
|
| 5003 |
x = mv_resize->moveresize_orig_x; |
| 5004 |
y = mv_resize->moveresize_orig_y; |
| 5005 |
|
| 5006 |
w = mv_resize->moveresize_orig_width; |
| 5007 |
h = mv_resize->moveresize_orig_height; |
| 5008 |
|
| 5009 |
switch (mv_resize->resize_edge) |
| 5010 |
{ |
| 5011 |
case GDK_WINDOW_EDGE_NORTH_WEST: |
| 5012 |
x += dx; |
| 5013 |
y += dy; |
| 5014 |
w -= dx; |
| 5015 |
h -= dy; |
| 5016 |
break; |
| 5017 |
case GDK_WINDOW_EDGE_NORTH: |
| 5018 |
y += dy; |
| 5019 |
h -= dy; |
| 5020 |
break; |
| 5021 |
case GDK_WINDOW_EDGE_NORTH_EAST: |
| 5022 |
y += dy; |
| 5023 |
h -= dy; |
| 5024 |
w += dx; |
| 5025 |
break; |
| 5026 |
case GDK_WINDOW_EDGE_SOUTH_WEST: |
| 5027 |
h += dy; |
| 5028 |
x += dx; |
| 5029 |
w -= dx; |
| 5030 |
break; |
| 5031 |
case GDK_WINDOW_EDGE_SOUTH_EAST: |
| 5032 |
w += dx; |
| 5033 |
h += dy; |
| 5034 |
break; |
| 5035 |
case GDK_WINDOW_EDGE_SOUTH: |
| 5036 |
h += dy; |
| 5037 |
break; |
| 5038 |
case GDK_WINDOW_EDGE_EAST: |
| 5039 |
w += dx; |
| 5040 |
break; |
| 5041 |
case GDK_WINDOW_EDGE_WEST: |
| 5042 |
x += dx; |
| 5043 |
w -= dx; |
| 5044 |
break; |
| 5045 |
} |
| 5046 |
|
| 5047 |
x = MAX (x, 0); |
| 5048 |
y = MAX (y, 0); |
| 5049 |
w = MAX (w, 1); |
| 5050 |
h = MAX (h, 1); |
| 5051 |
|
| 5052 |
if (mv_resize->moveresize_geom_mask) |
| 5053 |
{ |
| 5054 |
gdk_window_constrain_size (&mv_resize->moveresize_geometry, |
| 5055 |
mv_resize->moveresize_geom_mask, |
| 5056 |
w, h, &w, &h); |
| 5057 |
} |
| 5058 |
|
| 5059 |
gdk_window_move_resize (mv_resize->moveresize_window, x, y, w, h); |
| 5060 |
} |
| 5061 |
else |
| 5062 |
{ |
| 5063 |
gint x, y; |
| 5064 |
|
| 5065 |
x = mv_resize->moveresize_orig_x + dx; |
| 5066 |
y = mv_resize->moveresize_orig_y + dy; |
| 5067 |
|
| 5068 |
gdk_window_move (mv_resize->moveresize_window, x, y); |
| 5069 |
} |
| 5070 |
} |
| 5071 |
|
| 5072 |
static void |
| 5073 |
finish_drag (MoveResizeData *mv_resize) |
| 5074 |
{ |
| 5075 |
gdk_window_destroy (mv_resize->moveresize_emulation_window); |
| 5076 |
mv_resize->moveresize_emulation_window = NULL; |
| 5077 |
g_clear_object (&mv_resize->moveresize_window); |
| 5078 |
g_clear_pointer (&mv_resize->moveresize_pending_event, g_free); |
| 5079 |
} |
| 5080 |
|
| 5081 |
static int |
| 5082 |
lookahead_motion_predicate (Display *xdisplay, |
| 5083 |
XEvent *event, |
| 5084 |
XPointer arg) |
| 5085 |
{ |
| 5086 |
gboolean *seen_release = (gboolean *)arg; |
| 5087 |
GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay); |
| 5088 |
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE); |
| 5089 |
|
| 5090 |
if (*seen_release) |
| 5091 |
return False; |
| 5092 |
|
| 5093 |
switch (event->xany.type) |
| 5094 |
{ |
| 5095 |
case ButtonRelease: |
| 5096 |
*seen_release = TRUE; |
| 5097 |
break; |
| 5098 |
case MotionNotify: |
| 5099 |
mv_resize->moveresize_process_time = event->xmotion.time; |
| 5100 |
break; |
| 5101 |
default: |
| 5102 |
break; |
| 5103 |
} |
| 5104 |
|
| 5105 |
return False; |
| 5106 |
} |
| 5107 |
|
| 5108 |
static gboolean |
| 5109 |
moveresize_lookahead (MoveResizeData *mv_resize, |
| 5110 |
XEvent *event) |
| 5111 |
{ |
| 5112 |
XEvent tmp_event; |
| 5113 |
gboolean seen_release = FALSE; |
| 5114 |
|
| 5115 |
if (mv_resize->moveresize_process_time) |
| 5116 |
{ |
| 5117 |
if (event->xmotion.time == mv_resize->moveresize_process_time) |
| 5118 |
{ |
| 5119 |
mv_resize->moveresize_process_time = 0; |
| 5120 |
return TRUE; |
| 5121 |
} |
| 5122 |
else |
| 5123 |
return FALSE; |
| 5124 |
} |
| 5125 |
|
| 5126 |
XCheckIfEvent (event->xany.display, &tmp_event, |
| 5127 |
lookahead_motion_predicate, (XPointer) & seen_release); |
| 5128 |
|
| 5129 |
return mv_resize->moveresize_process_time == 0; |
| 5130 |
} |
| 5131 |
|
| 5132 |
gboolean |
| 5133 |
_gdk_x11_moveresize_handle_event (XEvent *event) |
| 5134 |
{ |
| 5135 |
guint button_mask = 0; |
| 5136 |
GdkDisplay *display = gdk_x11_lookup_xdisplay (event->xany.display); |
| 5137 |
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE); |
| 5138 |
GdkWindowImplX11 *impl; |
| 5139 |
|
| 5140 |
if (!mv_resize || !mv_resize->moveresize_window) |
| 5141 |
{ |
| 5142 |
handle_wmspec_button_release (display, event); |
| 5143 |
return FALSE; |
| 5144 |
} |
| 5145 |
|
| 5146 |
impl = GDK_WINDOW_IMPL_X11 (mv_resize->moveresize_window->impl); |
| 5147 |
|
| 5148 |
if (mv_resize->moveresize_button != 0) |
| 5149 |
button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1); |
| 5150 |
|
| 5151 |
switch (event->xany.type) |
| 5152 |
{ |
| 5153 |
case MotionNotify: |
| 5154 |
if (mv_resize->moveresize_window->resize_count > 0) |
| 5155 |
{ |
| 5156 |
if (mv_resize->moveresize_pending_event) |
| 5157 |
*mv_resize->moveresize_pending_event = *event; |
| 5158 |
else |
| 5159 |
mv_resize->moveresize_pending_event = |
| 5160 |
g_memdup (event, sizeof (XEvent)); |
| 5161 |
|
| 5162 |
break; |
| 5163 |
} |
| 5164 |
if (!moveresize_lookahead (mv_resize, event)) |
| 5165 |
break; |
| 5166 |
|
| 5167 |
update_pos (mv_resize, |
| 5168 |
event->xmotion.x_root / impl->window_scale, |
| 5169 |
event->xmotion.y_root / impl->window_scale); |
| 5170 |
|
| 5171 |
/* This should never be triggered in normal cases, but in the |
| 5172 |
* case where the drag started without an implicit grab being |
| 5173 |
* in effect, we could miss the release if it occurs before |
| 5174 |
* we grab the pointer; this ensures that we will never |
| 5175 |
* get a permanently stuck grab. |
| 5176 |
*/ |
| 5177 |
if ((event->xmotion.state & button_mask) == 0) |
| 5178 |
{ |
| 5179 |
check_maximize (mv_resize, |
| 5180 |
event->xmotion.x_root / impl->window_scale, |
| 5181 |
event->xmotion.y_root / impl->window_scale); |
| 5182 |
finish_drag (mv_resize); |
| 5183 |
} |
| 5184 |
break; |
| 5185 |
|
| 5186 |
case ButtonRelease: |
| 5187 |
update_pos (mv_resize, |
| 5188 |
event->xbutton.x_root / impl->window_scale, |
| 5189 |
event->xbutton.y_root / impl->window_scale); |
| 5190 |
|
| 5191 |
if (event->xbutton.button == mv_resize->moveresize_button) |
| 5192 |
{ |
| 5193 |
check_maximize (mv_resize, |
| 5194 |
event->xmotion.x_root / impl->window_scale, |
| 5195 |
event->xmotion.y_root / impl->window_scale); |
| 5196 |
finish_drag (mv_resize); |
| 5197 |
} |
| 5198 |
break; |
| 5199 |
|
| 5200 |
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2) |
| 5201 |
case GenericEvent: |
| 5202 |
{ |
| 5203 |
/* we just assume this is an XI2 event */ |
| 5204 |
XIEvent *ev = (XIEvent *) event->xcookie.data; |
| 5205 |
XIDeviceEvent *xev = (XIDeviceEvent *)ev; |
| 5206 |
gint state; |
| 5207 |
switch (ev->evtype) |
| 5208 |
{ |
| 5209 |
case XI_Motion: |
| 5210 |
update_pos (mv_resize, xev->root_x / impl->window_scale, xev->root_y / impl->window_scale); |
| 5211 |
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group); |
| 5212 |
if ((state & button_mask) == 0) |
| 5213 |
{ |
| 5214 |
check_maximize (mv_resize, |
| 5215 |
xev->root_x / impl->window_scale, |
| 5216 |
xev->root_y / impl->window_scale); |
| 5217 |
finish_drag (mv_resize); |
| 5218 |
} |
| 5219 |
break; |
| 5220 |
|
| 5221 |
case XI_ButtonRelease: |
| 5222 |
update_pos (mv_resize, xev->root_x / impl->window_scale, xev->root_y / impl->window_scale); |
| 5223 |
if (xev->detail == mv_resize->moveresize_button) |
| 5224 |
{ |
| 5225 |
check_maximize (mv_resize, |
| 5226 |
xev->root_x / impl->window_scale, |
| 5227 |
xev->root_y / impl->window_scale); |
| 5228 |
finish_drag (mv_resize); |
| 5229 |
} |
| 5230 |
break; |
| 5231 |
} |
| 5232 |
} |
| 5233 |
break; |
| 5234 |
#endif |
| 5235 |
|
| 5236 |
} |
| 5237 |
return TRUE; |
| 5238 |
} |
| 5239 |
|
| 5240 |
gboolean |
| 5241 |
_gdk_x11_moveresize_configure_done (GdkDisplay *display, |
| 5242 |
GdkWindow *window) |
| 5243 |
{ |
| 5244 |
XEvent *tmp_event; |
| 5245 |
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE); |
| 5246 |
|
| 5247 |
if (!mv_resize || window != mv_resize->moveresize_window) |
| 5248 |
return FALSE; |
| 5249 |
|
| 5250 |
if (mv_resize->moveresize_pending_event) |
| 5251 |
{ |
| 5252 |
tmp_event = mv_resize->moveresize_pending_event; |
| 5253 |
mv_resize->moveresize_pending_event = NULL; |
| 5254 |
_gdk_x11_moveresize_handle_event (tmp_event); |
| 5255 |
g_free (tmp_event); |
| 5256 |
} |
| 5257 |
|
| 5258 |
return TRUE; |
| 5259 |
} |
| 5260 |
|
| 5261 |
static void |
| 5262 |
create_moveresize_window (MoveResizeData *mv_resize, |
| 5263 |
guint32 timestamp) |
| 5264 |
{ |
| 5265 |
GdkWindowAttr attributes; |
| 5266 |
gint attributes_mask; |
| 5267 |
GdkGrabStatus status; |
| 5268 |
|
| 5269 |
g_assert (mv_resize->moveresize_emulation_window == NULL); |
| 5270 |
|
| 5271 |
attributes.x = -100; |
| 5272 |
attributes.y = -100; |
| 5273 |
attributes.width = 10; |
| 5274 |
attributes.height = 10; |
| 5275 |
attributes.window_type = GDK_WINDOW_TEMP; |
| 5276 |
attributes.wclass = GDK_INPUT_ONLY; |
| 5277 |
attributes.override_redirect = TRUE; |
| 5278 |
attributes.event_mask = 0; |
| 5279 |
|
| 5280 |
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR; |
| 5281 |
|
| 5282 |
mv_resize->moveresize_emulation_window = |
| 5283 |
gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)), |
| 5284 |
&attributes, |
| 5285 |
attributes_mask); |
| 5286 |
|
| 5287 |
gdk_window_show (mv_resize->moveresize_emulation_window); |
| 5288 |
|
| 5289 |
status = gdk_seat_grab (gdk_device_get_seat (mv_resize->device), |
| 5290 |
mv_resize->moveresize_emulation_window, |
| 5291 |
GDK_SEAT_CAPABILITY_POINTER, FALSE, |
| 5292 |
NULL, NULL, NULL, NULL); |
| 5293 |
|
| 5294 |
if (status != GDK_GRAB_SUCCESS) |
| 5295 |
{ |
| 5296 |
/* If this fails, some other client has grabbed the window |
| 5297 |
* already. |
| 5298 |
*/ |
| 5299 |
finish_drag (mv_resize); |
| 5300 |
} |
| 5301 |
|
| 5302 |
mv_resize->moveresize_process_time = 0; |
| 5303 |
} |
| 5304 |
|
| 5305 |
/* |
| 5306 |
Calculate mv_resize->moveresize_orig_x and mv_resize->moveresize_orig_y |
| 5307 |
so that calling XMoveWindow with these coordinates will not move the |
| 5308 |
window. |
| 5309 |
Note that this depends on the WM to implement ICCCM-compliant reference |
| 5310 |
point handling. |
| 5311 |
*/ |
| 5312 |
static void |
| 5313 |
calculate_unmoving_origin (MoveResizeData *mv_resize) |
| 5314 |
{ |
| 5315 |
GdkRectangle rect; |
| 5316 |
gint width, height; |
| 5317 |
|
| 5318 |
if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY && |
| 5319 |
mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC) |
| 5320 |
{ |
| 5321 |
gdk_window_get_origin (mv_resize->moveresize_window, |
| 5322 |
&mv_resize->moveresize_orig_x, |
| 5323 |
&mv_resize->moveresize_orig_y); |
| 5324 |
} |
| 5325 |
else |
| 5326 |
{ |
| 5327 |
gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect); |
| 5328 |
gdk_window_get_geometry (mv_resize->moveresize_window, |
| 5329 |
NULL, NULL, &width, &height); |
| 5330 |
|
| 5331 |
switch (mv_resize->moveresize_geometry.win_gravity) |
| 5332 |
{ |
| 5333 |
case GDK_GRAVITY_NORTH_WEST: |
| 5334 |
mv_resize->moveresize_orig_x = rect.x; |
| 5335 |
mv_resize->moveresize_orig_y = rect.y; |
| 5336 |
break; |
| 5337 |
case GDK_GRAVITY_NORTH: |
| 5338 |
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2; |
| 5339 |
mv_resize->moveresize_orig_y = rect.y; |
| 5340 |
break; |
| 5341 |
case GDK_GRAVITY_NORTH_EAST: |
| 5342 |
mv_resize->moveresize_orig_x = rect.x + rect.width - width; |
| 5343 |
mv_resize->moveresize_orig_y = rect.y; |
| 5344 |
break; |
| 5345 |
case GDK_GRAVITY_WEST: |
| 5346 |
mv_resize->moveresize_orig_x = rect.x; |
| 5347 |
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2; |
| 5348 |
break; |
| 5349 |
case GDK_GRAVITY_CENTER: |
| 5350 |
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2; |
| 5351 |
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2; |
| 5352 |
break; |
| 5353 |
case GDK_GRAVITY_EAST: |
| 5354 |
mv_resize->moveresize_orig_x = rect.x + rect.width - width; |
| 5355 |
mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2; |
| 5356 |
break; |
| 5357 |
case GDK_GRAVITY_SOUTH_WEST: |
| 5358 |
mv_resize->moveresize_orig_x = rect.x; |
| 5359 |
mv_resize->moveresize_orig_y = rect.y + rect.height - height; |
| 5360 |
break; |
| 5361 |
case GDK_GRAVITY_SOUTH: |
| 5362 |
mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2; |
| 5363 |
mv_resize->moveresize_orig_y = rect.y + rect.height - height; |
| 5364 |
break; |
| 5365 |
case GDK_GRAVITY_SOUTH_EAST: |
| 5366 |
mv_resize->moveresize_orig_x = rect.x + rect.width - width; |
| 5367 |
mv_resize->moveresize_orig_y = rect.y + rect.height - height; |
| 5368 |
break; |
| 5369 |
default: |
| 5370 |
mv_resize->moveresize_orig_x = rect.x; |
| 5371 |
mv_resize->moveresize_orig_y = rect.y; |
| 5372 |
break; |
| 5373 |
} |
| 5374 |
} |
| 5375 |
} |
| 5376 |
|
| 5377 |
static void |
| 5378 |
emulate_resize_drag (GdkWindow *window, |
| 5379 |
GdkWindowEdge edge, |
| 5380 |
GdkDevice *device, |
| 5381 |
gint button, |
| 5382 |
gint root_x, |
| 5383 |
gint root_y, |
| 5384 |
guint32 timestamp) |
| 5385 |
{ |
| 5386 |
MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE); |
| 5387 |
|
| 5388 |
if (mv_resize->moveresize_window != NULL) |
| 5389 |
return; /* already a drag operation in progress */ |
| 5390 |
|
| 5391 |
mv_resize->is_resize = TRUE; |
| 5392 |
mv_resize->moveresize_button = button; |
| 5393 |
mv_resize->resize_edge = edge; |
| 5394 |
mv_resize->device = device; |
| 5395 |
mv_resize->moveresize_x = root_x; |
| 5396 |
mv_resize->moveresize_y = root_y; |
| 5397 |
mv_resize->moveresize_window = g_object_ref (window); |
| 5398 |
|
| 5399 |
mv_resize->moveresize_orig_width = gdk_window_get_width (window); |
| 5400 |
mv_resize->moveresize_orig_height = gdk_window_get_height (window); |
| 5401 |
|
| 5402 |
mv_resize->moveresize_geom_mask = 0; |
| 5403 |
gdk_window_get_geometry_hints (window, |
| 5404 |
&mv_resize->moveresize_geometry, |
| 5405 |
&mv_resize->moveresize_geom_mask); |
| 5406 |
|
| 5407 |
calculate_unmoving_origin (mv_resize); |
| 5408 |
|
| 5409 |
create_moveresize_window (mv_resize, timestamp); |
| 5410 |
} |
| 5411 |
|
| 5412 |
static void |
| 5413 |
emulate_move_drag (GdkWindow *window, |
| 5414 |
GdkDevice *device, |
| 5415 |
gint button, |
| 5416 |
gint root_x, |
| 5417 |
gint root_y, |
| 5418 |
guint32 timestamp) |
| 5419 |
{ |
| 5420 |
MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE); |
| 5421 |
|
| 5422 |
if (mv_resize->moveresize_window != NULL) |
| 5423 |
return; /* already a drag operation in progress */ |
| 5424 |
|
| 5425 |
mv_resize->is_resize = FALSE; |
| 5426 |
mv_resize->device = device; |
| 5427 |
mv_resize->moveresize_button = button; |
| 5428 |
mv_resize->moveresize_x = root_x; |
| 5429 |
mv_resize->moveresize_y = root_y; |
| 5430 |
|
| 5431 |
mv_resize->moveresize_window = g_object_ref (window); |
| 5432 |
|
| 5433 |
calculate_unmoving_origin (mv_resize); |
| 5434 |
|
| 5435 |
create_moveresize_window (mv_resize, timestamp); |
| 5436 |
} |
| 5437 |
|
| 5438 |
static gboolean |
| 5439 |
_should_perform_ewmh_drag (GdkWindow *window, |
| 5440 |
GdkDevice *device) |
| 5441 |
{ |
| 5442 |
GdkPointerWindowInfo *info; |
| 5443 |
GdkDisplay *display; |
| 5444 |
|
| 5445 |
display = gdk_window_get_display (window); |
| 5446 |
info = _gdk_display_get_pointer_info (display, device); |
| 5447 |
|
| 5448 |
if ((!info->last_slave || gdk_device_get_source (info->last_slave) != GDK_SOURCE_TOUCHSCREEN) && |
| 5449 |
gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), |
| 5450 |
gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE"))) |
| 5451 |
return TRUE; |
| 5452 |
|
| 5453 |
return FALSE; |
| 5454 |
} |
| 5455 |
|
| 5456 |
static void |
| 5457 |
gdk_x11_window_begin_resize_drag (GdkWindow *window, |
| 5458 |
GdkWindowEdge edge, |
| 5459 |
GdkDevice *device, |
| 5460 |
gint button, |
| 5461 |
gint root_x, |
| 5462 |
gint root_y, |
| 5463 |
guint32 timestamp) |
| 5464 |
{ |
| 5465 |
if (GDK_WINDOW_DESTROYED (window) || |
| 5466 |
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) |
| 5467 |
return; |
| 5468 |
|
| 5469 |
/* Avoid EWMH for touch devices */ |
| 5470 |
if (_should_perform_ewmh_drag (window, device)) |
| 5471 |
wmspec_resize_drag (window, edge, device, button, root_x, root_y, timestamp); |
| 5472 |
else |
| 5473 |
emulate_resize_drag (window, edge, device, button, root_x, root_y, timestamp); |
| 5474 |
} |
| 5475 |
|
| 5476 |
static void |
| 5477 |
gdk_x11_window_begin_move_drag (GdkWindow *window, |
| 5478 |
GdkDevice *device, |
| 5479 |
gint button, |
| 5480 |
gint root_x, |
| 5481 |
gint root_y, |
| 5482 |
guint32 timestamp) |
| 5483 |
{ |
| 5484 |
gint direction; |
| 5485 |
|
| 5486 |
if (GDK_WINDOW_DESTROYED (window) || !WINDOW_IS_TOPLEVEL (window)) |
| 5487 |
return; |
| 5488 |
|
| 5489 |
if (button == 0) |
| 5490 |
direction = _NET_WM_MOVERESIZE_MOVE_KEYBOARD; |
| 5491 |
else |
| 5492 |
direction = _NET_WM_MOVERESIZE_MOVE; |
| 5493 |
|
| 5494 |
/* Avoid EWMH for touch devices */ |
| 5495 |
if (_should_perform_ewmh_drag (window, device)) |
| 5496 |
wmspec_moveresize (window, direction, device, button, root_x, root_y, timestamp); |
| 5497 |
else |
| 5498 |
emulate_move_drag (window, device, button, root_x, root_y, timestamp); |
| 5499 |
} |
| 5500 |
|
| 5501 |
static gboolean |
| 5502 |
gdk_x11_window_beep (GdkWindow *window) |
| 5503 |
{ |
| 5504 |
GdkDisplay *display; |
| 5505 |
|
| 5506 |
display = GDK_WINDOW_DISPLAY (window); |
| 5507 |
|
| 5508 |
if (!GDK_X11_DISPLAY (display)->trusted_client) |
| 5509 |
return FALSE; |
| 5510 |
|
| 5511 |
#ifdef HAVE_XKB |
| 5512 |
if (GDK_X11_DISPLAY (display)->use_xkb) |
| 5513 |
{ |
| 5514 |
XkbBell (GDK_DISPLAY_XDISPLAY (display), |
| 5515 |
GDK_WINDOW_XID (window), |
| 5516 |
0, |
| 5517 |
None); |
| 5518 |
return TRUE; |
| 5519 |
} |
| 5520 |
#endif |
| 5521 |
|
| 5522 |
return FALSE; |
| 5523 |
} |
| 5524 |
|
| 5525 |
static void |
| 5526 |
gdk_x11_window_set_opacity (GdkWindow *window, |
| 5527 |
gdouble opacity) |
| 5528 |
{ |
| 5529 |
GdkDisplay *display; |
| 5530 |
gulong cardinal; |
| 5531 |
|
| 5532 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 5533 |
|
| 5534 |
if (GDK_WINDOW_DESTROYED (window) || |
| 5535 |
!WINDOW_IS_TOPLEVEL (window)) |
| 5536 |
return; |
| 5537 |
|
| 5538 |
display = gdk_window_get_display (window); |
| 5539 |
|
| 5540 |
if (opacity < 0) |
| 5541 |
opacity = 0; |
| 5542 |
else if (opacity > 1) |
| 5543 |
opacity = 1; |
| 5544 |
|
| 5545 |
cardinal = opacity * 0xffffffff; |
| 5546 |
|
| 5547 |
if (cardinal == 0xffffffff) |
| 5548 |
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), |
| 5549 |
GDK_WINDOW_XID (window), |
| 5550 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY")); |
| 5551 |
else |
| 5552 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 5553 |
GDK_WINDOW_XID (window), |
| 5554 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"), |
| 5555 |
XA_CARDINAL, 32, |
| 5556 |
PropModeReplace, |
| 5557 |
(guchar *) &cardinal, 1); |
| 5558 |
} |
| 5559 |
|
| 5560 |
static void |
| 5561 |
gdk_x11_window_set_composited (GdkWindow *window, |
| 5562 |
gboolean composited) |
| 5563 |
{ |
| 5564 |
#if defined(HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES) |
| 5565 |
GdkWindowImplX11 *impl; |
| 5566 |
GdkDisplay *display; |
| 5567 |
Display *dpy; |
| 5568 |
Window xid; |
| 5569 |
|
| 5570 |
impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 5571 |
|
| 5572 |
display = gdk_window_get_display (window); |
| 5573 |
dpy = GDK_DISPLAY_XDISPLAY (display); |
| 5574 |
xid = GDK_WINDOW_XID (window); |
| 5575 |
|
| 5576 |
if (composited) |
| 5577 |
{ |
| 5578 |
XCompositeRedirectWindow (dpy, xid, CompositeRedirectManual); |
| 5579 |
impl->damage = XDamageCreate (dpy, xid, XDamageReportBoundingBox); |
| 5580 |
} |
| 5581 |
else |
| 5582 |
{ |
| 5583 |
XCompositeUnredirectWindow (dpy, xid, CompositeRedirectManual); |
| 5584 |
XDamageDestroy (dpy, impl->damage); |
| 5585 |
impl->damage = None; |
| 5586 |
} |
| 5587 |
#endif |
| 5588 |
} |
| 5589 |
|
| 5590 |
void |
| 5591 |
_gdk_x11_display_before_process_all_updates (GdkDisplay *display) |
| 5592 |
{ |
| 5593 |
} |
| 5594 |
|
| 5595 |
void |
| 5596 |
_gdk_x11_display_after_process_all_updates (GdkDisplay *display) |
| 5597 |
{ |
| 5598 |
/* Sync after all drawing, otherwise the client can get "ahead" of |
| 5599 |
the server rendering during animations, such that we fill up |
| 5600 |
the Xserver pipes with sync rendering ops not letting other |
| 5601 |
clients (including the VM) do anything. */ |
| 5602 |
XSync (GDK_DISPLAY_XDISPLAY (display), FALSE); |
| 5603 |
} |
| 5604 |
|
| 5605 |
static Bool |
| 5606 |
timestamp_predicate (Display *display, |
| 5607 |
XEvent *xevent, |
| 5608 |
XPointer arg) |
| 5609 |
{ |
| 5610 |
Window xwindow = GPOINTER_TO_UINT (arg); |
| 5611 |
GdkDisplay *gdk_display = gdk_x11_lookup_xdisplay (display); |
| 5612 |
|
| 5613 |
if (xevent->type == PropertyNotify && |
| 5614 |
xevent->xproperty.window == xwindow && |
| 5615 |
xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (gdk_display, |
| 5616 |
"GDK_TIMESTAMP_PROP")) |
| 5617 |
return True; |
| 5618 |
|
| 5619 |
return False; |
| 5620 |
} |
| 5621 |
|
| 5622 |
/** |
| 5623 |
* gdk_x11_get_server_time: |
| 5624 |
* @window: (type GdkX11Window): a #GdkWindow, used for communication |
| 5625 |
* with the server. The window must have |
| 5626 |
* GDK_PROPERTY_CHANGE_MASK in its events mask or a hang will |
| 5627 |
* result. |
| 5628 |
* |
| 5629 |
* Routine to get the current X server time stamp. |
| 5630 |
* |
| 5631 |
* Returns: the time stamp. |
| 5632 |
**/ |
| 5633 |
guint32 |
| 5634 |
gdk_x11_get_server_time (GdkWindow *window) |
| 5635 |
{ |
| 5636 |
Display *xdisplay; |
| 5637 |
Window xwindow; |
| 5638 |
guchar c = 'a'; |
| 5639 |
XEvent xevent; |
| 5640 |
Atom timestamp_prop_atom; |
| 5641 |
|
| 5642 |
g_return_val_if_fail (GDK_IS_WINDOW (window), 0); |
| 5643 |
g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0); |
| 5644 |
|
| 5645 |
xdisplay = GDK_WINDOW_XDISPLAY (window); |
| 5646 |
xwindow = GDK_WINDOW_XID (window); |
| 5647 |
timestamp_prop_atom = |
| 5648 |
gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), |
| 5649 |
"GDK_TIMESTAMP_PROP"); |
| 5650 |
|
| 5651 |
XChangeProperty (xdisplay, xwindow, timestamp_prop_atom, |
| 5652 |
timestamp_prop_atom, |
| 5653 |
8, PropModeReplace, &c, 1); |
| 5654 |
|
| 5655 |
XIfEvent (xdisplay, &xevent, |
| 5656 |
timestamp_predicate, GUINT_TO_POINTER(xwindow)); |
| 5657 |
|
| 5658 |
return xevent.xproperty.time; |
| 5659 |
} |
| 5660 |
|
| 5661 |
/** |
| 5662 |
* gdk_x11_window_get_xid: |
| 5663 |
* @window: (type GdkX11Window): a native #GdkWindow. |
| 5664 |
* |
| 5665 |
* Returns the X resource (window) belonging to a #GdkWindow. |
| 5666 |
* |
| 5667 |
* Returns: the ID of @drawable’s X resource. |
| 5668 |
**/ |
| 5669 |
XID |
| 5670 |
gdk_x11_window_get_xid (GdkWindow *window) |
| 5671 |
{ |
| 5672 |
g_return_val_if_fail (GDK_IS_X11_WINDOW (window), None); |
| 5673 |
|
| 5674 |
/* Try to ensure the window has a native window */ |
| 5675 |
if (!_gdk_window_has_impl (window)) |
| 5676 |
{ |
| 5677 |
gdk_window_ensure_native (window); |
| 5678 |
|
| 5679 |
/* We sync here to ensure the window is created in the Xserver when |
| 5680 |
* this function returns. This is required because the returned XID |
| 5681 |
* for this window must be valid immediately, even with another |
| 5682 |
* connection to the Xserver */ |
| 5683 |
gdk_display_sync (gdk_window_get_display (window)); |
| 5684 |
} |
| 5685 |
|
| 5686 |
if (!GDK_WINDOW_IS_X11 (window)) |
| 5687 |
{ |
| 5688 |
g_warning (G_STRLOC " drawable is not a native X11 window"); |
| 5689 |
return None; |
| 5690 |
} |
| 5691 |
|
| 5692 |
return GDK_WINDOW_IMPL_X11 (window->impl)->xid; |
| 5693 |
} |
| 5694 |
|
| 5695 |
static gint |
| 5696 |
gdk_x11_window_get_scale_factor (GdkWindow *window) |
| 5697 |
{ |
| 5698 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 5699 |
|
| 5700 |
if (GDK_WINDOW_DESTROYED (window)) |
| 5701 |
return 1; |
| 5702 |
|
| 5703 |
return impl->window_scale; |
| 5704 |
} |
| 5705 |
|
| 5706 |
/** |
| 5707 |
* gdk_x11_window_set_frame_sync_enabled: |
| 5708 |
* @window: (type GdkX11Window): a native #GdkWindow |
| 5709 |
* @frame_sync_enabled: whether frame-synchronization should be enabled |
| 5710 |
* |
| 5711 |
* This function can be used to disable frame synchronization for a window. |
| 5712 |
* Normally frame synchronziation will be enabled or disabled based on whether |
| 5713 |
* the system has a compositor that supports frame synchronization, but if |
| 5714 |
* the window is not directly managed by the window manager, then frame |
| 5715 |
* synchronziation may need to be disabled. This is the case for a window |
| 5716 |
* embedded via the XEMBED protocol. |
| 5717 |
* |
| 5718 |
* Since: 3.8 |
| 5719 |
*/ |
| 5720 |
void |
| 5721 |
gdk_x11_window_set_frame_sync_enabled (GdkWindow *window, |
| 5722 |
gboolean frame_sync_enabled) |
| 5723 |
{ |
| 5724 |
/* Try to ensure the window has a native window */ |
| 5725 |
if (!_gdk_window_has_impl (window)) |
| 5726 |
gdk_window_ensure_native (window); |
| 5727 |
|
| 5728 |
if (!GDK_WINDOW_IS_X11 (window)) |
| 5729 |
{ |
| 5730 |
g_warning (G_STRLOC " drawable is not a native X11 window"); |
| 5731 |
return; |
| 5732 |
} |
| 5733 |
|
| 5734 |
GDK_WINDOW_IMPL_X11 (window->impl)->frame_sync_enabled = FALSE; |
| 5735 |
} |
| 5736 |
|
| 5737 |
static void |
| 5738 |
gdk_x11_window_set_opaque_region (GdkWindow *window, |
| 5739 |
cairo_region_t *region) |
| 5740 |
{ |
| 5741 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 5742 |
GdkDisplay *display; |
| 5743 |
int nitems; |
| 5744 |
gulong *data; |
| 5745 |
|
| 5746 |
if (GDK_WINDOW_DESTROYED (window)) |
| 5747 |
return; |
| 5748 |
|
| 5749 |
if (region != NULL) |
| 5750 |
{ |
| 5751 |
int i, nrects; |
| 5752 |
|
| 5753 |
nrects = cairo_region_num_rectangles (region); |
| 5754 |
nitems = nrects * 4; |
| 5755 |
data = g_new (gulong, nitems); |
| 5756 |
|
| 5757 |
for (i = 0; i < nrects; i++) |
| 5758 |
{ |
| 5759 |
cairo_rectangle_int_t rect; |
| 5760 |
cairo_region_get_rectangle (region, i, &rect); |
| 5761 |
data[i*4+0] = rect.x * impl->window_scale; |
| 5762 |
data[i*4+1] = rect.y * impl->window_scale; |
| 5763 |
data[i*4+2] = rect.width * impl->window_scale; |
| 5764 |
data[i*4+3] = rect.height * impl->window_scale; |
| 5765 |
} |
| 5766 |
} |
| 5767 |
else |
| 5768 |
{ |
| 5769 |
nitems = 0; |
| 5770 |
data = NULL; |
| 5771 |
} |
| 5772 |
|
| 5773 |
display = gdk_window_get_display (window); |
| 5774 |
|
| 5775 |
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
| 5776 |
GDK_WINDOW_XID (window), |
| 5777 |
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_OPAQUE_REGION"), |
| 5778 |
XA_CARDINAL, 32, PropModeReplace, |
| 5779 |
(guchar *) data, nitems); |
| 5780 |
|
| 5781 |
g_free (data); |
| 5782 |
} |
| 5783 |
|
| 5784 |
static gboolean |
| 5785 |
gdk_x11_window_show_window_menu (GdkWindow *window, |
| 5786 |
GdkEvent *event) |
| 5787 |
{ |
| 5788 |
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); |
| 5789 |
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); |
| 5790 |
GdkDevice *device; |
| 5791 |
int device_id; |
| 5792 |
double x_root, y_root; |
| 5793 |
XClientMessageEvent xclient = { 0 }; |
| 5794 |
|
| 5795 |
switch (event->type) |
| 5796 |
{ |
| 5797 |
case GDK_BUTTON_PRESS: |
| 5798 |
case GDK_BUTTON_RELEASE: |
| 5799 |
break; |
| 5800 |
default: |
| 5801 |
return FALSE; |
| 5802 |
} |
| 5803 |
|
| 5804 |
if (!gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), |
| 5805 |
gdk_atom_intern_static_string ("_GTK_SHOW_WINDOW_MENU"))) |
| 5806 |
return FALSE; |
| 5807 |
|
| 5808 |
gdk_event_get_root_coords (event, &x_root, &y_root); |
| 5809 |
device = gdk_event_get_device (event); |
| 5810 |
g_object_get (G_OBJECT (device), |
| 5811 |
"device-id", &device_id, |
| 5812 |
NULL); |
| 5813 |
|
| 5814 |
/* Ungrab the implicit grab */ |
| 5815 |
gdk_seat_ungrab (gdk_device_get_seat (device)); |
| 5816 |
|
| 5817 |
xclient.type = ClientMessage; |
| 5818 |
xclient.window = GDK_WINDOW_XID (window); |
| 5819 |
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_GTK_SHOW_WINDOW_MENU"); |
| 5820 |
xclient.data.l[0] = device_id; |
| 5821 |
xclient.data.l[1] = x_root * impl->window_scale; |
| 5822 |
xclient.data.l[2] = y_root * impl->window_scale; |
| 5823 |
xclient.format = 32; |
| 5824 |
|
| 5825 |
XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False, |
| 5826 |
SubstructureRedirectMask | SubstructureNotifyMask, |
| 5827 |
(XEvent *)&xclient); |
| 5828 |
|
| 5829 |
return TRUE; |
| 5830 |
} |
| 5831 |
|
| 5832 |
static void |
| 5833 |
gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) |
| 5834 |
{ |
| 5835 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 5836 |
GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass); |
| 5837 |
|
| 5838 |
object_class->finalize = gdk_window_impl_x11_finalize; |
| 5839 |
|
| 5840 |
impl_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; |
| 5841 |
impl_class->show = gdk_window_x11_show; |
| 5842 |
impl_class->hide = gdk_window_x11_hide; |
| 5843 |
impl_class->withdraw = gdk_window_x11_withdraw; |
| 5844 |
impl_class->set_events = gdk_window_x11_set_events; |
| 5845 |
impl_class->get_events = gdk_window_x11_get_events; |
| 5846 |
impl_class->raise = gdk_window_x11_raise; |
| 5847 |
impl_class->lower = gdk_window_x11_lower; |
| 5848 |
impl_class->restack_under = gdk_window_x11_restack_under; |
| 5849 |
impl_class->restack_toplevel = gdk_window_x11_restack_toplevel; |
| 5850 |
impl_class->move_resize = gdk_window_x11_move_resize; |
| 5851 |
impl_class->set_background = gdk_window_x11_set_background; |
| 5852 |
impl_class->reparent = gdk_window_x11_reparent; |
| 5853 |
impl_class->set_device_cursor = gdk_window_x11_set_device_cursor; |
| 5854 |
impl_class->get_geometry = gdk_window_x11_get_geometry; |
| 5855 |
impl_class->get_root_coords = gdk_window_x11_get_root_coords; |
| 5856 |
impl_class->get_device_state = gdk_window_x11_get_device_state; |
| 5857 |
impl_class->shape_combine_region = gdk_window_x11_shape_combine_region; |
| 5858 |
impl_class->input_shape_combine_region = gdk_window_x11_input_shape_combine_region; |
| 5859 |
impl_class->queue_antiexpose = _gdk_x11_window_queue_antiexpose; |
| 5860 |
impl_class->destroy = gdk_x11_window_destroy; |
| 5861 |
impl_class->destroy_foreign = gdk_x11_window_destroy_foreign; |
| 5862 |
impl_class->get_shape = gdk_x11_window_get_shape; |
| 5863 |
impl_class->get_input_shape = gdk_x11_window_get_input_shape; |
| 5864 |
impl_class->beep = gdk_x11_window_beep; |
| 5865 |
|
| 5866 |
impl_class->focus = gdk_x11_window_focus; |
| 5867 |
impl_class->set_type_hint = gdk_x11_window_set_type_hint; |
| 5868 |
impl_class->get_type_hint = gdk_x11_window_get_type_hint; |
| 5869 |
impl_class->set_modal_hint = gdk_x11_window_set_modal_hint; |
| 5870 |
impl_class->set_skip_taskbar_hint = gdk_x11_window_set_skip_taskbar_hint; |
| 5871 |
impl_class->set_skip_pager_hint = gdk_x11_window_set_skip_pager_hint; |
| 5872 |
impl_class->set_urgency_hint = gdk_x11_window_set_urgency_hint; |
| 5873 |
impl_class->set_geometry_hints = gdk_x11_window_set_geometry_hints; |
| 5874 |
impl_class->set_title = gdk_x11_window_set_title; |
| 5875 |
impl_class->set_role = gdk_x11_window_set_role; |
| 5876 |
impl_class->set_startup_id = gdk_x11_window_set_startup_id; |
| 5877 |
impl_class->set_transient_for = gdk_x11_window_set_transient_for; |
| 5878 |
impl_class->get_frame_extents = gdk_x11_window_get_frame_extents; |
| 5879 |
impl_class->set_override_redirect = gdk_x11_window_set_override_redirect; |
| 5880 |
impl_class->set_accept_focus = gdk_x11_window_set_accept_focus; |
| 5881 |
impl_class->set_focus_on_map = gdk_x11_window_set_focus_on_map; |
| 5882 |
impl_class->set_icon_list = gdk_x11_window_set_icon_list; |
| 5883 |
impl_class->set_icon_name = gdk_x11_window_set_icon_name; |
| 5884 |
impl_class->iconify = gdk_x11_window_iconify; |
| 5885 |
impl_class->deiconify = gdk_x11_window_deiconify; |
| 5886 |
impl_class->stick = gdk_x11_window_stick; |
| 5887 |
impl_class->unstick = gdk_x11_window_unstick; |
| 5888 |
impl_class->maximize = gdk_x11_window_maximize; |
| 5889 |
impl_class->unmaximize = gdk_x11_window_unmaximize; |
| 5890 |
impl_class->fullscreen = gdk_x11_window_fullscreen; |
| 5891 |
impl_class->fullscreen_on_monitor = gdk_x11_window_fullscreen_on_monitor; |
| 5892 |
impl_class->apply_fullscreen_mode = gdk_x11_window_apply_fullscreen_mode; |
| 5893 |
impl_class->unfullscreen = gdk_x11_window_unfullscreen; |
| 5894 |
impl_class->set_keep_above = gdk_x11_window_set_keep_above; |
| 5895 |
impl_class->set_keep_below = gdk_x11_window_set_keep_below; |
| 5896 |
impl_class->get_group = gdk_x11_window_get_group; |
| 5897 |
impl_class->set_group = gdk_x11_window_set_group; |
| 5898 |
impl_class->set_decorations = gdk_x11_window_set_decorations; |
| 5899 |
impl_class->get_decorations = gdk_x11_window_get_decorations; |
| 5900 |
impl_class->set_functions = gdk_x11_window_set_functions; |
| 5901 |
impl_class->begin_resize_drag = gdk_x11_window_begin_resize_drag; |
| 5902 |
impl_class->begin_move_drag = gdk_x11_window_begin_move_drag; |
| 5903 |
impl_class->set_opacity = gdk_x11_window_set_opacity; |
| 5904 |
impl_class->set_composited = gdk_x11_window_set_composited; |
| 5905 |
impl_class->destroy_notify = gdk_x11_window_destroy_notify; |
| 5906 |
impl_class->get_drag_protocol = gdk_x11_window_get_drag_protocol; |
| 5907 |
impl_class->register_dnd = _gdk_x11_window_register_dnd; |
| 5908 |
impl_class->drag_begin = _gdk_x11_window_drag_begin; |
| 5909 |
impl_class->sync_rendering = _gdk_x11_window_sync_rendering; |
| 5910 |
impl_class->simulate_key = _gdk_x11_window_simulate_key; |
| 5911 |
impl_class->simulate_button = _gdk_x11_window_simulate_button; |
| 5912 |
impl_class->get_property = _gdk_x11_window_get_property; |
| 5913 |
impl_class->change_property = _gdk_x11_window_change_property; |
| 5914 |
impl_class->delete_property = _gdk_x11_window_delete_property; |
| 5915 |
impl_class->get_scale_factor = gdk_x11_window_get_scale_factor; |
| 5916 |
impl_class->set_opaque_region = gdk_x11_window_set_opaque_region; |
| 5917 |
impl_class->set_shadow_width = gdk_x11_window_set_shadow_width; |
| 5918 |
impl_class->show_window_menu = gdk_x11_window_show_window_menu; |
| 5919 |
impl_class->create_gl_context = gdk_x11_window_create_gl_context; |
| 5920 |
impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame; |
| 5921 |
impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size; |
| 5922 |
} |