~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to gdk/quartz/GdkQuartzWindow.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-05-04 12:24:25 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20070504122425-0m8midgzrp40y8w2
Tags: 2.10.12-1ubuntu1
* Sync with Debian
* New upstream version:
  Fixed bugs:
  - 379414 file chooser warnings when changing path in the entry
  - 418585 GtkFileChooserDefault sizing code is not DPI independent
  - 419568 Crash in search if start with special letter
  - 435062 build dies with icon cache validation
  - 379399 Segfault to call gtk_print_operation_run twice.
  - 387889 cups backend has problems when there are too many printers
  - 418531 invalid read to gtkicontheme.c gtk_icon_theme_lookup_icon...
  - 423916 crash in color scheme code
  - 424042 Segmentation fault while quickly pressing Alt+arrows
  - 415260 Protect against negative indices when setting values in G...
  - 419171 XGetVisualInfo() may not set nxvisuals
  - 128852 Gdk cursors don't look good on win32
  - 344657 Ctrl-H doesn't toggle "Show Hidden Files" setting
  - 345345 PrintOperation::paginate is not emitted for class handler
  - 347567 GtkPrintOperation::end-print is not emitted if it's cance...
  - 369112 gtk_ui_manager_add_ui should accept unnamed separator
  - 392015 Selected menu item invisible on Windows Vista
  - 399253 MS-Windows Theme Bottom Tab placement rendering glitches
  - 399425 gtk_input_dialog_fill_axes() adds child to gtkscrolledwin...
  - 403251 [patch] little memory leak in GtkPrintJob
  - 403267 [patch] memory leak in GtkPageSetupUnixDialog
  - 403470 MS-Windows Theme tab placement other than on top leaks a ...
  - 404506 Windows system fonts that have multi-byte font names cann...
  - 405089 Incorrect window placement for GtkEventBox private window
  - 405515 Minor leak in gtkfilesystemmodel.c
  - 405539 gdk_pixbuf_save() for PNG saver can return FALSE without ...
  - 415681 gdk_window_clear_area includes an extra line and column o...
  - 418219 GtkRecentChooser should apply filter before sorting and c...
  - 418403 Scroll to printer after selecting it from settings
  - 421985 _gtk_print_operation_platform_backend_launch_preview
  - 421990 gtk_print_job_get_surface
  - 421993 gtk_print_operation_init
  - 423064 Conditional jump or move depends on uninitialised value(s...
  - 423722 Fix printing header in gtk-demo
  - 424168 gtk_print_operation_run on async preview
  - 425655 Don't install gtk+-unix-print-2.0.pc on non-UNIX platforms
  - 425786 GDK segfaults if XineramaQueryScreens fails
  - 428665 Lpr Backend gets stuck in infinite loop during gtk_enumer...
  - 429902 GtkPrintOperation leaks cairo contextes
  - 431997 First delay of GdkPixbufAnimationIter is wrong
  - 433242 Inconsistent scroll arrow position calculations
  - 433972 Placing gtk.Expander inside a gtk.TextView() changes gtk....
  - 434261 _gtk_toolbar_elide_underscores incorrectly handles some s...
  - 383354 ctrl-L should make 'Location' entry disappear
  - 418673 gtk_recent_manager_add_item
  - 429732 gtk_accel_group_finalize accesses invalid memory
  - 435028 WM_CLIENT_LEADER is wrong on the leader_window
  - 431067 Background of the header window is not updated
  - 338843 add recent files support inside the ui manager
  - 148535 add drop shadow to menus, tooltips, etc. under Windows XP
* debian/control.in:
  - Conflicts on ubuntulooks (<= 0.9.11-1)
* debian/patches/15_default-fallback-icon-theme.patch:
  - patch from Debian, fallback on gnome icon theme

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GdkQuartzWindow.m
 
2
 *
 
3
 * Copyright (C) 2005 Imendio AB
 
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, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
 
 
22
#import "GdkQuartzWindow.h"
 
23
#include "gdkwindow-quartz.h"
 
24
#include "gdkprivate-quartz.h"
 
25
 
 
26
@implementation GdkQuartzWindow
 
27
 
 
28
-(BOOL)windowShouldClose:(id)sender
 
29
{
 
30
  GdkWindow *window = [[self contentView] gdkWindow];
 
31
  GdkEvent *event;
 
32
 
 
33
  event = gdk_event_new (GDK_DELETE);
 
34
 
 
35
  event->any.window = g_object_ref (window);
 
36
  event->any.send_event = FALSE;
 
37
 
 
38
  _gdk_event_queue_append (gdk_display_get_default (), event);
 
39
 
 
40
  return NO;
 
41
}
 
42
 
 
43
-(void)windowDidMiniaturize:(NSNotification *)aNotification
 
44
{
 
45
  GdkWindow *window = [[self contentView] gdkWindow];
 
46
 
 
47
  gdk_synthesize_window_state (window, 0, 
 
48
                               GDK_WINDOW_STATE_ICONIFIED);
 
49
}
 
50
 
 
51
-(void)windowDidDeminiaturize:(NSNotification *)aNotification
 
52
{
 
53
  GdkWindow *window = [[self contentView] gdkWindow];
 
54
 
 
55
  gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0);
 
56
}
 
