1/* $Id: display.hg,v 1.22 2006/04/12 11:11:24 murrayc Exp $ */
2
3/* display.h
4 *
5 * Copyright (C) 1998-2002 The gtkmm Development Team
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <gdkmm/screen.h>
23#include <gdkmm/device.h>
24#include <gdkmm/types.h> //For ModifierType
25_DEFS(gdkmm,gdk)
26_PINCLUDE(glibmm/private/object_p.h)
27
28
29namespace Gdk
30{
31
32_CC_INCLUDE(gdk/gdk.h)
33
34class Drawable;
35
36 /** Gdk::Display object's purpose is two fold:
37 *   To grab/ungrab keyboard focus and mouse pointer
38 *   To manage and provide information about the Gdk::Screen(s) available for this Gdk::Display
39 *
40 * Gdk::Display objects are the GDK representation of the X Display which can be described as a workstation consisting
41 * of a keyboard a pointing device (such as a mouse) and one or more screens. It is used to open and keep track of
42 * various Gdk::Screen objects currently instantiated by the application. It is also used to grab and release the keyboard
43 * and the mouse pointer.
44 */
45class Display : public Glib::Object
46{
47  _CLASS_GOBJECT(Display,GdkDisplay,GDK_DISPLAY,Glib::Object,GObject)
48protected:
49  _CTOR_DEFAULT
50
51public:
52  _WRAP_METHOD(static Glib::RefPtr<Display> open(const Glib::ustring& display_name), gdk_display_open, refreturn)
53
54  _WRAP_METHOD(Glib::ustring get_name() const, gdk_display_get_name)
55
56  _WRAP_METHOD(int get_n_screens() const, gdk_display_get_n_screens)
57  _WRAP_METHOD(Glib::RefPtr<Screen> get_screen(int screen_num), gdk_display_get_screen, refreturn)
58  _WRAP_METHOD(Glib::RefPtr<const Screen> get_screen(int screen_num) const, gdk_display_get_screen, refreturn, constversion)
59
60  _WRAP_METHOD(Glib::RefPtr<Screen> get_default_screen(), gdk_display_get_default_screen, refreturn)
61  _WRAP_METHOD(Glib::RefPtr<const Screen> get_default_screen() const, gdk_display_get_default_screen, refreturn, constversion)
62
63  _WRAP_METHOD(void pointer_ungrab(guint32 timestamp), gdk_display_pointer_ungrab)
64  _WRAP_METHOD(void keyboard_ungrab(guint32 timestamp), gdk_display_keyboard_ungrab)
65  _WRAP_METHOD(bool pointer_is_grabbed() const, gdk_display_pointer_is_grabbed)
66  _WRAP_METHOD(void beep(), gdk_display_beep)
67  _WRAP_METHOD(void sync(), gdk_display_sync)
68  _WRAP_METHOD(void	close(), gdk_display_close)
69
70  _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<Device> > list_devices(), gdk_display_list_devices)
71  _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<const Device> > list_devices() const, gdk_display_list_devices)
72
73  //TODO: Use C++ Gdk::Event:
74  //TODO: get_event() might remove the event - if so, then there should not be a const version:
75  _WRAP_METHOD(GdkEvent* get_event(), gdk_display_get_event)
76  _WRAP_METHOD(const GdkEvent* get_event() const, gdk_display_get_event, constversion)
77
78  _WRAP_METHOD(GdkEvent* peek_event(), gdk_display_peek_event)
79  _WRAP_METHOD(GdkEvent* peek_event() const, gdk_display_peek_event, constversion)
80  _WRAP_METHOD(void put_event(GdkEvent* event), gdk_display_put_event)
81
82  //TODO: Use a slot here, though this is probably never used anyway:
83  //Find out whether we can use a string representation for the atom - look for examples of this function's use.
84  _WRAP_METHOD(void add_client_message_filter(Glib::ustring& message_type, GdkFilterFunc func, gpointer data), gdk_display_add_client_message_filter)
85
86  _WRAP_METHOD(void set_double_click_time(guint msec), gdk_display_set_double_click_time)
87  _WRAP_METHOD(void set_double_click_distance(guint distance), gdk_display_set_double_click_distance)
88
89
90  _WRAP_METHOD(static Glib::RefPtr<Display> get_default(), gdk_display_get_default, refreturn)
91
92  _WRAP_METHOD(Glib::RefPtr<Device> get_core_pointer(), gdk_display_get_core_pointer, refreturn)
93  _WRAP_METHOD(Glib::RefPtr<const Device> get_core_pointer() const, gdk_display_get_core_pointer, refreturn)
94
95  /** Gets the current location of the pointer and the current modifier
96   * mask for a given display.
97   *
98   * @param screen location to store the screen that the cursor is on.
99   * @param x location to store root window X coordinate of pointer.
100   * @param y location to store root window Y coordinate of pointer.
101   * @param mask location to store current modifier mask.
102   *
103   **/
104  void get_pointer(Glib::RefPtr<Screen>& screen, int& x, int& y, ModifierType& mask);
105
106  // In fact, any one of these gdk_display_get_pointer() args can be NULL, but we don't need so many overloads.
107  /**
108   * Gets the current location of the pointer and the current modifier
109   * mask for a given display.
110   *
111   * @param x location to store root window X coordinate of pointer.
112   * @param y location to store root window Y coordinate of pointer.
113   * @param mask location to store current modifier mask.
114   *
115   **/
116  void get_pointer(int& x, int& y, ModifierType& mask);
117  _IGNORE(gdk_display_get_pointer)
118
119  _WRAP_METHOD(Glib::RefPtr<Window> get_window_at_pointer(int& win_x, int& win_y), gdk_display_get_window_at_pointer, refreturn)
120  _WRAP_METHOD(Glib::RefPtr<const Window> get_window_at_pointer(int& win_x, int& win_y) const, gdk_display_get_window_at_pointer, refreturn, constversion)
121
122  /** Obtains the window underneath the mouse pointer. Returns a null RefPtr if the window
123   * under the mouse pointer is not known to GDK (for example, belongs to
124   * another application).
125   * @result The window underneath the mouse pointer.
126   */
127  Glib::RefPtr<Window> get_window_at_pointer();
128
129  /** Obtains the window underneath the mouse pointer. Returns a null RefPtr if the window
130   * under the mouse pointer is not known to GDK (for example, belongs to
131   * another application).
132   * @result The window underneath the mouse pointer.
133   */
134  Glib::RefPtr<const Window> get_window_at_pointer() const;
135
136  _WRAP_METHOD(void warp_pointer(const Glib::RefPtr<Screen>& screen, int x, int y), gdk_display_warp_pointer)
137
138  _WRAP_METHOD(GdkDisplayPointerHooks* set_pointer_hooks(const GdkDisplayPointerHooks* new_hooks), gdk_display_set_pointer_hooks, deprecated)
139
140  _DEPRECATE_IFDEF_START
141  /** @deprecated This method has been removed in gtkmm-3.0 for lack of use cases.
142   */
143  GdkDisplayPointerHooks* unset_pointer_hooks();
144  _DEPRECATE_IFDEF_END
145
146  _WRAP_METHOD(static Glib::RefPtr<Display> open_default_libgtk_only(), gdk_display_open_default_libgtk_only, refreturn)
147
148#ifdef G_OS_WIN32
149_DEPRECATE_IFDEF_START
150  /** Finds out the DND protocol supported by a window.
151   *
152   * @newin{2,2}
153   * @deprecated Use the version that takes a GdkNativeWindow.
154   * @param xid The X id of the destination window.
155   * @param protocol Location where the supported DND protocol is returned.
156   * @return The X id of the window where the drop should happen. This
157   * may be @a xid or the X id of a proxy window, or None if @a xid doesn't
158   * support Drag and Drop.
159   *
160   * On Windows, GdkNativeWindow is not the same as guint32, so we keep the
161   * guint32 variant for ABI compatibility. On Linux, it is the same, and they
162   * can't be overloaded therefore. But the ABI stays the same anyway.
163   */
164  guint32 get_drag_protocol(guint32 xid, GdkDragProtocol& protocol);
165_DEPRECATE_IFDEF_END
166#endif
167
168  _WRAP_METHOD(GdkNativeWindow get_drag_protocol(GdkNativeWindow xid, GdkDragProtocol& protocol), gdk_drag_get_protocol_for_display)
169
170  _WRAP_METHOD(GdkKeymap* get_keymap(), gdk_keymap_get_for_display)
171  _WRAP_METHOD(const GdkKeymap* get_keymap() const, gdk_keymap_get_for_display, constversion)
172
173  bool set_selection_owner(const Glib::RefPtr<Window>& owner, Glib::ustring& selection, guint32 time_, bool send_event);
174  Glib::RefPtr<Window> get_selection_owner(const Glib::ustring& selection);
175
176#ifdef G_OS_WIN32
177  /** Send a response to SelectionRequest event.
178   *
179   * @newin{2,2}
180   * @param requestor Window to which to deliver response.
181   * @param selection Selection that was requested.
182   * @param target Target that was selected.
183   * @param property Property in which the selection owner stored the data,
184   * or "None" to indicate that the request was rejected.
185   * @param time_ Timestamp.
186   *
187   * On Windows, GdkNativeWindow is not the same as guint32, so we keep the
188   * guint32 variant for ABI compatibility. On Linux, it is the same, and they
189   * can't be overloaded therefore. But the ABI stays the same anyway.
190   */
191  void selection_send_notify(guint32 requestor, Glib::ustring& selection, Glib::ustring& target, Glib::ustring& property, guint32 time_);
192#endif
193
194  /** Send a response to SelectionRequest event.
195   *
196   * @newin{2,2}
197   * @param requestor Window to which to deliver response.
198   * @param selection Selection that was requested.
199   * @param target Target that was selected.
200   * @param property Property in which the selection owner stored the data,
201   * or "None" to indicate that the request was rejected.
202   * @param time_ Timestamp.
203   */
204  void selection_send_notify(GdkNativeWindow requestor, Glib::ustring& selection, Glib::ustring& target, Glib::ustring& property, guint32 time_);
205
206  _WRAP_METHOD(Glib::RefPtr<Pixmap> lookup_pixmap(NativeWindow anid), gdk_pixmap_lookup_for_display)
207  _WRAP_METHOD(Glib::RefPtr<const Pixmap> lookup_pixmap(NativeWindow anid) const, gdk_pixmap_lookup_for_display, constversion)
208
209  _WRAP_METHOD(void flush(), gdk_display_flush)
210  _WRAP_METHOD(bool supports_cursor_alpha() const, gdk_display_supports_cursor_alpha)
211  _WRAP_METHOD(bool supports_cursor_color() const, gdk_display_supports_cursor_color)
212  _WRAP_METHOD(guint get_default_cursor_size() const, gdk_display_get_default_cursor_size)
213  _WRAP_METHOD(void get_maximal_cursor_size(guint& width, guint& height), gdk_display_get_maximal_cursor_size)
214
215  _WRAP_METHOD(Glib::RefPtr<Window> get_default_group(), gdk_display_get_default_group, refreturn)
216  _WRAP_METHOD(Glib::RefPtr<const Window> get_default_group() const, gdk_display_get_default_group, refreturn, constversion)
217
218  //TODO: wrap the vfuncs, though they are not very useful because people will not derive from this class? murrayc.
219
220
221  _WRAP_METHOD(bool supports_selection_notification() const, gdk_display_supports_selection_notification)
222  _WRAP_METHOD(bool request_selection_notification(const Glib::ustring& selection), gdk_display_request_selection_notification)
223
224  _WRAP_METHOD(bool supports_clipboard_persistence() const, gdk_display_supports_clipboard_persistence)
225
226  /** Issues a request to the clipboard manager to store the clipboard data,
227   * saving all available targets.
228   * On X11, this is a special program that works according to the freedesktop clipboard specification,
229   * available at http://www.freedesktop.org/Standards/clipboard-manager-spec.
230   * @newin{2,6}
231   *
232   * @param clipboard_window A Gdk::Window belonging to the clipboard owner.
233   * @param time_ A timestamp.
234   */
235  void store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_);
236
237  void store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_, const Glib::StringArrayHandle& targets);
238  _IGNORE(gdk_display_store_clipboard)
239
240  _WRAP_METHOD(bool supports_shapes() const, gdk_display_supports_shapes)
241  _WRAP_METHOD(bool supports_input_shapes() const, gdk_display_supports_input_shapes)
242  _WRAP_METHOD(bool supports_composite() const, gdk_display_supports_composite)
243
244
245  /** The closed signal is emitted when the connection to the windowing
246   * system for this display is closed.
247   *
248   * @param is_error true if the display was closed due to an error
249   */
250  _WRAP_SIGNAL(void closed(bool is_error), closed)
251};
252
253} /* namespace Gdk */
254