int nsWidget::DndCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { nsWidget *pWidget = (nsWidget *) data; PtDndCallbackInfo_t *cbdnd = ( PtDndCallbackInfo_t * ) cbinfo->cbdata; static PtDndFetch_t dnd_data_template = { "Mozilla", "dnddata", Ph_TRANSPORT_INLINE, Pt_DND_SELECT_MOTION, NULL, NULL, NULL, NULL, NULL }; ///* ATENTIE */ printf( "In nsWidget::DndCallback subtype=%d\n", cbinfo->reason_subtype ); PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( cbinfo->event ); //printf("Enter pos=%d %d\n", ptrev->pos.x, ptrev->pos.y ); pWidget->ScreenToWidgetPos( ptrev->pos ); //printf("After trans pos=%d %d pWidget=%p\n", ptrev->pos.x, ptrev->pos.y, pWidget ); switch( cbinfo->reason_subtype ) { case Ph_EV_DND_ENTER: { sDragService->StartDragSession(); pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_ENTER, &ptrev->pos ); PtDndSelect( widget, &dnd_data_template, 1, NULL, NULL, cbinfo ); } break; case Ph_EV_DND_MOTION: { pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_OVER, &ptrev->pos ); } break; case Ph_EV_DND_DROP: nsDragService *d; d = ( nsDragService * )sDragService; if( d->SetDropData( (char*)cbdnd->data ) != NS_OK ) break; pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_DROP, &ptrev->pos ); sDragService->EndDragSession(); ((nsDragService*) sDragService)->SourceEndDrag(); break; case Ph_EV_DND_LEAVE: pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_EXIT, &ptrev->pos ); sDragService->EndDragSession(); break; case Ph_EV_DND_CANCEL: pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_EXIT, &ptrev->pos ); sDragService->EndDragSession(); ((nsDragService*) sDragService)->SourceEndDrag(); break; } return Pt_CONTINUE; }
void system_event(PhEvent_t *msg, input_region_data_t *regdat) { PhRect_t *rect; struct devctl_disparea_res new_res; switch(msg->subtype) { case Ph_SYSTEM_REGION_CHANGE: { PhSystemEvent_t *sys; sys = PhGetData(msg); if(sys->RegionChange.input_group == regdat->region.input_group) { if((sys->RegionChange.flags & 0x00ff) == Ph_GRAFX_REGION) { if(sys->RegionChange.fields == -1) { input_module_t *module; if(bus_interrogate(DEVI_CLASS_ABS, &module)) { rect = &sys->RegionChange.rect; /* * This will insure we get the * "real" graphics region */ query_grafx_region(regdat->region.input_group, rect); new_res.xl = rect->ul.x; new_res.yl = rect->ul.y; new_res.xh = rect->lr.x; new_res.yh = rect->lr.y; do { (module->devctrl)(module, DEVCTL_RESCHG, &new_res); } while(bus_interrogate(0, &module)); } } } } break; } default: break; } }
void nsWidget::DispatchDragDropEvent( PhEvent_t *phevent, PRUint32 aEventType, PhPoint_t *pos ) { nsEventStatus status; nsMouseEvent event(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); InitEvent( event, aEventType ); event.point.x = pos->x; event.point.y = pos->y; PhDndEvent_t *dnd = ( PhDndEvent_t * ) PhGetData( phevent ); event.isControl = ( dnd->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE; event.isShift = ( dnd->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE; event.isAlt = ( dnd->key_mods & Pk_KM_Alt ) ? PR_TRUE : PR_FALSE; event.isMeta = PR_FALSE; event.widget = this; ///* ATENTIE */ printf("DispatchDragDropEvent pos=%d %d widget=%p\n", event.point.x, event.point.y, this ); DispatchEvent( &event, status ); }
void service_event(PhEvent_t *msg, input_region_data_t *regdat) { short *inputctrl_ev; if (verbosity >= 8) printf("service_event\n"); switch(msg->subtype) { case Ph_EV_POINTER_CTRL: if (verbosity) printf("Ph_EV_POINTER_CTRL\n"); case Ph_EV_KEYBOARD_CTRL: if (verbosity) printf("Ph_EV_KEYBOARD_CTRL\n"); inputctrl_ev = PhGetData(msg); switch(*inputctrl_ev) { case _CTRL_FILTER: filter_ctrl(msg->subtype, inputctrl_ev); break; #if 0 case _CTRL_DEVICE: device_ctrl(msg->subtype, inputctrl_ev); break; #endif default: break; } } }
static int ph_DispatchEvent(_THIS) { int posted; PhRect_t* rect; PhPointerEvent_t* pointerEvent; PhKeyEvent_t* keyEvent; PhWindowEvent_t* winEvent; int i, buttons; SDL_Rect sdlrects[50]; posted = 0; switch (event->type) { case Ph_EV_BOUNDARY: { if (event->subtype == Ph_EV_PTR_ENTER) { posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } else if (event->subtype ==Ph_EV_PTR_LEAVE) { posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } break; case Ph_EV_PTR_MOTION_BUTTON: case Ph_EV_PTR_MOTION_NOBUTTON: { if (SDL_VideoSurface) { pointerEvent = PhGetData(event); rect = PhGetRects(event); if (mouse_relative) { posted = ph_WarpedMotion(this, event); } else { posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y); } } } break; case Ph_EV_BUT_PRESS: { pointerEvent = PhGetData( event ); buttons = ph2sdl_mousebutton( pointerEvent->buttons ); if (buttons != 0) { posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0); } } break; case Ph_EV_BUT_RELEASE: { pointerEvent = PhGetData(event); buttons = ph2sdl_mousebutton(pointerEvent->buttons); if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0) { posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); } else if(event->subtype == Ph_EV_RELEASE_PHANTOM) { /* If the mouse is outside the window, * only a phantom release event is sent, so * check if the window doesn't have mouse focus. * Not perfect, maybe checking the mouse button * state for Ph_EV_BOUNDARY events would be * better. */ if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) { posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); } } } break; case Ph_EV_WM: { winEvent = PhGetData(event); /* losing focus */ if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST)) { set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON); posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); } /* gaining focus */ else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS)) { set_motion_sensitivity(this, -1); posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); } /* request to quit */ else if (winEvent->event_f==Ph_WM_CLOSE) { posted = SDL_PrivateQuit(); } /* request to hide/unhide */ else if (winEvent->event_f==Ph_WM_HIDE) { if (currently_hided) { /* got unhide window event */ /* TODO: restore application's palette if in palette mode */ currently_hided=0; } else { /* got hide window event */ /* TODO: restore original palette if in palette mode */ currently_hided=1; } } /* request to resize */ else if (winEvent->event_f==Ph_WM_RESIZE) { SDL_PrivateResize(winEvent->size.w, winEvent->size.h); } /* request to move */ else if (winEvent->event_f==Ph_WM_MOVE) { if (current_overlay!=NULL) { int lockedstate=current_overlay->hwdata->locked; int chromastate=current_overlay->hwdata->ischromakey; SDL_Rect target; current_overlay->hwdata->locked=1; target.x=current_overlay->hwdata->CurrentViewPort.pos.x; target.y=current_overlay->hwdata->CurrentViewPort.pos.y; target.w=current_overlay->hwdata->CurrentViewPort.size.w; target.h=current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->ischromakey=0; ph_DisplayYUVOverlay(this, current_overlay, &target); current_overlay->hwdata->ischromakey=chromastate; current_overlay->hwdata->locked=lockedstate; } } /* request to maximize */ else if (winEvent->event_f==Ph_WM_MAX) { /* window already moved and resized here */ SDL_PrivateResize(winEvent->size.w-winEvent->pos.x, winEvent->size.h-winEvent->pos.y); } /* request to restore */ else if (winEvent->event_f==Ph_WM_RESTORE) { } } break; /* window has been resized, moved or removed */ case Ph_EV_EXPOSE: { if (event->num_rects!=0) { if (SDL_VideoSurface) { rect = PhGetRects(event); for(i=0;i<event->num_rects;i++) { sdlrects[i].x = rect[i].ul.x; sdlrects[i].y = rect[i].ul.y; sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1; sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1; } this->UpdateRects(this, event->num_rects, sdlrects); if (current_overlay!=NULL) { int lockedstate=current_overlay->hwdata->locked; SDL_Rect target; current_overlay->hwdata->locked=1; target.x=current_overlay->hwdata->CurrentViewPort.pos.x; target.y=current_overlay->hwdata->CurrentViewPort.pos.y; target.w=current_overlay->hwdata->CurrentViewPort.size.w; target.h=current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->forcedredraw=1; ph_DisplayYUVOverlay(this, current_overlay, &target); current_overlay->hwdata->forcedredraw=0; current_overlay->hwdata->locked=lockedstate; } } } } break; case Ph_EV_KEY: { SDL_keysym keysym; posted = 0; keyEvent = PhGetData( event ); if (Pk_KF_Key_Down & keyEvent->key_flags) { /* split the wheel events from real key events */ if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); break; } if ((keyEvent->key_cap==Pk_Down) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); break; } posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym)); } else /* must be key release */ { /* split the wheel events from real key events */ if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); break; } if ((keyEvent->key_cap==Pk_Down) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid)) { posted = SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); break; } posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym)); } } break; } return(posted); }
/***************************************************************************** * QNXManage: handle QNX events ***************************************************************************** * This function should be called regularly by video output thread. It allows * window resizing. It returns a non null value on error. *****************************************************************************/ static int QNXManage( vout_thread_t *p_vout ) { int i_ev, i_buflen; PhEvent_t *p_event; bool b_repos = 0; if (!vlc_object_alive (p_vout)) { return ( 0 ); } /* allocate buffer for event */ i_buflen = sizeof( PhEvent_t ) * 4; if( ( p_event = malloc( i_buflen ) ) == NULL ) return( 1 ); /* event loop */ do { memset( p_event, 0, i_buflen ); i_ev = PhEventPeek( p_event, i_buflen ); if( i_ev == Ph_RESIZE_MSG ) { PhEvent_t *buf; i_buflen = PhGetMsgSize( p_event ); buf = realloc( p_event, i_buflen ); if( buf == NULL ) { free( p_event ); return( 1 ); } p_event = buf; } else if( i_ev == Ph_EVENT_MSG ) { PtEventHandler( p_event ); if( p_event->type == Ph_EV_WM ) { PhWindowEvent_t *p_ev = PhGetData( p_event ); switch( p_ev->event_f ) { case Ph_WM_CLOSE: p_vout->p_libvlc->b_die = true; break; case Ph_WM_MOVE: p_vout->p_sys->pos.x = p_ev->pos.x; p_vout->p_sys->pos.y = p_ev->pos.y; b_repos = 1; break; case Ph_WM_RESIZE: p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w; p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h; p_vout->p_sys->dim.w = p_ev->size.w; p_vout->p_sys->dim.h = p_ev->size.h; p_vout->i_changes |= VOUT_SIZE_CHANGE; break; } } else if( p_event->type == Ph_EV_KEY ) { PhKeyEvent_t *p_ev = PhGetData( p_event ); long i_key = p_ev->key_sym; if( ( p_ev->key_flags & Pk_KF_Key_Down ) && ( p_ev->key_flags & Pk_KF_Sym_Valid ) ) { switch( i_key ) { case Pk_q: case Pk_Q: p_vout->p_libvlc->b_die = true; break; case Pk_f: case Pk_F: p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; break; default: break; } } } } } while( i_ev != -1 && i_ev != 0 ); free( p_event ); /* * fullscreen */ if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE ) { PhDim_t dim; p_vout->b_fullscreen = !p_vout->b_fullscreen; p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; if( p_vout->b_fullscreen ) { p_vout->p_sys->old_pos.x = p_vout->p_sys->pos.x; p_vout->p_sys->old_pos.y = p_vout->p_sys->pos.y; p_vout->p_sys->pos.x = p_vout->p_sys->pos.y = 0; dim.w = p_vout->p_sys->screen_dim.w + 1; dim.h = p_vout->p_sys->screen_dim.h + 1; } else { p_vout->p_sys->pos.x = p_vout->p_sys->old_pos.x; p_vout->p_sys->pos.y = p_vout->p_sys->old_pos.y; dim.w = p_vout->p_sys->old_dim.w + 1; dim.h = p_vout->p_sys->old_dim.h + 1; } /* modify render flags, border */ PtSetResource( p_vout->p_sys->p_window, Pt_ARG_WINDOW_RENDER_FLAGS, p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE ); /* set position and dimension */ PtSetResource( p_vout->p_sys->p_window, Pt_ARG_POS, &p_vout->p_sys->pos, 0 ); PtSetResource( p_vout->p_sys->p_window, Pt_ARG_DIM, &dim, 0 ); /* mark as damaged to force redraw */ PtDamageWidget( p_vout->p_sys->p_window ); } /* * size change */ if( p_vout->i_changes & VOUT_SIZE_CHANGE ) { p_vout->i_changes &= ~VOUT_SIZE_CHANGE; if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) { ResizeOverlayOutput(p_vout); } #if 0 else { p_vout->output.i_width = p_vout->p_sys->dim.w; p_vout->output.i_height = p_vout->p_sys->dim.h; p_vout->i_changes |= VOUT_YUV_CHANGE; QNXEnd( p_vout ); if( QNXInit( p_vout ) ) { msg_Err( p_vout, "cannot resize display" ); return( 1 ); } } #endif msg_Dbg( p_vout, "video display resized (%dx%d)", p_vout->p_sys->dim.w, p_vout->p_sys->dim.h ); } /* * position change, move video channel */ if( b_repos && p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) { ResizeOverlayOutput(p_vout); } return( i_ev == -1 ); }
// used only once inline PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) { PRBool result = PR_TRUE; // call the default nsWindow proc PhEvent_t* event = aCbInfo->event; static int prevx=-1, prevy=-1, left_button_down, kwww_outbound_valid; if (event->processing_flags & Ph_CONSUMED) return PR_TRUE; switch ( event->type ) { case Ph_EV_PTR_MOTION_NOBUTTON: { PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); if( ptrev ) { if( ptrev->flags & Ph_PTR_FLAG_Z_ONLY ) break; // sometimes z presses come out of nowhere */ ///* ATENTIE */ printf( "Ph_EV_PTR_MOTION_NOBUTTON (%d %d)\n", ptrev->pos.x, ptrev->pos.y ); ScreenToWidgetPos( ptrev->pos ); InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); result = DispatchMouseEvent(theMouseEvent); } } break; case Ph_EV_BUT_PRESS: { PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); /* there should be no reason to do this - mozilla should figure out how to call SetFocus */ /* this though fixes the problem with the plugins capturing the focus */ PtWidget_t *disjoint = PtFindDisjoint( widget ); if( PtWidgetIsClassMember( disjoint, PtServer ) || //mozserver PtWidgetIsClassMember( disjoint, PtContainer ) ) //TestPhEmbed PtContainerGiveFocus( widget, aCbInfo->event ); if( ptrev ) { prevx = ptrev->pos.x; prevy = ptrev->pos.y; ScreenToWidgetPos( ptrev->pos ); if( ptrev->buttons & Ph_BUTTON_SELECT ) { // Normally the left mouse button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_DOWN ); left_button_down = 1; } else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_RIGHT_BUTTON_DOWN ); else // middle button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_DOWN ); //printf("*** Button down\n"); result = DispatchMouseEvent(theMouseEvent); // if we're a right-button-down we're trying to popup a context menu. send that event to gecko also if( ptrev->buttons & Ph_BUTTON_MENU ) { nsMouseEvent contextMenuEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); InitMouseEvent( ptrev, this, contextMenuEvent, NS_CONTEXTMENU ); result = DispatchMouseEvent( contextMenuEvent ); } } } break; case Ph_EV_BUT_RELEASE: { PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); // Update the current input group for clipboard mouse events // (mozilla only). Note that for mozserver the mouse based // (eg. Edit->Copy/Paste menu) events don't come through here. // They are sent by the voyager client app via libPtWeb.so to // do_command() in mozserver.cpp. if (sClipboard) sClipboard->SetInputGroup(event->input_group); if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) { if (ptrev) { ScreenToWidgetPos( ptrev->pos ); if ( ptrev->buttons & Ph_BUTTON_SELECT ) { // Normally the left mouse button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); kwww_outbound_valid = 0; // // To be clean, let's not send multiple left button up // events. // if (!left_button_down) break; //case left_button_down = 0; } else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_RIGHT_BUTTON_UP ); else // middle button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_UP ); //printf("*** Button up %s\n", event->subtype==Ph_EV_RELEASE_PHANTOM ? "(phantom)" : ""); result = DispatchMouseEvent(theMouseEvent); } } else if (event->subtype==Ph_EV_RELEASE_OUTBOUND) { PhRect_t rect = {{0,0},{0,0}}; PhRect_t boundary = {{-10000,-10000},{10000,10000}}; //printf("*** OUTBOUND\n"); if (__progname && strcmp(__progname, "kwww") == 0) { // // In kscope we only use dragging to scroll the view. So // we don't want Mozilla to do any special drag processing, // and fake this out by immediately doing a left-button-up. // We do it at (999999,999999) so any control or link under // the pointer doesn't get activated. // ptrev->pos.x = ptrev->pos.y = 999999; InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); result = DispatchMouseEvent(theMouseEvent); InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); result = DispatchMouseEvent(theMouseEvent); left_button_down = 0; kwww_outbound_valid = 1; // // In case we activated a combo box, do another down/up // Sending an Esc key also works. Which is better? // The mouse button method may prevent drag initiation // within (multiline?) input fields. // #if 0 InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_DOWN ); result = DispatchMouseEvent(theMouseEvent); InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); result = DispatchMouseEvent(theMouseEvent); #else PhKeyEvent_t kev; memset( &kev, 0, sizeof(kev) ); kev.key_cap = kev.key_sym = Pk_Escape; kev.key_flags = Pk_KF_Key_Down | Pk_KF_Cap_Valid | Pk_KF_Sym_Valid; DispatchKeyEvent( &kev, 1 ); memset( &kev, 0, sizeof(kev) ); kev.key_cap = Pk_Escape; kev.key_flags = Pk_KF_Cap_Valid; DispatchKeyEvent( &kev, 1 ); #endif } PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK | Ph_TRACK_DRAG),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL); } } break; case Ph_EV_PTR_MOTION_BUTTON: { PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); if( ptrev ) { if( ptrev->flags & Ph_PTR_FLAG_Z_ONLY ) break; // sometimes z presses come out of nowhere */ #ifdef PHOTON_DND if( sDragService ) { nsDragService *d; nsIDragService *s = sDragService; d = ( nsDragService * )s; d->SetNativeDndData( widget, event ); } #endif if (!__progname || strcmp(__progname, "kwww") != 0) { // // We don't send these events in kscope. Dragging is devoted to // scrolling. // ScreenToWidgetPos( ptrev->pos ); InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); result = DispatchMouseEvent(theMouseEvent); } } } break; case Ph_EV_KEY: // Update the current input group for clipboard key events. This // covers both mozserver and mozilla. if (sClipboard) sClipboard->SetInputGroup(event->input_group); result = DispatchKeyEvent( (PhKeyEvent_t*) PhGetData( event ), 0 ); break; case Ph_EV_DRAG: { nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); switch(event->subtype) { static int is_kwww=-1; case Ph_EV_DRAG_COMPLETE: { nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event ); //printf("*** Drag complete\n"); if (is_kwww) { // Already did the button up kwww_outbound_valid = 0; prevx = prevy = -1; } else { ScreenToWidgetPos( ptrev2->pos ); InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); result = DispatchMouseEvent(theMouseEvent); left_button_down = 0; } } break; case Ph_EV_DRAG_MOTION_EVENT: { PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event ); //printf("*** Drag motion\n"); if (is_kwww == -1) { is_kwww = 0; if (__progname && strcmp(__progname, "kwww") == 0) is_kwww = 1; } if (is_kwww) { nsIWidget *nsw = this; nsIWidget *top_widget = nsw; if (!kwww_outbound_valid) { struct dragevent { PhEvent_t hdr; PhDragEvent_t drag; } ev; // // If the user does a drag where he releases the left mouse // button almost right away, then we will start getting // drag events even though the mouse button is not pressed! // Work around this Photon bug by cancelling the drag // ourselves. In 6.4.0 we can use PhCancelDrag() to do this. // //printf("*** CANCELLING DRAG!\n"); memset( &ev, 0, sizeof(ev) ); ev.hdr.type = Ph_EV_DRAG; ev.hdr.emitter.rid = Ph_DEV_RID; ev.hdr.flags = Ph_EVENT_INCLUSIVE | Ph_EMIT_TOWARD; ev.hdr.data_len = sizeof( ev.drag ); ev.hdr.subtype = Ph_EV_DRAG_COMPLETE; ev.hdr.input_group = aCbInfo->event->input_group; ev.drag.rid = PtWidgetRid(mWidget); ev.drag.flags = 0; PhEmit( &ev.hdr, NULL, &ev.drag ); break; //case } while (nsw) { top_widget = nsw; nsw = nsw->GetParent(); } try_again: nsIView *view = nsToolkit::GetViewFor(top_widget); if (view) { nsIViewManager* vm = view->GetViewManager(); if (vm) { nsIScrollableView* scrollView = nsnull; vm->GetRootScrollableView(&scrollView); if (scrollView) { if (prevx != -1 || prevy != -1) { // // The -1 check is to handle prevx and prevy not set // to the button press location, which happens when // you click on flash. // nsresult rc = ((nsIScrollableView_MOZILLA_1_8_BRANCH*)scrollView)->ScrollByPixels(prevx - ptrev2->pos.x, prevy - ptrev2->pos.y); //printf("*** rc %d from ScrollByPixels\n"); } } else if (top_widget != this) { // // There is no scrollable view for the top level widget. // See if there is one for the original widget. // top_widget = this; goto try_again; } } } prevx = ptrev2->pos.x; prevy = ptrev2->pos.y; } else { ScreenToWidgetPos( ptrev2->pos ); InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_MOVE ); result = DispatchMouseEvent(theMouseEvent); } } break; } } break; case Ph_EV_BOUNDARY: PRUint32 evtype; switch( event->subtype ) { case Ph_EV_PTR_ENTER: case Ph_EV_PTR_ENTER_FROM_CHILD: evtype = NS_MOUSE_ENTER; break; case Ph_EV_PTR_LEAVE_TO_CHILD: case Ph_EV_PTR_LEAVE: evtype = NS_MOUSE_EXIT; break; default: evtype = 0; break; } if( evtype != 0 ) { PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal); ScreenToWidgetPos( ptrev->pos ); InitMouseEvent( ptrev, this, theMouseEvent, evtype ); result = DispatchMouseEvent( theMouseEvent ); } break; } return result; }
/* * Create a display screen, or window, large enough to accomodate a bitmap * of the given dimensions. */ int I_GetEvent(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo, int bitmap_depth ) { int mask=FALSE; int kdosomething=FALSE; PhKeyEvent_t *kevent; PhPointerEvent_t *pevent; int keycode,code; int *pt; struct xmame_keyboard_event mame_key_event; char keyname[16+1]; mame_key_event.press = FALSE; switch (cbinfo->event->type) { case Ph_EV_KEY: { kevent = PhGetData (cbinfo->event); if (PkIsFirstDown (kevent->key_flags)) { mask=TRUE; mame_key_event.press=TRUE; kdosomething = TRUE; } else if (!PkIsKeyDown(kevent->key_flags)) kdosomething = TRUE; if (kdosomething) { if (kevent->key_flags & Pk_KF_Cap_Valid) keycode = kevent->key_cap; else goto getevent_done; if ((keycode & 0xF000) == 0xF000) { pt=extended_code_table; keycode &= 0x00FF; } else { pt=code_table; } mame_key_event.scancode = *(pt+keycode); if (PhKeyToMb (keyname, kevent) == -1) { keyname[0]=0; } mame_key_event.unicode = keyname[0]; //phkey [ *(pt+keycode) ] = mask; xmame_keyboard_register_event(&mame_key_event); } break; } case Ph_EV_BUT_PRESS: pevent = PhGetData( cbinfo->event ); if (pevent->buttons & Ph_BUTTON_SELECT) { mouse_data[0].buttons[0] = TRUE; } if (pevent->buttons & Ph_BUTTON_MENU) { mouse_data[0].buttons[1] = TRUE; } if (pevent->buttons & Ph_BUTTON_ADJUST) { mouse_data[0].buttons[2] = TRUE; } break; case Ph_EV_BUT_RELEASE: if( cbinfo->event->subtype != Ph_EV_RELEASE_REAL ) break; pevent = PhGetData( cbinfo->event ); if (pevent->buttons & Ph_BUTTON_SELECT) { mouse_data[0].buttons[0] = FALSE; } if (pevent->buttons & Ph_BUTTON_MENU) { mouse_data[0].buttons[1] = FALSE; } if (pevent->buttons & Ph_BUTTON_ADJUST) { mouse_data[0].buttons[2] = FALSE; } break; case Ph_EV_PTR_MOTION_NOBUTTON: case Ph_EV_PTR_MOTION_BUTTON: if (ph_grab_mouse == FALSE) { pevent = PhGetData( cbinfo->event ); update_mouse=TRUE; mouse_data[0].deltas[0] = pevent->pos.x-current_mouse[0]; mouse_data[0].deltas[1] = pevent->pos.y-current_mouse[1]; current_mouse[0] = pevent->pos.x; current_mouse[1] = pevent->pos.y; } break; case Ph_EV_EXPOSE: if (ph_video_mode==0) { ph_window_refresh_screen(); PgFlush(); } break; case Ph_EV_INFO: { switch (cbinfo->event->subtype) { case Ph_OFFSCREEN_INVALID : fprintf (stderr,"info: got offscreen invalid\n"); if (image != NULL) { fprintf(stderr,"info: creating new image\n"); PhDCRelease(image); image = PdCreateOffscreenContext(0, view_size.w, view_size.h, Pg_OSC_MEM_PAGE_ALIGN); if (image == NULL) { fprintf(stderr_file, "error: failed to create offscreen context\n"); exit(1); } scaled_buffer_ptr = PdGetOffscreenContextPtr (image); if (!scaled_buffer_ptr) { fprintf (stderr_file, "error: failed get a pointer to offscreen context.\n"); PhDCRelease (image); exit(1); } depth = 0; switch (image->format) { case Pg_IMAGE_PALETTE_BYTE : // TODO : break; case Pg_IMAGE_DIRECT_565 : depth = 16; pixels_per_line = image->pitch >> 1; break; case Pg_IMAGE_DIRECT_555 : // TODO: break; case Pg_IMAGE_DIRECT_888 : depth = 24; pixels_per_line = image->pitch / 3; break; case Pg_IMAGE_DIRECT_8888 : depth = 32; pixels_per_line = image->pitch >> 2; break; } ph_init_palette_info(); ph_window_update_display_func=NULL; if (bitmap_depth == 16) { switch(depth) { case 16: ph_window_update_display_func = ph_window_update_16_to_16bpp; break; case 24: ph_window_update_display_func = ph_window_update_16_to_24bpp; break; case 32: ph_window_update_display_func = ph_window_update_16_to_32bpp; break; } } if (ph_window_update_display_func == NULL) { fprintf(stderr_file, "error: Unsupported\n"); exit(1); } } break; } } break; }