summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa/ecore_cocoa.m
diff options
context:
space:
mode:
authorNicolas Aguirre <aguirre.nicolas@gmail.com>2015-08-06 18:52:37 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-13 15:40:00 -0700
commit86030d308cbd3febc3d68a2dc92aee24f8184ec3 (patch)
treee15932e87e6511a3399cc77395f889317cf7710c /src/lib/ecore_cocoa/ecore_cocoa.m
parent29e87eb667c3934aa908ec08969522a27cd8399c (diff)
ecore_cocoa: fix warnings, add Debug outputs where needed and remove printfs
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m343
1 files changed, 177 insertions, 166 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index bdc5cf0110..568a828e23 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -33,6 +33,8 @@ ecore_cocoa_init(void)
33 if (++_ecore_cocoa_init_count != 1) 33 if (++_ecore_cocoa_init_count != 1)
34 return _ecore_cocoa_init_count; 34 return _ecore_cocoa_init_count;
35 35
36 DBG("Ecore Cocoa Init");
37
36 if (!ecore_init()) 38 if (!ecore_init())
37 return --_ecore_cocoa_init_count; 39 return --_ecore_cocoa_init_count;
38 40
@@ -74,6 +76,8 @@ ecore_cocoa_shutdown(void)
74 if (--_ecore_cocoa_init_count != 0) 76 if (--_ecore_cocoa_init_count != 0)
75 return _ecore_cocoa_init_count; 77 return _ecore_cocoa_init_count;
76 78
79 DBG("Ecore Cocoa shutdown");
80
77 eina_log_domain_unregister(_ecore_cocoa_log_domain); 81 eina_log_domain_unregister(_ecore_cocoa_log_domain);
78 ecore_event_shutdown(); 82 ecore_event_shutdown();
79 83
@@ -91,7 +95,7 @@ _ecore_cocoa_event_modifiers(unsigned int mod)
91 if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN; 95 if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN;
92 if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM; 96 if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM;
93 97
94 DBG("key modifiers: %d, %d\n", mod, modifiers); 98 DBG("key modifiers: %d, %d", mod, modifiers);
95 return modifiers; 99 return modifiers;
96} 100}
97 101
@@ -109,6 +113,8 @@ _ecore_cocoa_event_key(NSEvent *event, int keyType)
109 NSString *keychar = [event charactersIgnoringModifiers]; 113 NSString *keychar = [event charactersIgnoringModifiers];
110 NSString *keycharRaw = [event characters]; 114 NSString *keycharRaw = [event characters];
111 115
116 DBG("Event Key, keyTpe : %d", keyType);
117
112 ev = calloc(1, sizeof (Ecore_Event_Key)); 118 ev = calloc(1, sizeof (Ecore_Event_Key));
113 if (!ev) return NULL; 119 if (!ev) return NULL;
114 120
@@ -180,8 +186,10 @@ ecore_cocoa_feed_events(void *anEvent)
180 unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); 186 unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
181 Eina_Bool pass = EINA_FALSE; 187 Eina_Bool pass = EINA_FALSE;
182 188
189 DBG("Feed events, event type ; %d", [event type]);
190
183 switch ([event type]) 191 switch ([event type])
184 { 192 {
185 case NSMouseMoved: 193 case NSMouseMoved:
186 case NSLeftMouseDragged: 194 case NSLeftMouseDragged:
187 case NSRightMouseDragged: 195 case NSRightMouseDragged:
@@ -192,182 +200,182 @@ ecore_cocoa_feed_events(void *anEvent)
192 case NSLeftMouseUp: 200 case NSLeftMouseUp:
193 case NSRightMouseUp: 201 case NSRightMouseUp:
194 case NSOtherMouseUp: 202 case NSOtherMouseUp:
195 { 203 {
196 //mouse events are managed in EcoreCocoaWindow 204 //mouse events are managed in EcoreCocoaWindow
197 return EINA_TRUE; 205 return EINA_TRUE;
198 } 206 }
199 case NSKeyDown: 207 case NSKeyDown:
200 { 208 {
201 Ecore_Event_Key *ev; 209 Ecore_Event_Key *ev;
202 210
203 ev = _ecore_cocoa_event_key(event, NSKeyDown); 211 ev = _ecore_cocoa_event_key(event, NSKeyDown);
204 if (ev == NULL) return EINA_TRUE; 212 if (ev == NULL) return EINA_TRUE;
205 213
206 ev->timestamp = time; 214 ev->timestamp = time;
207 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); 215 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
208 216
209 break; 217 break;
210 } 218 }
211 case NSKeyUp: 219 case NSKeyUp:
212 { 220 {
213 Ecore_Event_Key *ev; 221 Ecore_Event_Key *ev;
214 222
215 ev = _ecore_cocoa_event_key(event, NSKeyUp); 223 ev = _ecore_cocoa_event_key(event, NSKeyUp);
216 if (ev == NULL) return EINA_TRUE; 224 if (ev == NULL) return EINA_TRUE;
217 225
218 ev->timestamp = time; 226 ev->timestamp = time;
219 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); 227 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
220 228
221 break; 229 break;
222 } 230 }
223 case NSFlagsChanged: 231 case NSFlagsChanged:
224 { 232 {
225 int flags = [event modifierFlags]; 233 int flags = [event modifierFlags];
226 234
227 Ecore_Event_Key *evDown = NULL; 235 Ecore_Event_Key *evDown = NULL;
228 Ecore_Event_Key *evUp = NULL; 236 Ecore_Event_Key *evUp = NULL;
229 237
230 evDown = calloc(1, sizeof (Ecore_Event_Key)); 238 evDown = calloc(1, sizeof (Ecore_Event_Key));
231 if (!evDown) return pass; 239 if (!evDown) return pass;
232 240
233 // Turn special key flags on 241 // Turn special key flags on
234 if (flags & NSShiftKeyMask) 242 if (flags & NSShiftKeyMask)
235 evDown->key = "Shift_L"; 243 evDown->key = "Shift_L";
236 else if (flags & NSControlKeyMask) 244 else if (flags & NSControlKeyMask)
237 evDown->key = "Control_L"; 245 evDown->key = "Control_L";
238 else if (flags & NSAlternateKeyMask) 246 else if (flags & NSAlternateKeyMask)
239 evDown->key = "Alt_L"; 247 evDown->key = "Alt_L";
240 else if (flags & NSCommandKeyMask) 248 else if (flags & NSCommandKeyMask)
241 evDown->key = "Super_L"; 249 evDown->key = "Super_L";
242 else if (flags & NSAlphaShiftKeyMask) 250 else if (flags & NSAlphaShiftKeyMask)
243 evDown->key = "Caps_Lock"; 251 evDown->key = "Caps_Lock";
244 252
245 if (evDown->key) 253 if (evDown->key)
246 { 254 {
247 evDown->keyname = evDown->key; 255 evDown->keyname = evDown->key;
248 evDown->timestamp = time; 256 evDown->timestamp = time;
249 evDown->string = NULL; 257 evDown->string = NULL;
250 ecore_event_add(ECORE_EVENT_KEY_DOWN, evDown, NULL, NULL); 258 ecore_event_add(ECORE_EVENT_KEY_DOWN, evDown, NULL, NULL);
251 old_flags = flags; 259 old_flags = flags;
252 break; 260 break;
253 } 261 }
254 262
255 free(evDown); 263 free(evDown);
256 264
257 evUp = calloc(1, sizeof (Ecore_Event_Key)); 265 evUp = calloc(1, sizeof (Ecore_Event_Key));
258 if (!evUp) 266 if (!evUp)
259 { 267 {
260 return pass; 268 return pass;
261 } 269 }
262 270
263 int changed_flags = flags ^ old_flags; 271 int changed_flags = flags ^ old_flags;
264 272
265 // Turn special key flags off 273 // Turn special key flags off
266 if (changed_flags & NSShiftKeyMask) 274 if (changed_flags & NSShiftKeyMask)
267 evUp->key = "Shift_L"; 275 evUp->key = "Shift_L";
268 else if (changed_flags & NSControlKeyMask) 276 else if (changed_flags & NSControlKeyMask)
269 evUp->key = "Control_L"; 277 evUp->key = "Control_L";
270 else if (changed_flags & NSAlternateKeyMask) 278 else if (changed_flags & NSAlternateKeyMask)
271 evUp->key = "Alt_L"; 279 evUp->key = "Alt_L";
272 else if (changed_flags & NSCommandKeyMask) 280 else if (changed_flags & NSCommandKeyMask)
273 evUp->key = "Super_L"; 281 evUp->key = "Super_L";
274 else if (changed_flags & NSAlphaShiftKeyMask) 282 else if (changed_flags & NSAlphaShiftKeyMask)
275 evUp->key = "Caps_Lock"; 283 evUp->key = "Caps_Lock";
276 284
277 if (evUp->key) 285 if (evUp->key)
278 { 286 {
279 evUp->keyname = evDown->key; 287 evUp->keyname = evDown->key;
280 evUp->timestamp = time; 288 evUp->timestamp = time;
281 evUp->string = NULL; 289 evUp->string = NULL;
282 ecore_event_add(ECORE_EVENT_KEY_UP, evUp, NULL, NULL); 290 ecore_event_add(ECORE_EVENT_KEY_UP, evUp, NULL, NULL);
283 old_flags = flags; 291 old_flags = flags;
284 break; 292 break;
285 } 293 }
286 294
287 break; 295 break;
288 } 296 }
289 case NSAppKitDefined: 297 case NSAppKitDefined:
290 { 298 {
291 if ([event subtype] == NSApplicationActivatedEventType) 299 if ([event subtype] == NSApplicationActivatedEventType)
292 { 300 {
293 Ecore_Cocoa_Event_Window *ev; 301 Ecore_Cocoa_Event_Window *ev;
294 302
295 ev = malloc(sizeof(Ecore_Cocoa_Event_Window)); 303 ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
296 if (!ev) 304 if (!ev)
297 { 305 {
298 pass = EINA_FALSE; 306 pass = EINA_FALSE;
299 break; 307 break;
300 } 308 }
301 ev->wid = [event window]; 309 ev->wid = [event window];
302 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, ev, NULL, NULL); 310 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, ev, NULL, NULL);
303 } 311 }
304 else if ([event subtype] == NSApplicationDeactivatedEventType) 312 else if ([event subtype] == NSApplicationDeactivatedEventType)
305 { 313 {
306 Ecore_Cocoa_Event_Window *ev; 314 Ecore_Cocoa_Event_Window *ev;
307 315
308 ev = malloc(sizeof(Ecore_Cocoa_Event_Window)); 316 ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
309 if (!ev) 317 if (!ev)
310 { 318 {
311 pass = EINA_FALSE; 319 pass = EINA_FALSE;
312 break; 320 break;
313 } 321 }
314 ev->wid = [event window]; 322 ev->wid = [event window];
315 ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, ev, NULL, NULL); 323 ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, ev, NULL, NULL);
316 } 324 }
317 pass = EINA_TRUE; // pass along AppKit events, for window manager 325 pass = EINA_TRUE; // pass along AppKit events, for window manager
318 break; 326 break;
319 } 327 }
320 case NSScrollWheel: 328 case NSScrollWheel:
321 { 329 {
322 DBG("Scroll Wheel\n"); 330 DBG("Scroll Wheel");
323 331
324 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 332 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
325 Ecore_Event_Mouse_Wheel *ev; 333 Ecore_Event_Mouse_Wheel *ev;
326 float dx, dy = 0; 334 float dx, dy = 0;
327 335
328 ev = malloc(sizeof(Ecore_Event_Mouse_Wheel)); 336 ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
329 if (!ev) return pass; 337 if (!ev) return pass;
330 338
331 if ([event hasPreciseScrollingDeltas]) 339 if ([event hasPreciseScrollingDeltas])
332 { 340 {
333 dx = -[event scrollingDeltaX]; 341 dx = -[event scrollingDeltaX];
334 dy = -[event scrollingDeltaY]; 342 dy = -[event scrollingDeltaY];
335 } 343 }
336 else 344 else
337 { 345 {
338 dx = -[event deltaX]; 346 dx = -[event deltaX];
339 dy = -[event deltaY]; 347 dy = -[event deltaY];
340 } 348 }
341 349
342 if (dx == 0 && dy == 0) 350 if (dx == 0 && dy == 0)
343 { 351 {
344 break; 352 break;
345 } 353 }
346 354
347 ev->window = (Ecore_Window)window.ecore_window_data; 355 ev->window = (Ecore_Window)window.ecore_window_data;
348 ev->event_window = ev->window; 356 ev->event_window = ev->window;
349 ev->modifiers = 0; /* FIXME: keep modifier around. */ 357 ev->modifiers = 0; /* FIXME: keep modifier around. */
350 ev->timestamp = time; 358 ev->timestamp = time;
351 if (dy != 0) 359 if (dy != 0)
352 { 360 {
353 ev->z = (dy > 0) ? 1 : -1; 361 ev->z = (dy > 0) ? 1 : -1;
354 } 362 }
355 else 363 else
356 { 364 {
357 ev->z = (dx > 0) ? 1 : -1; 365 ev->z = (dx > 0) ? 1 : -1;
358 } 366 }
359 ev->direction = (dy != 0) ? 0 : 1; 367 ev->direction = (dy != 0) ? 0 : 1;
360 368
361 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL); 369 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
362 370
363 break; 371 break;
364 } 372 }
365 default: 373 default:
366 { 374 {
367 pass = EINA_TRUE; 375 pass = EINA_TRUE;
368 break; 376 break;
369 } 377 }
370 } 378 }
371 379
372 return pass; 380 return pass;
373} 381}
@@ -377,6 +385,8 @@ ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h)
377{ 385{
378 NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size; 386 NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size;
379 387
388 DBG("Screen size get : %dx%d", w, h);
389
380 if (w) *w = (int)pt.width; 390 if (w) *w = (int)pt.width;
381 if (h) *h = (int)pt.height; 391 if (h) *h = (int)pt.height;
382} 392}
@@ -393,6 +403,7 @@ ecore_cocoa_titlebar_height_get(void)
393 contentRect = [NSWindow contentRectForFrameRect:frame 403 contentRect = [NSWindow contentRectForFrameRect:frame
394 styleMask:NSTitledWindowMask]; 404 styleMask:NSTitledWindowMask];
395 height = (frame.size.height - contentRect.size.height); 405 height = (frame.size.height - contentRect.size.height);
406 DBG("Titlebar Heigt : %d", height);
396 } 407 }
397 return height; 408 return height;
398} 409}