private bool ShowDock(Gdk.Event evnt)
{
Adjustment adj = slider.Adjustment;
int x, y, m, dx, dy, sx, sy, ystartoff;
uint event_time;
double v;
if(previous_volume != (int)slider.Adjustment.Lower) {
previous_volume = Volume;
}
if(evnt is Gdk.EventKey) {
event_time = ((Gdk.EventKey)evnt).Time;
} else if(evnt is Gdk.EventButton) {
event_time = ((Gdk.EventButton)evnt).Time;
} else if(evnt is Gdk.EventScroll) {
event_time = ((Gdk.EventScroll)evnt).Time;
} else {
throw new ApplicationException("ShowDock expects EventKey, EventButton, or EventScroll");
}
if(classic) {
dock.Realize();
}
dock.Screen = Screen;
GdkWindow.GetOrigin(out x, out y);
x += Allocation.X;
v = Volume / (adj.Upper - adj.Lower);
if(classic) {
dock.Move(x + (Allocation.Width - dock.Allocation.Width) / 2, y - dock.Allocation.Height);
dock.ShowAll();
Relief = ReliefStyle.Normal;
State = StateType.Active;
} else {
y += Allocation.Y;
dock.Move(x, y - (SCALE_SIZE / 2));
dock.ShowAll();
dock.GdkWindow.GetOrigin(out dx, out dy);
dy += dock.Allocation.Y;
slider.GdkWindow.GetOrigin(out sx, out sy);
sy += slider.Allocation.Y;
ystartoff = sy - dy;
timeout = true;
x += (Allocation.Width - dock.Allocation.Width) / 2;
y -= ystartoff;
y -= slider.MinSliderSize / 2;
m = slider.Allocation.Height - slider.MinSliderSize;
y -= (int)(m * (1.0 - v));
if(evnt is Gdk.EventButton) {
y += (int)((Gdk.EventButton)evnt).Y;
} else if(evnt is Gdk.EventScroll) {
y += (int)((Gdk.EventScroll)evnt).Y;
}
dock.Move(x, y);
slider.GdkWindow.GetOrigin(out sx, out sy);
}
bool base_result = !classic && evnt is Gdk.EventButton
? base.OnButtonPressEvent((Gdk.EventButton)evnt)
: true;
Gtk.Grab.Add(dock);
if(Gdk.Pointer.Grab(dock.GdkWindow, true,
Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask |
Gdk.EventMask.PointerMotionMask, null, null, event_time) != Gdk.GrabStatus.Success) {
Gtk.Grab.Remove(dock);
dock.Hide();
return false;
}
if(Gdk.Keyboard.Grab(dock.GdkWindow, true, event_time) != Gdk.GrabStatus.Success) {
Display.PointerUngrab(event_time);
Gtk.Grab.Remove(dock);
dock.Hide();
return false;
}
if(!classic && evnt is Gdk.EventButton) {
dock.GrabFocus();
Gdk.EventButton evnt_copy = (Gdk.EventButton)Gdk.EventHelper.Copy(evnt);
m = slider.Allocation.Height - slider.MinSliderSize;
UpdateEventButton(evnt_copy, slider.GdkWindow, slider.Allocation.Width / 2,
((1.0 - v) * m) + slider.MinSliderSize / 2);
slider.ProcessEvent(evnt_copy);
Gdk.EventHelper.Free(evnt_copy);
} else {
slider.GrabFocus();
}
pop_time = event_time;
return base_result;
}