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