57
 
 
58
-(void)windowDidBecomeKey:(NSNotification *)aNotification
 
59
{
 
60
  GdkWindow *window = [[self contentView] gdkWindow];
 
61
 
 
62
  _gdk_quartz_update_focus_window (window, TRUE);
 
63
}
 
64
 
 
65
-(void)windowDidResignKey:(NSNotification *)aNotification
 
66
{
 
67
  GdkWindow *window = [[self contentView] gdkWindow];
 
68
 
 
69
  _gdk_quartz_update_focus_window (window, FALSE);
 
70
}
 
71
 
 
72
-(void)windowDidMove:(NSNotification *)aNotification
 
73
{
 
74
  NSRect content_rect = [self contentRectForFrameRect:[self frame]];
 
75
  GdkWindow *window = [[self contentView] gdkWindow];
 
76
  GdkWindowObject *private = (GdkWindowObject *)window;
 
77
  GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
 
78
  GdkEvent *event;
 
79
 
 
80
  private->x = content_rect.origin.x;
 
81
  private->y = _gdk_quartz_get_inverted_screen_y (content_rect.origin.y) - impl->height;
 
82
 
 
83
  /* Synthesize a configure event */
 
84
  event = gdk_event_new (GDK_CONFIGURE);
 
85
  event->configure.window = g_object_ref (window);
 
86
  event->configure.x = private->x;
 
87
  event->configure.y = private->y;
 
88
  event->configure.width = impl->width;
 
89
  event->configure.height = impl->height;
 
90
 
 
91
  _gdk_event_queue_append (gdk_display_get_default (), event);
 
92
}
 
93
 
 
94
-(void)windowDidResize:(NSNotification *)aNotification
 
95
{
 
96
  NSRect content_rect = [self contentRectForFrameRect:[self frame]];
 
97
  GdkWindow *window = [[self contentView] gdkWindow];
 
98
  GdkWindowObject *private = (GdkWindowObject *)window;
 
99
  GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
 
100
  GdkEvent *event;
 
101
 
 
102
  impl->width = content_rect.size.width;
 
103
  impl->height = content_rect.size.height;
 
104
 
 
105
  /* Synthesize a configure event */
 
106
 
 
107
  event = gdk_event_new (GDK_CONFIGURE);
 
108
  event->configure.window = g_object_ref (window);
 
109
  event->configure.x = private->x;
 
110
  event->configure.y = private->y;
 
111
  event->configure.width = impl->width;
 
112
  event->configure.height = impl->height;
 
113
 
 
114
  _gdk_event_queue_append (gdk_display_get_default (), event);
 
115
 
 
116
  /* Update tracking rectangle */
 
117
  [[self contentView] removeTrackingRect:impl->tracking_rect];
 
118
  impl->tracking_rect = [impl->view addTrackingRect:NSMakeRect(0, 0, impl->width, impl->height) 
 
119
                                              owner:impl->view
 
120
                                           userData:nil
 
121
                                       assumeInside:NO];
 
122
}
 
