1------------------------------------------------------------------------------
2--                                                                          --
3--      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       --
4--                     Copyright (C) 2000-2015, AdaCore                     --
5--                                                                          --
6-- This library is free software;  you can redistribute it and/or modify it --
7-- under terms of the  GNU General Public License  as published by the Free --
8-- Software  Foundation;  either version 3,  or (at your  option) any later --
9-- version. This library is distributed in the hope that it will be useful, --
10-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
12--                                                                          --
13-- As a special exception under Section 7 of GPL version 3, you are granted --
14-- additional permissions described in the GCC Runtime Library Exception,   --
15-- version 3.1, as published by the Free Software Foundation.               --
16--                                                                          --
17-- You should have received a copy of the GNU General Public License and    --
18-- a copy of the GCC Runtime Library Exception along with this program;     --
19-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
20-- <http://www.gnu.org/licenses/>.                                          --
21--                                                                          --
22------------------------------------------------------------------------------
23
24pragma Style_Checks (Off);
25pragma Warnings (Off, "*is already use-visible*");
26with Ada.Unchecked_Conversion;
27pragma Warnings(Off);  --  might be unused
28with Interfaces.C.Strings;     use Interfaces.C.Strings;
29pragma Warnings(On);
30
31package body Gdk.Window is
32
33   function From_Object_Free (B : access Gdk_Geometry) return Gdk_Geometry is
34      Result : constant Gdk_Geometry := B.all;
35   begin
36      Glib.g_free (B.all'Address);
37      return Result;
38   end From_Object_Free;
39
40   function Convert (R : Gdk.Gdk_Window) return System.Address is
41   begin
42      return Glib.To_Address (Glib.C_Proxy (R));
43   end Convert;
44
45   function Convert (R : System.Address) return Gdk.Gdk_Window is
46   begin
47      return Gdk.Gdk_Window(Glib.C_Proxy'(Glib.To_Proxy (R)));
48   end Convert;
49
50   function Get_User_Data (Window : Gdk_Window) return Glib.Object.GObject is
51      procedure Internal (Window : Gdk_Window; Widget : System.Address);
52      pragma Import (C, Internal, "gdk_window_get_user_data");
53      Data : aliased System.Address;
54      Stub : GObject_Record;
55   begin
56      Internal (Window, Data'Address);
57      return Get_User_Data (Data, Stub);
58   end Get_User_Data;
59
60   procedure Set_User_Data
61     (Window : Gdk_Window;
62      Widget : access Glib.Object.GObject_Record'Class)
63   is
64      procedure Internal (Window : Gdk_Window; Widget : System.Address);
65      pragma Import (C, Internal, "gdk_window_set_user_data");
66   begin
67      Internal (Window, Get_Object (Widget));
68   end Set_User_Data;
69
70   procedure C_Gdk_Window_Invalidate_Maybe_Recurse
71      (Self       : Gdk.Gdk_Window;
72       Region     : Cairo.Region.Cairo_Region;
73       Child_Func : System.Address;
74       User_Data  : System.Address);
75   pragma Import (C, C_Gdk_Window_Invalidate_Maybe_Recurse, "gdk_window_invalidate_maybe_recurse");
76   --  Adds Region to the update area for Window. The update area is the
77   --  region that needs to be redrawn, or "dirty region." The call
78   --  Gdk.Window.Process_Updates sends one or more expose events to the
79   --  window, which together cover the entire update area. An application
80   --  would normally redraw the contents of Window in response to those expose
81   --  events.
82   --  GDK will call Gdk.Window.Process_All_Updates on your behalf whenever
83   --  your program returns to the main loop and becomes idle, so normally
84   --  there's no need to do that manually, you just need to invalidate regions
85   --  that you know should be redrawn.
86   --  The Child_Func parameter controls whether the region of each child
87   --  window that intersects Region will also be invalidated. Only children
88   --  for which Child_Func returns TRUE will have the area invalidated.
89   --  "region": a cairo_region_t
90   --  "child_func": function to use to decide if to recurse to a child, null
91   --  means never recurse.
92   --  "user_data": data passed to Child_Func
93
94   procedure C_Gdk_Window_Set_Invalidate_Handler
95      (Self    : Gdk.Gdk_Window;
96       Handler : System.Address);
97   pragma Import (C, C_Gdk_Window_Set_Invalidate_Handler, "gdk_window_set_invalidate_handler");
98   --  Registers an invalidate handler for a specific window. This will get
99   --  called whenever a region in the window or its children is invalidated.
100   --  This can be used to record the invalidated region, which is useful if
101   --  you are keeping an offscreen copy of some region and want to keep it up
102   --  to date. You can also modify the invalidated region in case you're doing
103   --  some effect where e.g. a child widget appears in multiple places.
104   --  Since: gtk+ 3.10
105   --  "handler": a Gdk_Window_Invalidate_Handler_Func callback function
106
107   function To_Gdk_Window_Child_Func is new Ada.Unchecked_Conversion
108     (System.Address, Gdk_Window_Child_Func);
109
110   function To_Address is new Ada.Unchecked_Conversion
111     (Gdk_Window_Child_Func, System.Address);
112
113   function Internal_Gdk_Window_Child_Func
114      (Window    : Gdk.Gdk_Window;
115       User_Data : System.Address) return Glib.Gboolean;
116   pragma Convention (C, Internal_Gdk_Window_Child_Func);
117   --  "window": a Gdk.Gdk_Window
118   --  "user_data": user data
119
120   ------------------------------------
121   -- Internal_Gdk_Window_Child_Func --
122   ------------------------------------
123
124   function Internal_Gdk_Window_Child_Func
125      (Window    : Gdk.Gdk_Window;
126       User_Data : System.Address) return Glib.Gboolean
127   is
128      Func : constant Gdk_Window_Child_Func := To_Gdk_Window_Child_Func (User_Data);
129   begin
130      return Boolean'Pos (Func (Window));
131   end Internal_Gdk_Window_Child_Func;
132
133   -------------
134   -- Gdk_New --
135   -------------
136
137   procedure Gdk_New
138      (Self            : out Gdk_Window;
139       Parent          : Gdk.Gdk_Window;
140       Attributes      : Gdk.Gdk_Window_Attr;
141       Attributes_Mask : Gdk_Window_Attributes_Type)
142   is
143      function Internal
144         (Parent          : Gdk.Gdk_Window;
145          Attributes      : Gdk.Gdk_Window_Attr;
146          Attributes_Mask : Gdk_Window_Attributes_Type) return Gdk_Window;
147      pragma Import (C, Internal, "gdk_window_new");
148   begin
149      Self := Internal (Parent, Attributes, Attributes_Mask);
150   end Gdk_New;
151
152   --------------------
153   -- Gdk_Window_New --
154   --------------------
155
156   function Gdk_Window_New
157      (Parent          : Gdk.Gdk_Window;
158       Attributes      : Gdk.Gdk_Window_Attr;
159       Attributes_Mask : Gdk_Window_Attributes_Type) return Gdk_Window
160   is
161      function Internal
162         (Parent          : Gdk.Gdk_Window;
163          Attributes      : Gdk.Gdk_Window_Attr;
164          Attributes_Mask : Gdk_Window_Attributes_Type) return Gdk_Window;
165      pragma Import (C, Internal, "gdk_window_new");
166      Self : Gdk_Window;
167   begin
168      Self := Internal (Parent, Attributes, Attributes_Mask);
169      return Self;
170   end Gdk_Window_New;
171
172   --------------------------------
173   -- Begin_Move_Drag_For_Device --
174   --------------------------------
175
176   procedure Begin_Move_Drag_For_Device
177      (Self      : Gdk.Gdk_Window;
178       Device    : not null access Gdk.Device.Gdk_Device_Record'Class;
179       Button    : Gint;
180       Root_X    : Gint;
181       Root_Y    : Gint;
182       Timestamp : Guint32)
183   is
184      procedure Internal
185         (Self      : Gdk.Gdk_Window;
186          Device    : System.Address;
187          Button    : Gint;
188          Root_X    : Gint;
189          Root_Y    : Gint;
190          Timestamp : Guint32);
191      pragma Import (C, Internal, "gdk_window_begin_move_drag_for_device");
192   begin
193      Internal (Self, Get_Object (Device), Button, Root_X, Root_Y, Timestamp);
194   end Begin_Move_Drag_For_Device;
195
196   ----------------------------------
197   -- Begin_Resize_Drag_For_Device --
198   ----------------------------------
199
200   procedure Begin_Resize_Drag_For_Device
201      (Self      : Gdk.Gdk_Window;
202       Edge      : Gdk_Window_Edge;
203       Device    : not null access Gdk.Device.Gdk_Device_Record'Class;
204       Button    : Gint;
205       Root_X    : Gint;
206       Root_Y    : Gint;
207       Timestamp : Guint32)
208   is
209      procedure Internal
210         (Self      : Gdk.Gdk_Window;
211          Edge      : Gdk_Window_Edge;
212          Device    : System.Address;
213          Button    : Gint;
214          Root_X    : Gint;
215          Root_Y    : Gint;
216          Timestamp : Guint32);
217      pragma Import (C, Internal, "gdk_window_begin_resize_drag_for_device");
218   begin
219      Internal (Self, Edge, Get_Object (Device), Button, Root_X, Root_Y, Timestamp);
220   end Begin_Resize_Drag_For_Device;
221
222   -------------------
223   -- Ensure_Native --
224   -------------------
225
226   function Ensure_Native (Self : Gdk.Gdk_Window) return Boolean is
227      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
228      pragma Import (C, Internal, "gdk_window_ensure_native");
229   begin
230      return Internal (Self) /= 0;
231   end Ensure_Native;
232
233   ----------------------
234   -- Get_Accept_Focus --
235   ----------------------
236
237   function Get_Accept_Focus (Self : Gdk.Gdk_Window) return Boolean is
238      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
239      pragma Import (C, Internal, "gdk_window_get_accept_focus");
240   begin
241      return Internal (Self) /= 0;
242   end Get_Accept_Focus;
243
244   ------------------
245   -- Get_Children --
246   ------------------
247
248   function Get_Children
249      (Self : Gdk.Gdk_Window) return Gdk_Window_List.Glist
250   is
251      function Internal (Self : Gdk.Gdk_Window) return System.Address;
252      pragma Import (C, Internal, "gdk_window_get_children");
253      Tmp_Return : Gdk_Window_List.Glist;
254   begin
255      Gdk.Window.Gdk_Window_List.Set_Object (Tmp_Return, Internal (Self));
256      return Tmp_Return;
257   end Get_Children;
258
259   --------------------
260   -- Get_Composited --
261   --------------------
262
263   function Get_Composited (Self : Gdk.Gdk_Window) return Boolean is
264      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
265      pragma Import (C, Internal, "gdk_window_get_composited");
266   begin
267      return Internal (Self) /= 0;
268   end Get_Composited;
269
270   ---------------------
271   -- Get_Decorations --
272   ---------------------
273
274   procedure Get_Decorations
275      (Self            : Gdk.Gdk_Window;
276       Decorations     : out Gdk_WMDecoration;
277       Has_Decorations : out Boolean)
278   is
279      function Internal
280         (Self            : Gdk.Gdk_Window;
281          Acc_Decorations : access Gdk_WMDecoration) return Glib.Gboolean;
282      pragma Import (C, Internal, "gdk_window_get_decorations");
283      Acc_Decorations : aliased Gdk_WMDecoration;
284      Tmp_Return      : Glib.Gboolean;
285   begin
286      Tmp_Return := Internal (Self, Acc_Decorations'Access);
287      Decorations := Acc_Decorations;
288      Has_Decorations := Tmp_Return /= 0;
289   end Get_Decorations;
290
291   -----------------------
292   -- Get_Device_Cursor --
293   -----------------------
294
295   function Get_Device_Cursor
296      (Self   : Gdk.Gdk_Window;
297       Device : not null access Gdk.Device.Gdk_Device_Record'Class)
298       return Gdk.Gdk_Cursor
299   is
300      function Internal
301         (Self   : Gdk.Gdk_Window;
302          Device : System.Address) return Gdk.Gdk_Cursor;
303      pragma Import (C, Internal, "gdk_window_get_device_cursor");
304   begin
305      return Internal (Self, Get_Object (Device));
306   end Get_Device_Cursor;
307
308   -----------------------
309   -- Get_Device_Events --
310   -----------------------
311
312   function Get_Device_Events
313      (Self   : Gdk.Gdk_Window;
314       Device : not null access Gdk.Device.Gdk_Device_Record'Class)
315       return Gdk.Event.Gdk_Event_Mask
316   is
317      function Internal
318         (Self   : Gdk.Gdk_Window;
319          Device : System.Address) return Gdk.Event.Gdk_Event_Mask;
320      pragma Import (C, Internal, "gdk_window_get_device_events");
321   begin
322      return Internal (Self, Get_Object (Device));
323   end Get_Device_Events;
324
325   -------------------------
326   -- Get_Device_Position --
327   -------------------------
328
329   procedure Get_Device_Position
330      (Self   : Gdk.Gdk_Window;
331       Device : not null access Gdk.Device.Gdk_Device_Record'Class;
332       X      : out Gint;
333       Y      : out Gint;
334       Mask   : out Gdk.Types.Gdk_Modifier_Type;
335       Window : out Gdk.Gdk_Window)
336   is
337      function Internal
338         (Self     : Gdk.Gdk_Window;
339          Device   : System.Address;
340          Acc_X    : access Gint;
341          Acc_Y    : access Gint;
342          Acc_Mask : access Gdk.Types.Gdk_Modifier_Type)
343          return Gdk.Gdk_Window;
344      pragma Import (C, Internal, "gdk_window_get_device_position");
345      Acc_X      : aliased Gint;
346      Acc_Y      : aliased Gint;
347      Acc_Mask   : aliased Gdk.Types.Gdk_Modifier_Type;
348      Tmp_Return : Gdk.Gdk_Window;
349   begin
350      Tmp_Return := Internal (Self, Get_Object (Device), Acc_X'Access, Acc_Y'Access, Acc_Mask'Access);
351      X := Acc_X;
352      Y := Acc_Y;
353      Mask := Acc_Mask;
354      Window := Tmp_Return;
355   end Get_Device_Position;
356
357   --------------------------------
358   -- Get_Device_Position_Double --
359   --------------------------------
360
361   function Get_Device_Position_Double
362      (Self   : Gdk.Gdk_Window;
363       Device : not null access Gdk.Device.Gdk_Device_Record'Class;
364       X      : access Gdouble;
365       Y      : access Gdouble;
366       Mask   : access Gdk.Types.Gdk_Modifier_Type) return Gdk.Gdk_Window
367   is
368      function Internal
369         (Self     : Gdk.Gdk_Window;
370          Device   : System.Address;
371          Acc_X    : access Gdouble;
372          Acc_Y    : access Gdouble;
373          Acc_Mask : access Gdk.Types.Gdk_Modifier_Type)
374          return Gdk.Gdk_Window;
375      pragma Import (C, Internal, "gdk_window_get_device_position_double");
376      Acc_X      : aliased Gdouble;
377      Acc_Y      : aliased Gdouble;
378      Acc_Mask   : aliased Gdk.Types.Gdk_Modifier_Type;
379      Tmp_Return : Gdk.Gdk_Window;
380   begin
381      Tmp_Return := Internal (Self, Get_Object (Device), Acc_X'Access, Acc_Y'Access, Acc_Mask'Access);
382      if X /= null then
383         X.all := Acc_X;
384      end if;
385      if Y /= null then
386         Y.all := Acc_Y;
387      end if;
388      if Mask /= null then
389         Mask.all := Acc_Mask;
390      end if;
391      return Tmp_Return;
392   end Get_Device_Position_Double;
393
394   -----------------
395   -- Get_Display --
396   -----------------
397
398   function Get_Display
399      (Self : Gdk.Gdk_Window) return Gdk.Display.Gdk_Display
400   is
401      function Internal (Self : Gdk.Gdk_Window) return System.Address;
402      pragma Import (C, Internal, "gdk_window_get_display");
403      Stub_Gdk_Display : Gdk.Display.Gdk_Display_Record;
404   begin
405      return Gdk.Display.Gdk_Display (Get_User_Data (Internal (Self), Stub_Gdk_Display));
406   end Get_Display;
407
408   ---------------------------
409   -- Get_Event_Compression --
410   ---------------------------
411
412   function Get_Event_Compression (Self : Gdk.Gdk_Window) return Boolean is
413      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
414      pragma Import (C, Internal, "gdk_window_get_event_compression");
415   begin
416      return Internal (Self) /= 0;
417   end Get_Event_Compression;
418
419   ----------------------
420   -- Get_Focus_On_Map --
421   ----------------------
422
423   function Get_Focus_On_Map (Self : Gdk.Gdk_Window) return Boolean is
424      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
425      pragma Import (C, Internal, "gdk_window_get_focus_on_map");
426   begin
427      return Internal (Self) /= 0;
428   end Get_Focus_On_Map;
429
430   ---------------------
431   -- Get_Frame_Clock --
432   ---------------------
433
434   function Get_Frame_Clock
435      (Self : Gdk.Gdk_Window) return Gdk.Frame_Clock.Gdk_Frame_Clock
436   is
437      function Internal (Self : Gdk.Gdk_Window) return System.Address;
438      pragma Import (C, Internal, "gdk_window_get_frame_clock");
439      Stub_Gdk_Frame_Clock : Gdk.Frame_Clock.Gdk_Frame_Clock_Record;
440   begin
441      return Gdk.Frame_Clock.Gdk_Frame_Clock (Get_User_Data (Internal (Self), Stub_Gdk_Frame_Clock));
442   end Get_Frame_Clock;
443
444   --------------------
445   -- Get_Modal_Hint --
446   --------------------
447
448   function Get_Modal_Hint (Self : Gdk.Gdk_Window) return Boolean is
449      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
450      pragma Import (C, Internal, "gdk_window_get_modal_hint");
451   begin
452      return Internal (Self) /= 0;
453   end Get_Modal_Hint;
454
455   -----------------
456   -- Get_Pointer --
457   -----------------
458
459   procedure Get_Pointer
460      (Self   : Gdk.Gdk_Window;
461       X      : out Gint;
462       Y      : out Gint;
463       Mask   : out Gdk.Types.Gdk_Modifier_Type;
464       Window : out Gdk.Gdk_Window)
465   is
466      function Internal
467         (Self     : Gdk.Gdk_Window;
468          Acc_X    : access Gint;
469          Acc_Y    : access Gint;
470          Acc_Mask : access Gdk.Types.Gdk_Modifier_Type)
471          return Gdk.Gdk_Window;
472      pragma Import (C, Internal, "gdk_window_get_pointer");
473      Acc_X      : aliased Gint;
474      Acc_Y      : aliased Gint;
475      Acc_Mask   : aliased Gdk.Types.Gdk_Modifier_Type;
476      Tmp_Return : Gdk.Gdk_Window;
477   begin
478      Tmp_Return := Internal (Self, Acc_X'Access, Acc_Y'Access, Acc_Mask'Access);
479      X := Acc_X;
480      Y := Acc_Y;
481      Mask := Acc_Mask;
482      Window := Tmp_Return;
483   end Get_Pointer;
484
485   ----------------
486   -- Get_Screen --
487   ----------------
488
489   function Get_Screen (Self : Gdk.Gdk_Window) return Gdk.Screen.Gdk_Screen is
490      function Internal (Self : Gdk.Gdk_Window) return System.Address;
491      pragma Import (C, Internal, "gdk_window_get_screen");
492      Stub_Gdk_Screen : Gdk.Screen.Gdk_Screen_Record;
493   begin
494      return Gdk.Screen.Gdk_Screen (Get_User_Data (Internal (Self), Stub_Gdk_Screen));
495   end Get_Screen;
496
497   -----------------------------
498   -- Get_Support_Multidevice --
499   -----------------------------
500
501   function Get_Support_Multidevice (Self : Gdk.Gdk_Window) return Boolean is
502      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
503      pragma Import (C, Internal, "gdk_window_get_support_multidevice");
504   begin
505      return Internal (Self) /= 0;
506   end Get_Support_Multidevice;
507
508   ----------------
509   -- Has_Native --
510   ----------------
511
512   function Has_Native (Self : Gdk.Gdk_Window) return Boolean is
513      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
514      pragma Import (C, Internal, "gdk_window_has_native");
515   begin
516      return Internal (Self) /= 0;
517   end Has_Native;
518
519   ------------------------------
520   -- Invalidate_Maybe_Recurse --
521   ------------------------------
522
523   procedure Invalidate_Maybe_Recurse
524      (Self       : Gdk.Gdk_Window;
525       Region     : Cairo.Region.Cairo_Region;
526       Child_Func : Gdk_Window_Child_Func)
527   is
528   begin
529      if Child_Func = null then
530         C_Gdk_Window_Invalidate_Maybe_Recurse (Self, Region, System.Null_Address, System.Null_Address);
531      else
532         C_Gdk_Window_Invalidate_Maybe_Recurse (Self, Region, Internal_Gdk_Window_Child_Func'Address, To_Address (Child_Func));
533      end if;
534   end Invalidate_Maybe_Recurse;
535
536   package body Invalidate_Maybe_Recurse_User_Data is
537
538      package Users is new Glib.Object.User_Data_Closure
539        (User_Data_Type, Destroy);
540
541      function To_Gdk_Window_Child_Func is new Ada.Unchecked_Conversion
542        (System.Address, Gdk_Window_Child_Func);
543
544      function To_Address is new Ada.Unchecked_Conversion
545        (Gdk_Window_Child_Func, System.Address);
546
547      function Internal_Cb
548         (Window    : Gdk.Gdk_Window;
549          User_Data : System.Address) return Glib.Gboolean;
550      pragma Convention (C, Internal_Cb);
551      --  A function of this type is passed to
552      --  Gdk.Window.Invalidate_Maybe_Recurse. It gets called for each child of
553      --  the window to determine whether to recursively invalidate it or now.
554      --  "window": a Gdk.Gdk_Window
555      --  "user_data": user data
556
557      -----------------
558      -- Internal_Cb --
559      -----------------
560
561      function Internal_Cb
562         (Window    : Gdk.Gdk_Window;
563          User_Data : System.Address) return Glib.Gboolean
564      is
565         D : constant Users.Internal_Data_Access := Users.Convert (User_Data);
566      begin
567         return Boolean'Pos (To_Gdk_Window_Child_Func (D.Func) (Window, D.Data.all));
568      end Internal_Cb;
569
570      ------------------------------
571      -- Invalidate_Maybe_Recurse --
572      ------------------------------
573
574      procedure Invalidate_Maybe_Recurse
575         (Self       : Gdk.Gdk_Window;
576          Region     : Cairo.Region.Cairo_Region;
577          Child_Func : Gdk_Window_Child_Func;
578          User_Data  : User_Data_Type)
579      is
580      begin
581         if Child_Func = null then
582            C_Gdk_Window_Invalidate_Maybe_Recurse (Self, Region, System.Null_Address, System.Null_Address);
583         else
584            C_Gdk_Window_Invalidate_Maybe_Recurse (Self, Region, Internal_Cb'Address, Users.Build (To_Address (Child_Func), User_Data));
585         end if;
586      end Invalidate_Maybe_Recurse;
587
588   end Invalidate_Maybe_Recurse_User_Data;
589
590   ---------------------
591   -- Invalidate_Rect --
592   ---------------------
593
594   procedure Invalidate_Rect
595      (Self                : Gdk.Gdk_Window;
596       Rect                : Gdk.Rectangle.Gdk_Rectangle;
597       Invalidate_Children : Boolean)
598   is
599      procedure Internal
600         (Self                : Gdk.Gdk_Window;
601          Rect                : Gdk.Rectangle.Gdk_Rectangle;
602          Invalidate_Children : Glib.Gboolean);
603      pragma Import (C, Internal, "gdk_window_invalidate_rect");
604   begin
605      Internal (Self, Rect, Boolean'Pos (Invalidate_Children));
606   end Invalidate_Rect;
607
608   -----------------------
609   -- Invalidate_Region --
610   -----------------------
611
612   procedure Invalidate_Region
613      (Self                : Gdk.Gdk_Window;
614       Region              : Cairo.Region.Cairo_Region;
615       Invalidate_Children : Boolean)
616   is
617      procedure Internal
618         (Self                : Gdk.Gdk_Window;
619          Region              : Cairo.Region.Cairo_Region;
620          Invalidate_Children : Glib.Gboolean);
621      pragma Import (C, Internal, "gdk_window_invalidate_region");
622   begin
623      Internal (Self, Region, Boolean'Pos (Invalidate_Children));
624   end Invalidate_Region;
625
626   ------------------
627   -- Is_Destroyed --
628   ------------------
629
630   function Is_Destroyed (Self : Gdk.Gdk_Window) return Boolean is
631      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
632      pragma Import (C, Internal, "gdk_window_is_destroyed");
633   begin
634      return Internal (Self) /= 0;
635   end Is_Destroyed;
636
637   -------------------
638   -- Is_Input_Only --
639   -------------------
640
641   function Is_Input_Only (Self : Gdk.Gdk_Window) return Boolean is
642      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
643      pragma Import (C, Internal, "gdk_window_is_input_only");
644   begin
645      return Internal (Self) /= 0;
646   end Is_Input_Only;
647
648   ---------------
649   -- Is_Shaped --
650   ---------------
651
652   function Is_Shaped (Self : Gdk.Gdk_Window) return Boolean is
653      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
654      pragma Import (C, Internal, "gdk_window_is_shaped");
655   begin
656      return Internal (Self) /= 0;
657   end Is_Shaped;
658
659   -----------------
660   -- Is_Viewable --
661   -----------------
662
663   function Is_Viewable (Self : Gdk.Gdk_Window) return Boolean is
664      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
665      pragma Import (C, Internal, "gdk_window_is_viewable");
666   begin
667      return Internal (Self) /= 0;
668   end Is_Viewable;
669
670   ----------------
671   -- Is_Visible --
672   ----------------
673
674   function Is_Visible (Self : Gdk.Gdk_Window) return Boolean is
675      function Internal (Self : Gdk.Gdk_Window) return Glib.Gboolean;
676      pragma Import (C, Internal, "gdk_window_is_visible");
677   begin
678      return Internal (Self) /= 0;
679   end Is_Visible;
680
681   -------------------
682   -- Peek_Children --
683   -------------------
684
685   function Peek_Children
686      (Self : Gdk.Gdk_Window) return Gdk_Window_List.Glist
687   is
688      function Internal (Self : Gdk.Gdk_Window) return System.Address;
689      pragma Import (C, Internal, "gdk_window_peek_children");
690      Tmp_Return : Gdk_Window_List.Glist;
691   begin
692      Gdk.Window.Gdk_Window_List.Set_Object (Tmp_Return, Internal (Self));
693      return Tmp_Return;
694   end Peek_Children;
695
696   ---------------------
697   -- Process_Updates --
698   ---------------------
699
700   procedure Process_Updates
701      (Self            : Gdk.Gdk_Window;
702       Update_Children : Boolean)
703   is
704      procedure Internal
705         (Self            : Gdk.Gdk_Window;
706          Update_Children : Glib.Gboolean);
707      pragma Import (C, Internal, "gdk_window_process_updates");
708   begin
709      Internal (Self, Boolean'Pos (Update_Children));
710   end Process_Updates;
711
712   -------------
713   -- Restack --
714   -------------
715
716   procedure Restack
717      (Self    : Gdk.Gdk_Window;
718       Sibling : Gdk.Gdk_Window;
719       Above   : Boolean)
720   is
721      procedure Internal
722         (Self    : Gdk.Gdk_Window;
723          Sibling : Gdk.Gdk_Window;
724          Above   : Glib.Gboolean);
725      pragma Import (C, Internal, "gdk_window_restack");
726   begin
727      Internal (Self, Sibling, Boolean'Pos (Above));
728   end Restack;
729
730   ----------------------
731   -- Set_Accept_Focus --
732   ----------------------
733
734   procedure Set_Accept_Focus
735      (Self         : Gdk.Gdk_Window;
736       Accept_Focus : Boolean)
737   is
738      procedure Internal
739         (Self         : Gdk.Gdk_Window;
740          Accept_Focus : Glib.Gboolean);
741      pragma Import (C, Internal, "gdk_window_set_accept_focus");
742   begin
743      Internal (Self, Boolean'Pos (Accept_Focus));
744   end Set_Accept_Focus;
745
746   --------------------
747   -- Set_Composited --
748   --------------------
749
750   procedure Set_Composited (Self : Gdk.Gdk_Window; Composited : Boolean) is
751      procedure Internal (Self : Gdk.Gdk_Window; Composited : Glib.Gboolean);
752      pragma Import (C, Internal, "gdk_window_set_composited");
753   begin
754      Internal (Self, Boolean'Pos (Composited));
755   end Set_Composited;
756
757   -----------------------
758   -- Set_Device_Cursor --
759   -----------------------
760
761   procedure Set_Device_Cursor
762      (Self   : Gdk.Gdk_Window;
763       Device : not null access Gdk.Device.Gdk_Device_Record'Class;
764       Cursor : Gdk.Gdk_Cursor)
765   is
766      procedure Internal
767         (Self   : Gdk.Gdk_Window;
768          Device : System.Address;
769          Cursor : Gdk.Gdk_Cursor);
770      pragma Import (C, Internal, "gdk_window_set_device_cursor");
771   begin
772      Internal (Self, Get_Object (Device), Cursor);
773   end Set_Device_Cursor;
774
775   -----------------------
776   -- Set_Device_Events --
777   -----------------------
778
779   procedure Set_Device_Events
780      (Self       : Gdk.Gdk_Window;
781       Device     : not null access Gdk.Device.Gdk_Device_Record'Class;
782       Event_Mask : Gdk.Event.Gdk_Event_Mask)
783   is
784      procedure Internal
785         (Self       : Gdk.Gdk_Window;
786          Device     : System.Address;
787          Event_Mask : Gdk.Event.Gdk_Event_Mask);
788      pragma Import (C, Internal, "gdk_window_set_device_events");
789   begin
790      Internal (Self, Get_Object (Device), Event_Mask);
791   end Set_Device_Events;
792
793   ---------------------------
794   -- Set_Event_Compression --
795   ---------------------------
796
797   procedure Set_Event_Compression
798      (Self              : Gdk.Gdk_Window;
799       Event_Compression : Boolean)
800   is
801      procedure Internal
802         (Self              : Gdk.Gdk_Window;
803          Event_Compression : Glib.Gboolean);
804      pragma Import (C, Internal, "gdk_window_set_event_compression");
805   begin
806      Internal (Self, Boolean'Pos (Event_Compression));
807   end Set_Event_Compression;
808
809   ----------------------
810   -- Set_Focus_On_Map --
811   ----------------------
812
813   procedure Set_Focus_On_Map
814      (Self         : Gdk.Gdk_Window;
815       Focus_On_Map : Boolean)
816   is
817      procedure Internal
818         (Self         : Gdk.Gdk_Window;
819          Focus_On_Map : Glib.Gboolean);
820      pragma Import (C, Internal, "gdk_window_set_focus_on_map");
821   begin
822      Internal (Self, Boolean'Pos (Focus_On_Map));
823   end Set_Focus_On_Map;
824
825   -------------------
826   -- Set_Icon_Name --
827   -------------------
828
829   procedure Set_Icon_Name (Self : Gdk.Gdk_Window; Name : UTF8_String := "") is
830      procedure Internal
831         (Self : Gdk.Gdk_Window;
832          Name : Interfaces.C.Strings.chars_ptr);
833      pragma Import (C, Internal, "gdk_window_set_icon_name");
834      Tmp_Name : Interfaces.C.Strings.chars_ptr;
835   begin
836      if Name = "" then
837         Tmp_Name := Interfaces.C.Strings.Null_Ptr;
838      else
839         Tmp_Name := New_String (Name);
840      end if;
841      Internal (Self, Tmp_Name);
842      Free (Tmp_Name);
843   end Set_Icon_Name;
844
845   ----------------------------
846   -- Set_Invalidate_Handler --
847   ----------------------------
848
849   procedure Set_Invalidate_Handler
850      (Self    : Gdk.Gdk_Window;
851       Handler : Gdk_Window_Invalidate_Handler_Func)
852   is
853   begin
854      if Handler = null then
855         C_Gdk_Window_Set_Invalidate_Handler (Self, System.Null_Address);
856      else
857         C_Gdk_Window_Set_Invalidate_Handler (Self, Handler'Address);
858      end if;
859   end Set_Invalidate_Handler;
860
861   --------------------
862   -- Set_Keep_Above --
863   --------------------
864
865   procedure Set_Keep_Above (Self : Gdk.Gdk_Window; Setting : Boolean) is
866      procedure Internal (Self : Gdk.Gdk_Window; Setting : Glib.Gboolean);
867      pragma Import (C, Internal, "gdk_window_set_keep_above");
868   begin
869      Internal (Self, Boolean'Pos (Setting));
870   end Set_Keep_Above;
871
872   --------------------
873   -- Set_Keep_Below --
874   --------------------
875
876   procedure Set_Keep_Below (Self : Gdk.Gdk_Window; Setting : Boolean) is
877      procedure Internal (Self : Gdk.Gdk_Window; Setting : Glib.Gboolean);
878      pragma Import (C, Internal, "gdk_window_set_keep_below");
879   begin
880      Internal (Self, Boolean'Pos (Setting));
881   end Set_Keep_Below;
882
883   --------------------
884   -- Set_Modal_Hint --
885   --------------------
886
887   procedure Set_Modal_Hint (Self : Gdk.Gdk_Window; Modal : Boolean) is
888      procedure Internal (Self : Gdk.Gdk_Window; Modal : Glib.Gboolean);
889      pragma Import (C, Internal, "gdk_window_set_modal_hint");
890   begin
891      Internal (Self, Boolean'Pos (Modal));
892   end Set_Modal_Hint;
893
894   ---------------------------
895   -- Set_Override_Redirect --
896   ---------------------------
897
898   procedure Set_Override_Redirect
899      (Self              : Gdk.Gdk_Window;
900       Override_Redirect : Boolean)
901   is
902      procedure Internal
903         (Self              : Gdk.Gdk_Window;
904          Override_Redirect : Glib.Gboolean);
905      pragma Import (C, Internal, "gdk_window_set_override_redirect");
906   begin
907      Internal (Self, Boolean'Pos (Override_Redirect));
908   end Set_Override_Redirect;
909
910   --------------
911   -- Set_Role --
912   --------------
913
914   procedure Set_Role (Self : Gdk.Gdk_Window; Role : UTF8_String) is
915      procedure Internal
916         (Self : Gdk.Gdk_Window;
917          Role : Interfaces.C.Strings.chars_ptr);
918      pragma Import (C, Internal, "gdk_window_set_role");
919      Tmp_Role : Interfaces.C.Strings.chars_ptr := New_String (Role);
920   begin
921      Internal (Self, Tmp_Role);
922      Free (Tmp_Role);
923   end Set_Role;
924
925   -------------------------
926   -- Set_Skip_Pager_Hint --
927   -------------------------
928
929   procedure Set_Skip_Pager_Hint
930      (Self        : Gdk.Gdk_Window;
931       Skips_Pager : Boolean)
932   is
933      procedure Internal
934         (Self        : Gdk.Gdk_Window;
935          Skips_Pager : Glib.Gboolean);
936      pragma Import (C, Internal, "gdk_window_set_skip_pager_hint");
937   begin
938      Internal (Self, Boolean'Pos (Skips_Pager));
939   end Set_Skip_Pager_Hint;
940
941   ---------------------------
942   -- Set_Skip_Taskbar_Hint --
943   ---------------------------
944
945   procedure Set_Skip_Taskbar_Hint
946      (Self          : Gdk.Gdk_Window;
947       Skips_Taskbar : Boolean)
948   is
949      procedure Internal
950         (Self          : Gdk.Gdk_Window;
951          Skips_Taskbar : Glib.Gboolean);
952      pragma Import (C, Internal, "gdk_window_set_skip_taskbar_hint");
953   begin
954      Internal (Self, Boolean'Pos (Skips_Taskbar));
955   end Set_Skip_Taskbar_Hint;
956
957   --------------------
958   -- Set_Startup_Id --
959   --------------------
960
961   procedure Set_Startup_Id
962      (Self       : Gdk.Gdk_Window;
963       Startup_Id : UTF8_String)
964   is
965      procedure Internal
966         (Self       : Gdk.Gdk_Window;
967          Startup_Id : Interfaces.C.Strings.chars_ptr);
968      pragma Import (C, Internal, "gdk_window_set_startup_id");
969      Tmp_Startup_Id : Interfaces.C.Strings.chars_ptr := New_String (Startup_Id);
970   begin
971      Internal (Self, Tmp_Startup_Id);
972      Free (Tmp_Startup_Id);
973   end Set_Startup_Id;
974
975   --------------------------
976   -- Set_Static_Gravities --
977   --------------------------
978
979   function Set_Static_Gravities
980      (Self       : Gdk.Gdk_Window;
981       Use_Static : Boolean) return Boolean
982   is
983      function Internal
984         (Self       : Gdk.Gdk_Window;
985          Use_Static : Glib.Gboolean) return Glib.Gboolean;
986      pragma Import (C, Internal, "gdk_window_set_static_gravities");
987   begin
988      return Internal (Self, Boolean'Pos (Use_Static)) /= 0;
989   end Set_Static_Gravities;
990
991   -----------------------------
992   -- Set_Support_Multidevice --
993   -----------------------------
994
995   procedure Set_Support_Multidevice
996      (Self                : Gdk.Gdk_Window;
997       Support_Multidevice : Boolean)
998   is
999      procedure Internal
1000         (Self                : Gdk.Gdk_Window;
1001          Support_Multidevice : Glib.Gboolean);
1002      pragma Import (C, Internal, "gdk_window_set_support_multidevice");
1003   begin
1004      Internal (Self, Boolean'Pos (Support_Multidevice));
1005   end Set_Support_Multidevice;
1006
1007   ---------------
1008   -- Set_Title --
1009   ---------------
1010
1011   procedure Set_Title (Self : Gdk.Gdk_Window; Title : UTF8_String) is
1012      procedure Internal
1013         (Self  : Gdk.Gdk_Window;
1014          Title : Interfaces.C.Strings.chars_ptr);
1015      pragma Import (C, Internal, "gdk_window_set_title");
1016      Tmp_Title : Interfaces.C.Strings.chars_ptr := New_String (Title);
1017   begin
1018      Internal (Self, Tmp_Title);
1019      Free (Tmp_Title);
1020   end Set_Title;
1021
1022   ----------------------
1023   -- Set_Urgency_Hint --
1024   ----------------------
1025
1026   procedure Set_Urgency_Hint (Self : Gdk.Gdk_Window; Urgent : Boolean) is
1027      procedure Internal (Self : Gdk.Gdk_Window; Urgent : Glib.Gboolean);
1028      pragma Import (C, Internal, "gdk_window_set_urgency_hint");
1029   begin
1030      Internal (Self, Boolean'Pos (Urgent));
1031   end Set_Urgency_Hint;
1032
1033   ----------------------
1034   -- Show_Window_Menu --
1035   ----------------------
1036
1037   function Show_Window_Menu
1038      (Self  : Gdk.Gdk_Window;
1039       Event : Gdk.Event.Gdk_Event) return Boolean
1040   is
1041      function Internal
1042         (Self  : Gdk.Gdk_Window;
1043          Event : Gdk.Event.Gdk_Event) return Glib.Gboolean;
1044      pragma Import (C, Internal, "gdk_window_show_window_menu");
1045   begin
1046      return Internal (Self, Event) /= 0;
1047   end Show_Window_Menu;
1048
1049   ----------------
1050   -- At_Pointer --
1051   ----------------
1052
1053   procedure At_Pointer
1054      (Win_X  : out Gint;
1055       Win_Y  : out Gint;
1056       Window : out Gdk.Gdk_Window)
1057   is
1058      function Internal
1059         (Acc_Win_X : access Gint;
1060          Acc_Win_Y : access Gint) return Gdk.Gdk_Window;
1061      pragma Import (C, Internal, "gdk_window_at_pointer");
1062      Acc_Win_X  : aliased Gint;
1063      Acc_Win_Y  : aliased Gint;
1064      Tmp_Return : Gdk.Gdk_Window;
1065   begin
1066      Tmp_Return := Internal (Acc_Win_X'Access, Acc_Win_Y'Access);
1067      Win_X := Acc_Win_X;
1068      Win_Y := Acc_Win_Y;
1069      Window := Tmp_Return;
1070   end At_Pointer;
1071
1072   -----------------------
1073   -- Set_Debug_Updates --
1074   -----------------------
1075
1076   procedure Set_Debug_Updates (Setting : Boolean) is
1077      procedure Internal (Setting : Glib.Gboolean);
1078      pragma Import (C, Internal, "gdk_window_set_debug_updates");
1079   begin
1080      Internal (Boolean'Pos (Setting));
1081   end Set_Debug_Updates;
1082
1083end Gdk.Window;
1084