mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
b=497498 move nsWindow::UpdateDragStatus to nsDragService::UpdateDragAction r=enndeakin
--HG-- extra : rebase_source : e8198557c42f804cbe7ef758c8d8048af45722ec
This commit is contained in:
parent
657ea8347a
commit
fddba909e3
@ -62,6 +62,10 @@
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK2)
|
||||
#include "gtk2compat.h"
|
||||
#endif
|
||||
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxXlibSurface.h"
|
||||
#include "gfxContext.h"
|
||||
@ -1899,7 +1903,7 @@ nsDragService::RunScheduledTask()
|
||||
// contain a position. However, we can't assume the same when the Motif
|
||||
// protocol is used.
|
||||
if (task == eDragTaskMotion || positionHasChanged) {
|
||||
nsWindow::UpdateDragStatus(mTargetDragContext, this);
|
||||
UpdateDragAction();
|
||||
DispatchMotionEvents();
|
||||
|
||||
if (task == eDragTaskMotion) {
|
||||
@ -1942,6 +1946,44 @@ nsDragService::RunScheduledTask()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// This will update the drag action based on the information in the
|
||||
// drag context. Gtk gets this from a combination of the key settings
|
||||
// and what the source is offering.
|
||||
|
||||
void
|
||||
nsDragService::UpdateDragAction()
|
||||
{
|
||||
// This doesn't look right. dragSession.dragAction is used by
|
||||
// nsContentUtils::SetDataTransferInEvent() to set the initial
|
||||
// dataTransfer.dropEffect, so GdkDragContext::suggested_action would be
|
||||
// more appropriate. GdkDragContext::actions should be used to set
|
||||
// dataTransfer.effectAllowed, which doesn't currently happen with
|
||||
// external sources.
|
||||
|
||||
// default is to do nothing
|
||||
int action = nsIDragService::DRAGDROP_ACTION_NONE;
|
||||
GdkDragAction gdkAction = gdk_drag_context_get_actions(mTargetDragContext);
|
||||
|
||||
// set the default just in case nothing matches below
|
||||
if (gdkAction & GDK_ACTION_DEFAULT)
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
// first check to see if move is set
|
||||
if (gdkAction & GDK_ACTION_MOVE)
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
// then fall to the others
|
||||
else if (gdkAction & GDK_ACTION_LINK)
|
||||
action = nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
|
||||
// copy is ctrl
|
||||
else if (gdkAction & GDK_ACTION_COPY)
|
||||
action = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
|
||||
// update the drag information
|
||||
SetDragAction(action);
|
||||
}
|
||||
|
||||
void
|
||||
nsDragService::DispatchMotionEvents()
|
||||
{
|
||||
|
@ -244,6 +244,7 @@ private:
|
||||
// Callback for g_idle_add_full() to run mScheduledTask.
|
||||
static gboolean TaskDispatchCallback(gpointer data);
|
||||
gboolean RunScheduledTask();
|
||||
void UpdateDragAction();
|
||||
void DispatchMotionEvents();
|
||||
gboolean DispatchDropEvent();
|
||||
};
|
||||
|
@ -5648,43 +5648,6 @@ nsWindow::InitDragEvent(nsDragEvent &aEvent)
|
||||
KeymapWrapper::InitInputEvent(aEvent, modifierState);
|
||||
}
|
||||
|
||||
// This will update the drag action based on the information in the
|
||||
// drag context. Gtk gets this from a combination of the key settings
|
||||
// and what the source is offering.
|
||||
|
||||
/* static */ void
|
||||
nsWindow::UpdateDragStatus(GdkDragContext *aDragContext,
|
||||
nsIDragService *aDragService)
|
||||
{
|
||||
// default is to do nothing
|
||||
int action = nsIDragService::DRAGDROP_ACTION_NONE;
|
||||
GdkDragAction gdkAction = gdk_drag_context_get_actions(aDragContext);
|
||||
|
||||
// set the default just in case nothing matches below
|
||||
if (gdkAction & GDK_ACTION_DEFAULT)
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
// first check to see if move is set
|
||||
if (gdkAction & GDK_ACTION_MOVE)
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
// then fall to the others
|
||||
else if (gdkAction & GDK_ACTION_LINK)
|
||||
action = nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
|
||||
// copy is ctrl
|
||||
else if (gdkAction & GDK_ACTION_COPY)
|
||||
action = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
|
||||
// update the drag information
|
||||
nsCOMPtr<nsIDragSession> session;
|
||||
aDragService->GetCurrentSession(getter_AddRefs(session));
|
||||
|
||||
if (session)
|
||||
session->SetDragAction(action);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
drag_motion_event_cb(GtkWidget *aWidget,
|
||||
GdkDragContext *aDragContext,
|
||||
|
Loading…
x
Reference in New Issue
Block a user