Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gdk / gdkmm / display.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <gdkmm/display.h>
5 #include <gdkmm/private/display_p.h>
6
7 #include <gdk/gdkenumtypes.h>
8 // -*- c++ -*-
9 /* $Id$ */
10
11 /*
12  *
13  * Copyright 1998-2002 The gtkmm Development Team
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Library General Public
17  * License as published by the Free Software Foundation; either
18  * version 2 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * Library General Public License for more details.
24  *
25  * You should have received a copy of the GNU Library General Public
26  * License along with this library; if not, write to the Free
27  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28  */
29
30 #include <gdkmm/window.h>
31 #include <gdk/gdkdisplay.h>
32
33 namespace Gdk
34 {
35
36 bool Display::set_selection_owner(const Glib::RefPtr<Window>& owner, Glib::ustring& selection, guint32 time_, bool send_event)
37 {
38   return gdk_selection_owner_set_for_display(gobj(), owner->gobj(), Gdk::AtomString::to_c_type(selection), time_, (gboolean)send_event);
39 }
40
41 Glib::RefPtr<Window> Display::get_selection_owner(const Glib::ustring& selection)
42 {
43   return Glib::wrap( (GdkWindowObject*)gdk_selection_owner_get_for_display(gobj(), Gdk::AtomString::to_c_type(selection)) , true);
44 }
45
46 void Display::selection_send_notify(guint32 requestor, Glib::ustring& selection, Glib::ustring& target, Glib::ustring& property, guint32 time_)
47 {
48   gdk_selection_send_notify_for_display(gobj(), requestor, Gdk::AtomString::to_c_type(selection), Gdk::AtomString::to_c_type(target), Gdk::AtomString::to_c_type(property), time_);
49 }
50
51 void Display::get_pointer(Glib::RefPtr<Screen>& screen, int& x, int& y, ModifierType& mask)
52 {
53   GdkScreen* cScreen = 0;
54   GdkModifierType cMask = (GdkModifierType)mask;
55   gdk_display_get_pointer(gobj(), &cScreen, &x, &y, &cMask);
56   screen = Glib::wrap(cScreen);
57   mask = (ModifierType)cMask;
58 }
59
60 void Display::get_pointer(int& x, int& y, ModifierType& mask)
61 {
62   GdkModifierType cMask = (GdkModifierType)mask;
63   gdk_display_get_pointer(gobj(), 0, &x, &y, &cMask);
64   mask = (ModifierType)cMask;
65 }
66
67
68 Glib::RefPtr<Window> Display::get_window_at_pointer()
69 {
70
71   Glib::RefPtr<Window> retvalue = Glib::wrap((GdkWindowObject*)(gdk_display_get_window_at_pointer(gobj(), 0, 0)));
72
73   if(retvalue)
74     retvalue->reference(); //The function does not do a ref for us.
75   return retvalue;
76 }
77
78 Glib::RefPtr<const Window> Display::get_window_at_pointer() const
79 {
80
81   Glib::RefPtr<const Window> retvalue = Glib::wrap((GdkWindowObject*)(gdk_display_get_window_at_pointer(const_cast<GdkDisplay*>(gobj()), 0, 0)));
82
83   if(retvalue)
84     retvalue->reference(); //The function does not do a ref for us.
85   return retvalue;
86 }
87
88 GdkDisplayPointerHooks*  Display::unset_pointer_hooks()
89 {
90   return gdk_display_set_pointer_hooks(gobj(), 0 /* See GDK docs */);  
91 }
92
93  void Display::store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_)
94  {
95    gdk_display_store_clipboard(gobj(), clipboard_window->gobj(), time_, 0 /* see the C docs */, 0);
96  }
97   
98  void Display::store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_, const Glib::StringArrayHandle& targets)
99  {
100    //Put it into a real container that we can use:
101    std::vector<Glib::ustring> targets_copy = targets;
102    
103    //Create array of target GdkAtoms from target strings:
104    if(!targets_copy.empty())
105    {
106      GdkAtom* pAtoms = new GdkAtom[targets_copy.size()];
107      
108      for(guint i = 0; i < targets_copy.size(); ++i)
109      {
110        *pAtoms = Gdk::AtomString::to_c_type(targets_copy[i]);
111      }
112  
113      gdk_display_store_clipboard(gobj(), clipboard_window->gobj(), time_, 0 /* see the C docs */, 0);
114      
115      delete[] pAtoms;
116    }
117  }
118
119 } //Gdk
120
121
122 namespace
123 {
124
125
126 static void Display_signal_closed_callback(GdkDisplay* self, gboolean p0,void* data)
127 {
128   using namespace Gdk;
129   typedef sigc::slot< void,bool > SlotType;
130
131   // Do not try to call a signal on a disassociated wrapper.
132   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
133   {
134     #ifdef GLIBMM_EXCEPTIONS_ENABLED
135     try
136     {
137     #endif //GLIBMM_EXCEPTIONS_ENABLED
138       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
139         (*static_cast<SlotType*>(slot))(p0
140 );
141     #ifdef GLIBMM_EXCEPTIONS_ENABLED
142     }
143     catch(...)
144     {
145       Glib::exception_handlers_invoke();
146     }
147     #endif //GLIBMM_EXCEPTIONS_ENABLED
148   }
149 }
150
151 static const Glib::SignalProxyInfo Display_signal_closed_info =
152 {
153   "closed",
154   (GCallback) &Display_signal_closed_callback,
155   (GCallback) &Display_signal_closed_callback
156 };
157
158
159 } // anonymous namespace
160
161
162 namespace Glib
163 {
164
165 Glib::RefPtr<Gdk::Display> wrap(GdkDisplay* object, bool take_copy)
166 {
167   return Glib::RefPtr<Gdk::Display>( dynamic_cast<Gdk::Display*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
168   //We use dynamic_cast<> in case of multiple inheritance.
169 }
170
171 } /* namespace Glib */
172
173
174 namespace Gdk
175 {
176
177
178 /* The *_Class implementation: */
179
180 const Glib::Class& Display_Class::init()
181 {
182   if(!gtype_) // create the GType if necessary
183   {
184     // Glib::Class has to know the class init function to clone custom types.
185     class_init_func_ = &Display_Class::class_init_function;
186
187     // This is actually just optimized away, apparently with no harm.
188     // Make sure that the parent type has been created.
189     //CppClassParent::CppObjectType::get_type();
190
191     // Create the wrapper type, with the same class/instance size as the base type.
192     register_derived_type(gdk_display_get_type());
193
194     // Add derived versions of interfaces, if the C type implements any interfaces:
195   }
196
197   return *this;
198 }
199
200 void Display_Class::class_init_function(void* g_class, void* class_data)
201 {
202   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
203   CppClassParent::class_init_function(klass, class_data);
204
205 #ifdef GLIBMM_VFUNCS_ENABLED
206 #endif //GLIBMM_VFUNCS_ENABLED
207
208 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
209   klass->closed = &closed_callback;
210 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
211 }
212
213 #ifdef GLIBMM_VFUNCS_ENABLED
214 #endif //GLIBMM_VFUNCS_ENABLED
215
216 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
217 void Display_Class::closed_callback(GdkDisplay* self, gboolean p0)
218 {
219   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
220       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
221
222   // Non-gtkmmproc-generated custom classes implicitly call the default
223   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
224   // generated classes can use this optimisation, which avoids the unnecessary
225   // parameter conversions if there is no possibility of the virtual function
226   // being overridden:
227   if(obj_base && obj_base->is_derived_())
228   {
229     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
230     if(obj) // This can be NULL during destruction.
231     {
232       #ifdef GLIBMM_EXCEPTIONS_ENABLED
233       try // Trap C++ exceptions which would normally be lost because this is a C callback.
234       {
235       #endif //GLIBMM_EXCEPTIONS_ENABLED
236         // Call the virtual member method, which derived classes might override.
237         obj->on_closed(p0
238 );
239         return;
240       #ifdef GLIBMM_EXCEPTIONS_ENABLED
241       }
242       catch(...)
243       {
244         Glib::exception_handlers_invoke();
245       }
246       #endif //GLIBMM_EXCEPTIONS_ENABLED
247     }
248   }
249   
250   BaseClassType *const base = static_cast<BaseClassType*>(
251         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
252     );
253
254   // Call the original underlying C function:
255   if(base && base->closed)
256     (*base->closed)(self, p0);
257 }
258 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
259
260
261 Glib::ObjectBase* Display_Class::wrap_new(GObject* object)
262 {
263   return new Display((GdkDisplay*)object);
264 }
265
266
267 /* The implementation: */
268
269 GdkDisplay* Display::gobj_copy()
270 {
271   reference();
272   return gobj();
273 }
274
275 Display::Display(const Glib::ConstructParams& construct_params)
276 :
277   Glib::Object(construct_params)
278 {}
279
280 Display::Display(GdkDisplay* castitem)
281 :
282   Glib::Object((GObject*)(castitem))
283 {}
284
285 Display::~Display()
286 {}
287
288
289 Display::CppClassType Display::display_class_; // initialize static member
290
291 GType Display::get_type()
292 {
293   return display_class_.init().get_type();
294 }
295
296 GType Display::get_base_type()
297 {
298   return gdk_display_get_type();
299 }
300
301
302 Display::Display()
303 :
304   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
305   Glib::ObjectBase(0),
306   Glib::Object(Glib::ConstructParams(display_class_.init()))
307 {
308   }
309
310 Glib::RefPtr<Display> Display::open(const Glib::ustring& display_name)
311 {
312
313   Glib::RefPtr<Display> retvalue = Glib::wrap(gdk_display_open(display_name.c_str()));
314
315   if(retvalue)
316     retvalue->reference(); //The function does not do a ref for us.
317   return retvalue;
318 }
319
320
321 Glib::ustring Display::get_name() const
322 {
323   return Glib::convert_const_gchar_ptr_to_ustring(gdk_display_get_name(const_cast<GdkDisplay*>(gobj())));
324 }
325
326 int Display::get_n_screens() const
327 {
328   return gdk_display_get_n_screens(const_cast<GdkDisplay*>(gobj()));
329 }
330
331 Glib::RefPtr<Screen> Display::get_screen(int screen_num)
332 {
333
334   Glib::RefPtr<Screen> retvalue = Glib::wrap(gdk_display_get_screen(gobj(), screen_num));
335   if(retvalue)
336     retvalue->reference(); //The function does not do a ref for us.
337   return retvalue;
338
339 }
340
341 Glib::RefPtr<const Screen> Display::get_screen(int screen_num) const
342 {
343   return const_cast<Display*>(this)->get_screen(screen_num);
344 }
345
346 Glib::RefPtr<Screen> Display::get_default_screen()
347 {
348
349   Glib::RefPtr<Screen> retvalue = Glib::wrap(gdk_display_get_default_screen(gobj()));
350   if(retvalue)
351     retvalue->reference(); //The function does not do a ref for us.
352   return retvalue;
353
354 }
355
356 Glib::RefPtr<const Screen> Display::get_default_screen() const
357 {
358   return const_cast<Display*>(this)->get_default_screen();
359 }
360
361 void Display::pointer_ungrab(guint32 timestamp)
362 {
363 gdk_display_pointer_ungrab(gobj(), timestamp); 
364 }
365
366 void Display::keyboard_ungrab(guint32 timestamp)
367 {
368 gdk_display_keyboard_ungrab(gobj(), timestamp); 
369 }
370
371 bool Display::pointer_is_grabbed() const
372 {
373   return gdk_display_pointer_is_grabbed(const_cast<GdkDisplay*>(gobj()));
374 }
375
376 void Display::beep()
377 {
378 gdk_display_beep(gobj()); 
379 }
380
381 void Display::sync()
382 {
383 gdk_display_sync(gobj()); 
384 }
385
386 void Display::close()
387 {
388 gdk_display_close(gobj()); 
389 }
390
391 Glib::ListHandle< Glib::RefPtr<Device> > Display::list_devices()
392 {
393   return Glib::ListHandle< Glib::RefPtr<Device> >(gdk_display_list_devices(gobj()), Glib::OWNERSHIP_NONE);
394 }
395
396 Glib::ListHandle< Glib::RefPtr<const Device> > Display::list_devices() const
397 {
398   return Glib::ListHandle< Glib::RefPtr<const Device> >(gdk_display_list_devices(const_cast<GdkDisplay*>(gobj())), Glib::OWNERSHIP_NONE);
399 }
400
401 GdkEvent* Display::get_event()
402 {
403   return gdk_display_get_event(gobj());
404 }
405
406 const GdkEvent* Display::get_event() const
407 {
408   return const_cast<Display*>(this)->get_event();
409 }
410
411 GdkEvent* Display::peek_event()
412 {
413   return gdk_display_peek_event(gobj());
414 }
415
416 GdkEvent* Display::peek_event() const
417 {
418   return const_cast<Display*>(this)->peek_event();
419 }
420
421 void Display::put_event(GdkEvent* event)
422 {
423 gdk_display_put_event(gobj(), event); 
424 }
425
426 void Display::add_client_message_filter(Glib::ustring& message_type, GdkFilterFunc func, gpointer data)
427 {
428 gdk_display_add_client_message_filter(gobj(), Gdk::AtomString::to_c_type(message_type), func, data); 
429 }
430
431 void Display::set_double_click_time(guint msec)
432 {
433 gdk_display_set_double_click_time(gobj(), msec); 
434 }
435
436 void Display::set_double_click_distance(guint distance)
437 {
438 gdk_display_set_double_click_distance(gobj(), distance); 
439 }
440
441 Glib::RefPtr<Display> Display::get_default()
442 {
443
444   Glib::RefPtr<Display> retvalue = Glib::wrap(gdk_display_get_default());
445
446   if(retvalue)
447     retvalue->reference(); //The function does not do a ref for us.
448   return retvalue;
449 }
450
451
452 Glib::RefPtr<Device> Display::get_core_pointer()
453 {
454
455   Glib::RefPtr<Device> retvalue = Glib::wrap(gdk_display_get_core_pointer(gobj()));
456   if(retvalue)
457     retvalue->reference(); //The function does not do a ref for us.
458   return retvalue;
459
460 }
461
462 Glib::RefPtr<const Device> Display::get_core_pointer() const
463 {
464
465   Glib::RefPtr<const Device> retvalue = Glib::wrap(gdk_display_get_core_pointer(const_cast<GdkDisplay*>(gobj())));
466   if(retvalue)
467     retvalue->reference(); //The function does not do a ref for us.
468   return retvalue;
469
470 }
471
472 Glib::RefPtr<Window> Display::get_window_at_pointer(int& win_x, int& win_y)
473 {
474
475   Glib::RefPtr<Window> retvalue = Glib::wrap((GdkWindowObject*)(gdk_display_get_window_at_pointer(gobj(), &win_x, &win_y)));
476   if(retvalue)
477     retvalue->reference(); //The function does not do a ref for us.
478   return retvalue;
479
480 }
481
482 Glib::RefPtr<const Window> Display::get_window_at_pointer(int& win_x, int& win_y) const
483 {
484   return const_cast<Display*>(this)->get_window_at_pointer(win_x, win_y);
485 }
486
487 void Display::warp_pointer(const Glib::RefPtr<Screen>& screen, int x, int y)
488 {
489 gdk_display_warp_pointer(gobj(), Glib::unwrap(screen), x, y); 
490 }
491
492 GdkDisplayPointerHooks* Display::set_pointer_hooks(const GdkDisplayPointerHooks* new_hooks)
493 {
494   return gdk_display_set_pointer_hooks(gobj(), new_hooks);
495 }
496
497 Glib::RefPtr<Display> Display::open_default_libgtk_only()
498 {
499
500   Glib::RefPtr<Display> retvalue = Glib::wrap(gdk_display_open_default_libgtk_only());
501
502   if(retvalue)
503     retvalue->reference(); //The function does not do a ref for us.
504   return retvalue;
505 }
506
507
508 guint32 Display::get_drag_protocol(guint32 xid, GdkDragProtocol& protocol)
509 {
510   return gdk_drag_get_protocol_for_display(gobj(), xid, &(protocol));
511 }
512
513 GdkKeymap* Display::get_keymap()
514 {
515   return gdk_keymap_get_for_display(gobj());
516 }
517
518 const GdkKeymap* Display::get_keymap() const
519 {
520   return const_cast<Display*>(this)->get_keymap();
521 }
522
523 Glib::RefPtr<Pixmap> Display::lookup_pixmap(NativeWindow anid)
524 {
525   return Glib::wrap((GdkPixmapObject*)(gdk_pixmap_lookup_for_display(gobj(), (GdkNativeWindow)(anid))));
526 }
527
528 Glib::RefPtr<const Pixmap> Display::lookup_pixmap(NativeWindow anid) const
529 {
530   return const_cast<Display*>(this)->lookup_pixmap(anid);
531 }
532
533 void Display::flush()
534 {
535 gdk_display_flush(gobj()); 
536 }
537
538 bool Display::supports_cursor_alpha() const
539 {
540   return gdk_display_supports_cursor_alpha(const_cast<GdkDisplay*>(gobj()));
541 }
542
543 bool Display::supports_cursor_color() const
544 {
545   return gdk_display_supports_cursor_color(const_cast<GdkDisplay*>(gobj()));
546 }
547
548 guint Display::get_default_cursor_size() const
549 {
550   return gdk_display_get_default_cursor_size(const_cast<GdkDisplay*>(gobj()));
551 }
552
553 void Display::get_maximal_cursor_size(guint& width, guint& height)
554 {
555 gdk_display_get_maximal_cursor_size(gobj(), &(width), &(height)); 
556 }
557
558 Glib::RefPtr<Window> Display::get_default_group()
559 {
560
561   Glib::RefPtr<Window> retvalue = Glib::wrap((GdkWindowObject*)(gdk_display_get_default_group(gobj())));
562   if(retvalue)
563     retvalue->reference(); //The function does not do a ref for us.
564   return retvalue;
565
566 }
567
568 Glib::RefPtr<const Window> Display::get_default_group() const
569 {
570   return const_cast<Display*>(this)->get_default_group();
571 }
572
573 bool Display::supports_selection_notification() const
574 {
575   return gdk_display_supports_selection_notification(const_cast<GdkDisplay*>(gobj()));
576 }
577
578 bool Display::request_selection_notification(const Glib::ustring& selection)
579 {
580   return gdk_display_request_selection_notification(gobj(), Gdk::AtomString::to_c_type(selection));
581 }
582
583 bool Display::supports_clipboard_persistence() const
584 {
585   return gdk_display_supports_clipboard_persistence(const_cast<GdkDisplay*>(gobj()));
586 }
587
588 bool Display::supports_shapes() const
589 {
590   return gdk_display_supports_shapes(const_cast<GdkDisplay*>(gobj()));
591 }
592
593 bool Display::supports_input_shapes() const
594 {
595   return gdk_display_supports_input_shapes(const_cast<GdkDisplay*>(gobj()));
596 }
597
598 bool Display::supports_composite() const
599 {
600   return gdk_display_supports_composite(const_cast<GdkDisplay*>(gobj()));
601 }
602
603
604 Glib::SignalProxy1< void,bool > Display::signal_closed()
605 {
606   return Glib::SignalProxy1< void,bool >(this, &Display_signal_closed_info);
607 }
608
609
610 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
611 void Gdk::Display::on_closed(bool is_error)
612 {
613   BaseClassType *const base = static_cast<BaseClassType*>(
614       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
615   );
616
617   if(base && base->closed)
618     (*base->closed)(gobj(),static_cast<int>(is_error));
619 }
620 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
621
622 #ifdef GLIBMM_VFUNCS_ENABLED
623 #endif //GLIBMM_VFUNCS_ENABLED
624
625
626 } // namespace Gdk
627
628