123
 
 
124
-(id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
 
125
{
 
126
  self = [super initWithContentRect:contentRect
 
127
                          styleMask:styleMask
 
128
                            backing:backingType
 
129
                              defer:flag];
 
130
 
 
131
 
 
132
  /* A possible modification here would be to only accept mouse moved events
 
133
   * if any of the child GdkWindows are interested in mouse moved events.
 
134
   */
 
135
  [self setAcceptsMouseMovedEvents:YES];
 
136
 
 
137
  [self setDelegate:self];
 
138
  [self setReleasedWhenClosed:YES];
 
139
 
 
140
  return self;
 
141
}
 
142
 
 
143
-(BOOL)canBecomeMainWindow
 
144
{
 
145
  GdkWindow *window = [[self contentView] gdkWindow];
 
146
  GdkWindowObject *private = (GdkWindowObject *)window;
 
147
  GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
 
148
 
 
149
  switch (impl->type_hint)
 
150
    {
 
151
    case GDK_WINDOW_TYPE_HINT_NORMAL:
 
152
    case GDK_WINDOW_TYPE_HINT_DIALOG:
 
153
      return YES;
 
154
      
 
155
    case GDK_WINDOW_TYPE_HINT_MENU:
 
156
    case GDK_WINDOW_TYPE_HINT_TOOLBAR:
 
157
    case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
 
158
    case GDK_WINDOW_TYPE_HINT_UTILITY:
 
159
    case GDK_WINDOW_TYPE_HINT_DOCK:
 
160
    case GDK_WINDOW_TYPE_HINT_DESKTOP:
 
161
    case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
 
162
    case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
 
163
    case GDK_WINDOW_TYPE_HINT_TOOLTIP:
 
164
    case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
 
165
    case GDK_WINDOW_TYPE_HINT_COMBO:
 
166
    case GDK_WINDOW_TYPE_HINT_DND:
 
167
      return NO;
 
168
    }
 
169
  
 
170
  return YES;
 
171
}
 
172
 
 
173
-(BOOL)canBecomeKeyWindow
 
174
{
 
175
  GdkWindow *window = [[self contentView] gdkWindow];
 
176
  GdkWindowObject *private = (GdkWindowObject *)window;
 
177
  GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
 
178
 
 
179
  /* FIXME: Is this right? If so, the switch shouldn't be needed. Need
 
180
   * this + some tweaking to the event/grab code to get menus
 
181
   * working...
 
182
   */
 
183
  /*if (private->window_type == GDK_WINDOW_TEMP)
 
184
    return NO;
 
185
  */
 
186
 
 
187
  switch (impl->type_hint)
 
188
    {
 
189
    case GDK_WINDOW_TYPE_HINT_NORMAL:
 
190
    case GDK_WINDOW_TYPE_HINT_DIALOG:
 
191
    case GDK_WINDOW_TYPE_HINT_MENU:
 
192
    case GDK_WINDOW_TYPE_HINT_TOOLBAR:
 
193
    case GDK_WINDOW_TYPE_HINT_UTILITY:
 
194
    case GDK_WINDOW_TYPE_HINT_DOCK:
 
195
    case GDK_WINDOW_TYPE_HINT_DESKTOP:
 
196
    case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
 
197
    case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
 
198
    case GDK_WINDOW_TYPE_HINT_COMBO:
 
199
      return YES;
 
200
      
 
201
    case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
 
202
    case GDK_WINDOW_TYPE_HINT_TOOLTIP:
 
203
    case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
 
204
    case GDK_WINDOW_TYPE_HINT_DND:
 
205
      return NO;
 
206
    }
 
207
  
 
208
  return YES;
 
209
}
 
210
 
 
211
static GdkDragContext *current_context = NULL;
 
212
 
 
213
static GdkDragAction
 
214
drag_operation_to_drag_action (NSDragOperation operation)
 
215
{
 
216
  GdkDragAction result = 0;
 
217
 
 
218
  if (operation & NSDragOperationGeneric)
 
219
    result |= GDK_ACTION_COPY;
 
220
 
 
221
  return result;
 
222
}
 
223
 
 
224
static NSDragOperation
 
225
drag_action_to_drag_operation (GdkDragAction action)
 
226
{
 
227
  NSDragOperation result = 0;
 
228
 
 
229
  if (action & GDK_ACTION_COPY)
 
230
    result |= NSDragOperationCopy;
 
231
 
 
232
  return result;
 
233
}
 
234
 
 
235
static void
 
236
update_context_from_dragging_info (id <NSDraggingInfo> sender)
 
237
{
 
238
  g_assert (current_context != NULL);
 
239
 
 
240
  GDK_DRAG_CONTEXT_PRIVATE (current_context)->dragging_info = sender;
 
241
  current_context->suggested_action = drag_operation_to_drag_action ([sender draggingSourceOperationMask]);
 
242
}
 
243
 
 
244
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
 
245
{
 
246
  GdkEvent event;
 
247
 
 
248
  if (current_context)
 
249
    g_object_unref (current_context);
 
250
  
 
251
  current_context = gdk_drag_context_new ();
 
252
  update_context_from_dragging_info (sender);
 
253
 
 
254
  event.dnd.type = GDK_DRAG_ENTER;
 
255
  event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
 
256
  event.dnd.send_event = FALSE;
 
257
  event.dnd.context = current_context;
 
258
  event.dnd.time = GDK_CURRENT_TIME;
 
259
 
 
260
  (*_gdk_event_func) (&event, _gdk_event_data);
 
261
 
 
262
  return NSDragOperationNone;
 
263
}
 
264
 
 
265
- (void)draggingEnded:(id <NSDraggingInfo>)sender
 
266
{
 
267
  g_object_unref (current_context);
 
268
  current_context = NULL;
 
269
}
 
270
 
 
271
- (void)draggingExited:(id <NSDraggingInfo>)sender
 
272
{
 
273
  GdkEvent event;
 
274
  
 
275
  event.dnd.type = GDK_DRAG_LEAVE;
 
276
  event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
 
277
  event.dnd.send_event = FALSE;
 
278
  event.dnd.context = current_context;
 
279
  event.dnd.time = GDK_CURRENT_TIME;
 
280
 
 
281
  (*_gdk_event_func) (&event, _gdk_event_data);
 
282
  
 
283
  g_object_unref (current_context);
 
284
  current_context = NULL;
 
285
}
 
286
 
 
287
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
 
288
{
 
289
  NSPoint point = [sender draggingLocation];
 
290
  NSPoint screen_point = [self convertBaseToScreen:point];
 
291
  GdkEvent event;
 
292
 
 
293
  update_context_from_dragging_info (sender);
 
294
 
 
295
  event.dnd.type = GDK_DRAG_MOTION;
 
296
  event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
 
297
  event.dnd.send_event = FALSE;
 
298
  event.dnd.context = current_context;
 
299
  event.dnd.time = GDK_CURRENT_TIME;
 
300
  event.dnd.x_root = screen_point.x;
 
301
  event.dnd.y_root = _gdk_quartz_get_inverted_screen_y (screen_point.y);
 
302
 
 
303
  (*_gdk_event_func) (&event, _gdk_event_data);
 
304
 
 
305
  g_object_unref (event.dnd.window);
 
306
 
 
307
  return drag_action_to_drag_operation (current_context->action);
 
308
}
 
309
 
 
310
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
 
311
{
 
312
  NSPoint point = [sender draggingLocation];
 
313
  NSPoint screen_point = [self convertBaseToScreen:point];
 
314
  GdkEvent event;
 
315
 
 
316
  update_context_from_dragging_info (sender);
 
317
 
 
318
  event.dnd.type = GDK_DROP_START;
 
319
  event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
 
320
  event.dnd.send_event = FALSE;
 
321
  event.dnd.context = current_context;
 
322
  event.dnd.time = GDK_CURRENT_TIME;
 
323
  event.dnd.x_root = screen_point.x;
 
324
  event.dnd.y_root = _gdk_quartz_get_inverted_screen_y (screen_point.y);
 
325
 
 
326
  (*_gdk_event_func) (&event, _gdk_event_data);
 
327
 
 
328
  g_object_unref (event.dnd.window);
 
329
 
 
330
  g_object_unref (current_context);
 
331
  current_context = NULL;
 
332
 
 
333
  return YES;
 
334
}
 
335
 
 
336
- (BOOL)wantsPeriodicDraggingUpdates
 
337
{
 
338
  return NO;
 
339
}
 
340
 
 
341
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
 
342
{
 
343
  GdkEvent event;
 
344
 
 
345
  g_assert (_gdk_quartz_drag_source_context != NULL);
 
346
 
 
347
  event.dnd.type = GDK_DROP_FINISHED;
 
348
  event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
 
349
  event.dnd.send_event = FALSE;
 
350
  event.dnd.context = _gdk_quartz_drag_source_context;
 
351
 
 
352
  (*_gdk_event_func) (&event, _gdk_event_data);
 
353
 
 
354
  g_object_unref (event.dnd.window);
 
355
 
 
356
  g_object_unref (_gdk_quartz_drag_source_context);
 
357
  _gdk_quartz_drag_source_context = NULL;
 
358
}
 
359
 
 
360
@end