summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-02-21 16:49:10 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-02-21 16:49:10 +0900
commit83190eb0c2bcf9fdff52992164789d4daed4ee25 (patch)
tree02013b13ae298200dd0b0473eb67ce237cbfafea
parent5e99f9b96873a794f40d30bbb997917cf57a5bdf (diff)
Add ecore_x_dnd_self_begin() and ecore_x_dnd_self_drop() to allow dnd
to your own window (drop where u drag from). helpful for elm where dnd src/dst are object based, so we talk dnd protocol to ourselves.
-rw-r--r--ChangeLog7
-rw-r--r--NEWS2
-rw-r--r--src/lib/ecore_x/Ecore_X.h2
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_dnd.c147
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_dnd.c58
5 files changed, 147 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index f693ee63a9..1ae0ace285 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
12013-02-21 Carsten Haitzler (The Rasterman)
2
3 * Add ecore_x_dnd_self_begin() and ecore_x_dnd_self_drop() to
4 allow xdnd chatting to yourself (your source drag window).
5
12013-02-20 Carsten Haitzler (The Rasterman) 62013-02-20 Carsten Haitzler (The Rasterman)
2 7
3 * Fix ecore-x edid fetch to ftech 128, not 100 bytes. 8 * Fix ecore-x edid fetch to ftech 128, not 100 bytes.
4 9
52013-02-20 Cedric Bail 102013-02-20 Cedric Bail
6 11
7 * Properly report file not found in Edje. 12 * Properly report file not found in Edje.
diff --git a/NEWS b/NEWS
index b0d312323f..67913fbfa1 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,8 @@ Additions:
30 ecore_x_e_window_profile_change_done_send() 30 ecore_x_e_window_profile_change_done_send()
31 ecore_x_randr_crtc_info_get() 31 ecore_x_randr_crtc_info_get()
32 ecore_x_randr_crtc_info_free() 32 ecore_x_randr_crtc_info_free()
33 ecore_x_dnd_self_begin()
34 ecore_x_dnd_self_drop()
33 * ecore_wayland: 35 * ecore_wayland:
34 - Store global wayland interfaces in a globals list so wayland programs 36 - Store global wayland interfaces in a globals list so wayland programs
35 can bind to other non-standard wayland protocol extensions. 37 can bind to other non-standard wayland protocol extensions.
diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h
index 464432d8d3..64f24277cd 100644
--- a/src/lib/ecore_x/Ecore_X.h
+++ b/src/lib/ecore_x/Ecore_X.h
@@ -1351,6 +1351,8 @@ EAPI void ecore_x_dnd_types_set(Ecore_X_Window win, const c
1351EAPI void ecore_x_dnd_actions_set(Ecore_X_Window win, Ecore_X_Atom *actions, unsigned int num_actions); 1351EAPI void ecore_x_dnd_actions_set(Ecore_X_Window win, Ecore_X_Atom *actions, unsigned int num_actions);
1352EAPI Eina_Bool ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size); 1352EAPI Eina_Bool ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size);
1353EAPI Eina_Bool ecore_x_dnd_drop(void); 1353EAPI Eina_Bool ecore_x_dnd_drop(void);
1354EAPI Eina_Bool ecore_x_dnd_self_begin(Ecore_X_Window source, unsigned char *data, int size); /**< @since 1.8 */
1355EAPI Eina_Bool ecore_x_dnd_self_drop(void); /**< @since 1.8 */
1354EAPI void ecore_x_dnd_send_status(Eina_Bool will_accept, Eina_Bool suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action); 1356EAPI void ecore_x_dnd_send_status(Eina_Bool will_accept, Eina_Bool suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action);
1355EAPI void ecore_x_dnd_send_finished(void); 1357EAPI void ecore_x_dnd_send_finished(void);
1356EAPI void ecore_x_dnd_source_action_set(Ecore_X_Atom action); 1358EAPI void ecore_x_dnd_source_action_set(Ecore_X_Atom action);
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c
index 80ae6b4c5d..543f43c6c9 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c
@@ -132,60 +132,6 @@ ecore_x_dnd_send_status(Eina_Bool will_accept,
132// ecore_x_flush(); 132// ecore_x_flush();
133} 133}
134 134
135EAPI Eina_Bool
136ecore_x_dnd_drop(void)
137{
138 xcb_client_message_event_t ev;
139 Eina_Bool status = EINA_FALSE;
140
141 LOGFN(__FILE__, __LINE__, __FUNCTION__);
142 CHECK_XCB_CONN;
143
144 memset(&ev, 0, sizeof(xcb_client_message_event_t));
145
146 if (_source->dest)
147 {
148 ev.response_type = XCB_CLIENT_MESSAGE;
149 ev.format = 32;
150 ev.window = _source->dest;
151
152 if (_source->will_accept)
153 {
154 ev.type = ECORE_X_ATOM_XDND_DROP;
155 ev.data.data32[0] = _source->win;
156 ev.data.data32[1] = 0;
157 ev.data.data32[2] = _source->time;
158
159 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
160 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
161// ecore_x_flush();
162 _source->state = ECORE_X_DND_SOURCE_DROPPED;
163 status = EINA_TRUE;
164 }
165 else
166 {
167 ev.type = ECORE_X_ATOM_XDND_LEAVE;
168 ev.data.data32[0] = _source->win;
169 ev.data.data32[1] = 0;
170
171 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
172 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
173// ecore_x_flush();
174 _source->state = ECORE_X_DND_SOURCE_IDLE;
175 }
176 }
177 else
178 {
179 ecore_x_selection_xdnd_clear();
180 _source->state = ECORE_X_DND_SOURCE_IDLE;
181 }
182
183 ecore_x_window_ignore_set(_source->win, 0);
184 _source->prev.window = 0;
185
186 return status;
187}
188
189EAPI void 135EAPI void
190ecore_x_dnd_aware_set(Ecore_X_Window win, 136ecore_x_dnd_aware_set(Ecore_X_Window win,
191 Eina_Bool on) 137 Eina_Bool on)
@@ -429,10 +375,11 @@ ecore_x_dnd_callback_pos_update_set(void (*cb)(void *, Ecore_X_Xdnd_Position *da
429 _posupdatedata = (void *)data; 375 _posupdatedata = (void *)data;
430} 376}
431 377
432EAPI Eina_Bool 378static Eina_Bool
433ecore_x_dnd_begin(Ecore_X_Window source, 379_ecore_x_dnd_begin(Ecore_X_Window source,
434 unsigned char *data, 380 Eina_Bool self;
435 int size) 381 unsigned char *data,
382 int size)
436{ 383{
437 LOGFN(__FILE__, __LINE__, __FUNCTION__); 384 LOGFN(__FILE__, __LINE__, __FUNCTION__);
438 385
@@ -452,7 +399,7 @@ ecore_x_dnd_begin(Ecore_X_Window source,
452 ecore_x_window_shadow_tree_flush(); 399 ecore_x_window_shadow_tree_flush();
453 400
454 _source->win = source; 401 _source->win = source;
455 ecore_x_window_ignore_set(_source->win, 1); 402 if (!self) ecore_x_window_ignore_set(_source->win, 1);
456 _source->state = ECORE_X_DND_SOURCE_DRAGGING; 403 _source->state = ECORE_X_DND_SOURCE_DRAGGING;
457 _source->time = _ecore_xcb_events_last_time_get(); 404 _source->time = _ecore_xcb_events_last_time_get();
458 _source->prev.window = 0; 405 _source->prev.window = 0;
@@ -465,6 +412,88 @@ ecore_x_dnd_begin(Ecore_X_Window source,
465 return EINA_TRUE; 412 return EINA_TRUE;
466} 413}
467 414
415static Eina_Bool
416_ecore_x_dnd_drop(Eina_Bool self)
417{
418 xcb_client_message_event_t ev;
419 Eina_Bool status = EINA_FALSE;
420
421 LOGFN(__FILE__, __LINE__, __FUNCTION__);
422 CHECK_XCB_CONN;
423
424 memset(&ev, 0, sizeof(xcb_client_message_event_t));
425
426 if (_source->dest)
427 {
428 ev.response_type = XCB_CLIENT_MESSAGE;
429 ev.format = 32;
430 ev.window = _source->dest;
431
432 if (_source->will_accept)
433 {
434 ev.type = ECORE_X_ATOM_XDND_DROP;
435 ev.data.data32[0] = _source->win;
436 ev.data.data32[1] = 0;
437 ev.data.data32[2] = _source->time;
438
439 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
440 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
441// ecore_x_flush();
442 _source->state = ECORE_X_DND_SOURCE_DROPPED;
443 status = EINA_TRUE;
444 }
445 else
446 {
447 ev.type = ECORE_X_ATOM_XDND_LEAVE;
448 ev.data.data32[0] = _source->win;
449 ev.data.data32[1] = 0;
450
451 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
452 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
453// ecore_x_flush();
454 _source->state = ECORE_X_DND_SOURCE_IDLE;
455 }
456 }
457 else
458 {
459 ecore_x_selection_xdnd_clear();
460 _source->state = ECORE_X_DND_SOURCE_IDLE;
461 }
462
463 if (!self) ecore_x_window_ignore_set(_source->win, 0);
464 _source->prev.window = 0;
465
466 return status;
467}
468
469EAPI Eina_Bool
470ecore_x_dnd_begin(Ecore_X_Window source,
471 unsigned char *data,
472 int size)
473{
474 return _ecore_x_dnd_begin(source, EINA_FALSE, data, size);
475}
476
477EAPI Eina_Bool
478ecore_x_dnd_drop(void)
479{
480 return _ecore_x_dnd_drop(EINA_FALSE);
481}
482
483EAPI Eina_Bool
484ecore_x_dnd_self_begin(Ecore_X_Window source,
485 unsigned char *data,
486 int size)
487{
488 return _ecore_x_dnd_begin(source, EINA_TRUE, data, size);
489}
490
491EAPI Eina_Bool
492ecore_x_dnd_self_drop(void)
493{
494 return _ecore_x_dnd_drop(EINA_TRUE);
495}
496
468EAPI void 497EAPI void
469ecore_x_dnd_send_finished(void) 498ecore_x_dnd_send_finished(void)
470{ 499{
diff --git a/src/lib/ecore_x/xlib/ecore_x_dnd.c b/src/lib/ecore_x/xlib/ecore_x_dnd.c
index e4f74a7257..e25e93617b 100644
--- a/src/lib/ecore_x/xlib/ecore_x_dnd.c
+++ b/src/lib/ecore_x/xlib/ecore_x_dnd.c
@@ -398,10 +398,13 @@ _ecore_x_dnd_target_get(void)
398 return _target; 398 return _target;
399} 399}
400 400
401EAPI Eina_Bool 401
402ecore_x_dnd_begin(Ecore_X_Window source, 402
403 unsigned char *data, 403static Eina_Bool
404 int size) 404_ecore_x_dnd_begin(Ecore_X_Window source,
405 Eina_Bool self,
406 unsigned char *data,
407 int size)
405{ 408{
406 LOGFN(__FILE__, __LINE__, __FUNCTION__); 409 LOGFN(__FILE__, __LINE__, __FUNCTION__);
407 if (!ecore_x_dnd_version_get(source)) 410 if (!ecore_x_dnd_version_get(source))
@@ -422,7 +425,7 @@ ecore_x_dnd_begin(Ecore_X_Window source,
422 ecore_x_window_shadow_tree_flush(); 425 ecore_x_window_shadow_tree_flush();
423 426
424 _source->win = source; 427 _source->win = source;
425 ecore_x_window_ignore_set(_source->win, 1); 428 if (!self) ecore_x_window_ignore_set(_source->win, 1);
426 _source->state = ECORE_X_DND_SOURCE_DRAGGING; 429 _source->state = ECORE_X_DND_SOURCE_DRAGGING;
427 _source->time = _ecore_x_event_last_time; 430 _source->time = _ecore_x_event_last_time;
428 _source->prev.window = 0; 431 _source->prev.window = 0;
@@ -435,8 +438,8 @@ ecore_x_dnd_begin(Ecore_X_Window source,
435 return EINA_TRUE; 438 return EINA_TRUE;
436} 439}
437 440
438EAPI Eina_Bool 441static Eina_Bool
439ecore_x_dnd_drop(void) 442_ecore_x_dnd_drop(Eina_Bool self)
440{ 443{
441 XEvent xev; 444 XEvent xev;
442 int status = EINA_FALSE; 445 int status = EINA_FALSE;
@@ -475,13 +478,41 @@ ecore_x_dnd_drop(void)
475 _source->state = ECORE_X_DND_SOURCE_IDLE; 478 _source->state = ECORE_X_DND_SOURCE_IDLE;
476 } 479 }
477 480
478 ecore_x_window_ignore_set(_source->win, 0); 481 if (!self) ecore_x_window_ignore_set(_source->win, 0);
479 482
480 _source->prev.window = 0; 483 _source->prev.window = 0;
481 484
482 return status; 485 return status;
483} 486}
484 487
488EAPI Eina_Bool
489ecore_x_dnd_begin(Ecore_X_Window source,
490 unsigned char *data,
491 int size)
492{
493 return _ecore_x_dnd_begin(source, EINA_FALSE, data, size);
494}
495
496EAPI Eina_Bool
497ecore_x_dnd_drop(void)
498{
499 return _ecore_x_dnd_drop(EINA_FALSE);
500}
501
502EAPI Eina_Bool
503ecore_x_dnd_self_begin(Ecore_X_Window source,
504 unsigned char *data,
505 int size)
506{
507 return _ecore_x_dnd_begin(source, EINA_TRUE, data, size);
508}
509
510EAPI Eina_Bool
511ecore_x_dnd_self_drop(void)
512{
513 return _ecore_x_dnd_drop(EINA_TRUE);
514}
515
485EAPI void 516EAPI void
486ecore_x_dnd_send_status(Eina_Bool will_accept, 517ecore_x_dnd_send_status(Eina_Bool will_accept,
487 Eina_Bool suppress, 518 Eina_Bool suppress,
@@ -599,21 +630,29 @@ _ecore_x_dnd_drag(Ecore_X_Window root,
599 630
600 /* Attempt to find a DND-capable window under the cursor */ 631 /* Attempt to find a DND-capable window under the cursor */
601 skip = ecore_x_window_ignore_list(&num); 632 skip = ecore_x_window_ignore_list(&num);
633 int i;
634 for (i = 0; i < num; i++) printf("skip %x\n", skip[i]);
602// WARNING - this function is HEAVY. it goes to and from x a LOT walking the 635// WARNING - this function is HEAVY. it goes to and from x a LOT walking the
603// window tree - use the SHADOW version - makes a 1-off tree copy, then uses 636// window tree - use the SHADOW version - makes a 1-off tree copy, then uses
604// that instead. 637// that instead.
605// win = ecore_x_window_at_xy_with_skip_get(x, y, skip, num); 638// win = ecore_x_window_at_xy_with_skip_get(x, y, skip, num);
606 win = ecore_x_window_shadow_tree_at_xy_with_skip_get(root, x, y, skip, num); 639 win = ecore_x_window_shadow_tree_at_xy_with_skip_get(root, x, y, skip, num);
640 printf("win1 %x\n", win);
607 641
608// NOTE: This now uses the shadow version to find parent windows 642// NOTE: This now uses the shadow version to find parent windows
609// while ((win) && !(ecore_x_dnd_version_get(win))) 643// while ((win) && !(ecore_x_dnd_version_get(win)))
610// win = ecore_x_window_parent_get(win); 644// win = ecore_x_window_parent_get(win);
611 while ((win) && !(ecore_x_dnd_version_get(win))) 645 while ((win) && !(ecore_x_dnd_version_get(win)))
612 win = ecore_x_window_shadow_parent_get(root, win); 646 {
647 printf("win parent %x\n", win);
648 win = ecore_x_window_shadow_parent_get(root, win);
649 }
650 printf("win2 %x\n", win);
613 651
614 /* Send XdndLeave to current destination window if we have left it */ 652 /* Send XdndLeave to current destination window if we have left it */
615 if ((_source->dest) && (win != _source->dest)) 653 if ((_source->dest) && (win != _source->dest))
616 { 654 {
655 printf("leave...\n");
617 xev.xclient.window = _source->dest; 656 xev.xclient.window = _source->dest;
618 xev.xclient.message_type = ECORE_X_ATOM_XDND_LEAVE; 657 xev.xclient.message_type = ECORE_X_ATOM_XDND_LEAVE;
619 xev.xclient.data.l[0] = _source->win; 658 xev.xclient.data.l[0] = _source->win;
@@ -629,6 +668,7 @@ _ecore_x_dnd_drag(Ecore_X_Window root,
629 668
630 _source->version = MIN(ECORE_X_DND_VERSION, 669 _source->version = MIN(ECORE_X_DND_VERSION,
631 ecore_x_dnd_version_get(win)); 670 ecore_x_dnd_version_get(win));
671 printf("win %x == %x\n", win, _source->dest);
632 if (win != _source->dest) 672 if (win != _source->dest)
633 { 673 {
634 int i; 674 int i;