Merge lp:~larsu/ido/fix-volume-slider into lp:ido/15.04

Proposed by Lars Karlitski
Status: Merged
Approved by: Iain Lane
Approved revision: 189
Merged at revision: 187
Proposed branch: lp:~larsu/ido/fix-volume-slider
Merge into: lp:ido/15.04
Diff against target: 131 lines (+23/-51)
1 file modified
src/idoscalemenuitem.c (+23/-51)
To merge this branch: bzr merge lp:~larsu/ido/fix-volume-slider
Reviewer Review Type Date Requested Status
Iain Lane Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+247198@code.launchpad.net

Commit message

idoscalemenuitem: fix slider event forwarding

Description of the change

idoscalemenuitem: fix slider event forwarding

The slider behaves weirdly when clicking/dragging it right now. This patch fixes that.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

Looks nice, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/idoscalemenuitem.c'
--- src/idoscalemenuitem.c 2014-03-12 17:25:55 +0000
+++ src/idoscalemenuitem.c 2015-01-21 18:25:20 +0000
@@ -437,20 +437,6 @@
437 }437 }
438}438}
439439
440static void
441ido_scale_menu_item_get_scale_allocation (IdoScaleMenuItem *menuitem,
442 GtkAllocation *allocation)
443{
444 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
445 GtkAllocation parent_allocation;
446
447 gtk_widget_get_allocation (GTK_WIDGET (menuitem), &parent_allocation);
448 gtk_widget_get_allocation (priv->scale, allocation);
449
450 allocation->x -= parent_allocation.x;
451 allocation->y -= parent_allocation.y;
452}
453
454static gboolean440static gboolean
455ido_scale_menu_item_parent_key_press_event (GtkWidget *widget,441ido_scale_menu_item_parent_key_press_event (GtkWidget *widget,
456 GdkEventKey *event,442 GdkEventKey *event,
@@ -506,19 +492,13 @@
506{492{
507 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);493 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
508 GtkAllocation alloc;494 GtkAllocation alloc;
509495 gint x, y;
510 ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc);496
511497 gtk_widget_get_allocation (priv->scale, &alloc);
512 // can we block emissions of "grab-notify" on parent??498 gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
513499
514 event->x -= alloc.x;500 if (x > 0 && x < alloc.width && y > 0 && y < alloc.height)
515 event->y -= alloc.y;501 gtk_widget_event (priv->scale, (GdkEvent *) event);
516
517 event->x_root -= alloc.x;
518 event->y_root -= alloc.y;
519
520 gtk_widget_event (priv->scale,
521 ((GdkEvent *)(void*)(event)));
522502
523 if (!priv->grabbed)503 if (!priv->grabbed)
524 {504 {
@@ -526,7 +506,7 @@
526 g_signal_emit (menuitem, signals[SLIDER_GRABBED], 0);506 g_signal_emit (menuitem, signals[SLIDER_GRABBED], 0);
527 }507 }
528508
529 return FALSE;509 return TRUE;
530}510}
531511
532static gboolean512static gboolean
@@ -537,11 +517,13 @@
537 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);517 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
538 GtkWidget *scale = priv->scale;518 GtkWidget *scale = priv->scale;
539 GtkAllocation alloc;519 GtkAllocation alloc;
520 gint x, y;
540521
541 ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc);522 gtk_widget_get_allocation (priv->scale, &alloc);
523 gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
542524
543 /* if user clicked to the left of the scale... */525 /* if user clicked to the left of the scale... */
544 if (event->x < alloc.x)526 if (x < 0)
545 {527 {
546 if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR)528 if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR)
547 {529 {
@@ -554,7 +536,7 @@
554 }536 }
555537
556 /* if user clicked to the right of the scale... */538 /* if user clicked to the right of the scale... */
557 else if (event->x > alloc.x + alloc.width)539 else if (x > alloc.width)
558 {540 {
559 if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR)541 if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR)
560 {542 {
@@ -567,15 +549,9 @@
567 }549 }
568550
569 /* user clicked on the scale... */551 /* user clicked on the scale... */
570 else552 else if (x > 0 && x < alloc.width && y > 0 && y < alloc.height)
571 {553 {
572 event->x -= alloc.x;554 gtk_widget_event (scale, (GdkEvent*) event);
573 event->y -= alloc.y;
574
575 event->x_root -= alloc.x;
576 event->y_root -= alloc.y;
577
578 gtk_widget_event (scale, (GdkEvent*)event);
579 }555 }
580556
581 if (priv->grabbed)557 if (priv->grabbed)
@@ -592,19 +568,15 @@
592 GdkEventMotion *event)568 GdkEventMotion *event)
593{569{
594 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);570 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
595 GtkWidget *scale = priv->scale;
596 GtkAllocation alloc;571 GtkAllocation alloc;
597572 gint x, y;
598 ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc);573
599574 gtk_widget_get_allocation (priv->scale, &alloc);
600 event->x -= alloc.x;575 gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
601 event->y -= alloc.y;576
602577 if (priv->grabbed ||
603 event->x_root -= alloc.x;578 (x > 0 && x < alloc.width && y > 0 && y < alloc.height))
604 event->y_root -= alloc.y;579 gtk_widget_event (priv->scale, (GdkEvent *) event);
605
606 gtk_widget_event (scale,
607 ((GdkEvent *)(void*)(event)));
608580
609 return TRUE;581 return TRUE;
610}582}

Subscribers

People subscribed via source and target branches