Пример #1
0
/* Toolkit independent way of determining if an event window is in the
   menubar. */
Boolean
lw_window_is_in_menubar (Window win, Widget menubar_widget)
{
  return menubar_widget
#if defined (USE_LUCID)
      && XtWindow (menubar_widget) == win;
#endif
#if defined (USE_MOTIF)
      && ((XtWindow (menubar_widget) == win)
	  || (XtWindowToWidget (XtDisplay (menubar_widget), win)
	      && (XtParent (XtWindowToWidget (XtDisplay (menubar_widget), win))
		  == menubar_widget)));
#endif
}
Пример #2
0
NPError nsPluginInstance::SetWindow(NPWindow* aWindow)
{
  if(aWindow == NULL)
    return FALSE;

  mX = aWindow->x;
  mY = aWindow->y;
  mWidth = aWindow->width;
  mHeight = aWindow->height;
  if (mWindow != (Window) aWindow->window) {
    mWindow = (Window) aWindow->window;
    NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct *)aWindow->ws_info;
  mDisplay = ws_info->display;
  mVisual = ws_info->visual;
  mDepth = ws_info->depth;
  mColormap = ws_info->colormap;

  if (!mFontInfo) {
      if (!(mFontInfo = XLoadQueryFont(mDisplay, "9x15")))
    printf("Cannot open 9X15 font\n");
  }
  // add xt event handler
  Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
    if (xtwidget && mXtwidget != xtwidget) {
      mXtwidget = xtwidget;
    long event_mask = ExposureMask;
    XSelectInput(mDisplay, mWindow, event_mask);
    XtAddEventHandler(xtwidget, event_mask, False, (XtEventHandler)xt_event_handler, this);
  }
  }
  draw();
  return TRUE;
}
Пример #3
0
int INTERNAL_cursorpos(float *x, float *y)
{
    int    rootx, rooty, wx, wy, ret;
    Window root, child;
    unsigned int mask;
    Widget wid;
    
    *x = *y = 0.0;
    if ((wid=XtWindowToWidget(INTERNAL_display,xwini[GD.win_id].xwin))==NULL)
        return FALSE;
    if (XtIsManaged(wid)==FALSE)
        return FALSE;
    if (XmGetVisibility(wid) == XmVISIBILITY_FULLY_OBSCURED)
        return FALSE;
    ret = (int) XQueryPointer(INTERNAL_display,
                              xwini[GD.win_id].xwin,
                              &root,
                              &child,
                              &rootx, &rooty,
                              &wx, &wy,
                              &mask);
    *x = usercoorx((float) wx);
    *y = usercoory((float) wy);
    return ret;
}
Пример #4
0
void g_retrievecursor(int store_id)
{
    Widget wid;
    Window w;
    int x,y;

    if (store_id < 0 || store_id > G_MAX_STORE_CURSOR || SC[store_id].w == 0)
        return;

    wid = XtWindowToWidget(INTERNAL_display,SC[store_id].w);
    if (wid && XtIsManaged(wid) &&
        XmGetVisibility(wid) != XmVISIBILITY_FULLY_OBSCURED) {
        w = SC[store_id].w;
        x = SC[store_id].x;
        y = SC[store_id].y;
    }
    else {
        w = INTERNAL_rootwin;
        x = SC[store_id].rootx;
        y = SC[store_id].rooty;
    }
    XWarpPointer(INTERNAL_display,
                 None,
                 w,
                 0, 0,
                 0, 0,
                 x, y);
    XFlush(INTERNAL_display);
}
Пример #5
0
/*!
  For internal use only.
*/
void QNPWidget::setWindow(bool delold)
{
    saveWId = winId(); // ### Don't need this anymore

    create((WId)pi->window, FALSE, delold);

   if ( delold ) {
      // Make sure they get a show()
      clearWState( WState_Visible );
   }

#ifdef _WS_X11_
    Widget w = XtWindowToWidget (qt_xdisplay(), pi->window);
    XtAddEventHandler(w, EnterWindowMask, FALSE, enter_event_handler, pi);
    XtAddEventHandler(w, LeaveWindowMask, FALSE, leave_event_handler, pi);
    Pixmap bgpm=0;
    XColor col;
    XtVaGetValues(w,
	XtNbackground, &col.pixel,
	XtNbackgroundPixmap, &bgpm,
	0, 0);
    XQueryColor(qt_xdisplay(), x11Colormap(), &col);
    setBackgroundColor(QColor(col.red >> 8, col.green >> 8, col.blue >> 8));
    if (bgpm) {
	// ### Need an under-the-hood function here, or we have to
	// ### rewrite lots of code from QPixmap::convertToImage().
	// ### Doesn't matter yet, because Netscape doesn't ever set
	// ### the background image of the window it gives us.
    }
#endif

    createNewWindowsForAllChildren(this);

    setGeometry( pi->x, pi->y, pi->width, pi->height );
}
Пример #6
0
static void
xt_add_focus_listener_tree ( Widget treeroot, XtPointer user_data) 
{
  Window win = XtWindow(treeroot);
  Window *children;
  Window root, parent;
  Display *dpy = XtDisplay(treeroot);
  unsigned int i, nchildren;

  /* ensure we don't add more than once */
  xt_remove_focus_listener( treeroot, user_data);
  xt_add_focus_listener( treeroot, user_data);
  trap_errors();
  if(!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) {
    untrap_error();
    return;
  }

  if(untrap_error()) 
    return;

  for(i=0; i<nchildren; ++i) {
    Widget child = XtWindowToWidget(dpy, children[i]);
    if (child) 
      xt_add_focus_listener_tree( child, user_data);
  }
  XFree((void*)children);

  return;
}
Пример #7
0
void XmdsPopupMenuPosition(XmRowColumnWidget w,XButtonEvent *event)
{
  Widget option = w->row_column.memory_subwidget;
  XtX(w) = event->x_root - (option ? XtX(option) + XtWidth(option) / 2 : 0);
  XtY(w) = event->y_root - (option ? XtY(option) + XtHeight(option) / 2 : 0);
  RC_SetWidgetMoved(w,1);
  RC_CascadeBtn(w) = XtWindowToWidget(XtDisplay(w),event->window);
}
Пример #8
0
// When we are in an event loop of QApplication rather than the browser's
// event loop (eg. for a modal dialog), we still send events to Xt.
static
void np_event_proc( XEvent* e )
{
    Widget xtw = XtWindowToWidget( e->xany.display, e->xany.window );
    if ( xtw && qApp->loopLevel() > 0 ) {
        // Allow Xt to process the event
        qt_np_cascade_event_handler[e->type]( e );
    }
}
Пример #9
0
// When we are in an event loop of QApplication rather than the browser's
// event loop (eg. for a modal dialog), we still send repaint events to
// the browser.
static
void np_event_proc( XEvent* e )
{
    Widget xtw = XtWindowToWidget( e->xany.display, e->xany.window );
    if ( xtw && filterTypeFor( e->type ) == Safe ) {
	// Graciously allow the browser to process the event
	qt_np_cascade_event_handler[e->type]( e );
    }
}
Пример #10
0
static void         
xt_client_focus_listener( Widget w, XtPointer user_data, XEvent *event)
{
  Display *dpy = XtDisplay(w);
  XtClient *xtclient = user_data;
  Window win = XtWindow(w);

  switch(event->type)
    {
    case CreateNotify:
      if(event->xcreatewindow.parent == win) {
        Widget child=XtWindowToWidget( dpy, event->xcreatewindow.window);
        if (child)
          xt_add_focus_listener_tree(child, user_data);
      }
      break;
    case DestroyNotify:
      xt_remove_focus_listener( w, user_data);
      break;
    case ReparentNotify:
      if(event->xreparent.parent == win) {
        /* I am the new parent */
        Widget child=XtWindowToWidget(dpy, event->xreparent.window);
        if (child)
          xt_add_focus_listener_tree( child, user_data);
      }
      else if(event->xreparent.window == win) {
        /* I am the new child */
      }
      else {
        /* I am the old parent */
      }
      break;
    case ButtonRelease:
#if 0
      XSetInputFocus(dpy, XtWindow(xtclient->child_widget), RevertToParent, event->xbutton.time);
#endif
      send_xembed_message ( xtclient,
                            XEMBED_REQUEST_FOCUS, 0, 0, 0, 0);
      break;
    default:
      break;
    } /* End of switch(event->type) */
}
Пример #11
0
static void
SetUpWindow(SqueakPlugin *plugin)
{
  Widget w= XtWindowToWidget(plugin->display, plugin->nswindow);
  DPRINT("NP: SetUpWindow(0x%X)\n", plugin->nswindow);
  XSelectInput(plugin->display, plugin->nswindow, 0); 
  if (plugin->embedded) {
    /* need to capture destroys when page is re-layouted */
    XtAddCallback(w, XtNdestroyCallback, 
		  (XtCallbackProc) DestroyCallback, plugin);
  }
}
Пример #12
0
/*
 * test if there is a menu that has the current focus
 * called from awt_Dialog.c and awt_Component.c
 */
Boolean
awt_util_focusIsOnMenu(Display *display)
{
  Window window;
  Widget widget;
  int32_t rtr;

  XGetInputFocus(display, &window, &rtr);
  if (window == None) {
    return False;
  }

  widget = XtWindowToWidget(display, window);
  if (widget == NULL) {
    return False;
  }

  if (XtIsSubclass(widget, xmMenuShellWidgetClass)) {
    return True;
  }

  #if MOTIF_VERSION!=1
  /* Motif 2.1 uses XmGrabShell on XmComboBox instead
     of XmMenuShell
  */
  if (XtIsSubclass(widget, xmGrabShellWidgetClass)) {
      return True;
  }
  /* Fix 4800638 check the ancestor of focus widget is
     GrabSell
   */
  if (XtIsSubclass(widget, xmListWidgetClass))
  {
      Widget shell = getShellWidget(widget);
      if (shell && XtIsSubclass(shell,
          xmGrabShellWidgetClass))
      {
          return True;
      }
  }
  #endif

  if (XtIsSubclass(widget, xmRowColumnWidgetClass)) {
      unsigned char type;
      XtVaGetValues(widget, XmNrowColumnType, &type, NULL);
      if (type == XmMENU_BAR) {
          return True;
      }
  }
  return False;
}
Пример #13
0
static void
addXtEventHandler(PluginInstance *This)
{
#ifdef MOZ_X11
     Display *dpy = (Display*) This->display;
     Window xwin = (Window) This->window;
     Widget xt_w = XtWindowToWidget(dpy, xwin);
     if (xt_w)
     {
         long event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask;
         XSelectInput(dpy, xwin, event_mask);
         XtAddEventHandler(xt_w, event_mask, False, (XtEventHandler)xt_event_handler, This);
     }
#endif
}
Пример #14
0
static Widget camshellof(int id, struct camwins **cwp)
{
  struct camwins *cw;
  Widget w;
  if (id < 0 || INDEXOF(id) >= VVCOUNT(camshells)) {
    return NULL;
  }
  cw = VVINDEX(camshells, struct camwins, INDEXOF(id));
  if ((w = XtWindowToWidget(dpy, cw->shellwin)) == NULL) {
    return NULL;
  }
  if (cwp) {
    *cwp = cw;
  }
  return w;
}
Пример #15
0
/*!
  For internal use only.
*/
void QNPWidget::unsetWindow()
{
#ifdef _WS_X11_
    WId wi = winId();
    Widget w = XtWindowToWidget (qt_xdisplay(), wi);
    if ( w ) {
	XtRemoveEventHandler(w, LeaveWindowMask, FALSE, leave_event_handler, pi);
	XtRemoveEventHandler(w, EnterWindowMask, FALSE, enter_event_handler, pi);
    }
    destroy( FALSE, FALSE ); // Xt has already destroyed all the windows
#endif
#ifdef _WS_WIN_
    // Nothing special
    destroy( FALSE, TRUE ); // Browser will the window, but not the subwindows
#endif
}
Пример #16
0
// Relacement for Qt function - add Xt stuff for top-level widgets
void qt_XDestroyWindow( const QWidget* qw, Display *display, Window window )
{

    if ( qw->isTopLevel() && !qw->isA("QNPWidget") ) {
	Widget xtw = XtWindowToWidget( display, window );
	if ( xtw ) {
	    XtRemoveEventHandler(xtw, LeaveWindowMask, TRUE, leave_event_handler, 0);
	    XtRemoveEventHandler(xtw, EnterWindowMask, TRUE, enter_event_handler, 0);
	    XtDestroyWidget( xtw );
	} else {
	    XDestroyWindow( display, window );
	}
    } else {
	XDestroyWindow( display, window );
    }
}
static pxembed_server_data
getDataByServerHandle(Window serverHandle) {
    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    pxembed_server_data temp = xembed_list;
    Widget serverWidget = NULL;
    if (serverHandle == None) {
        return NULL;
    }
    serverWidget = XtWindowToWidget(awt_display, serverHandle);
    while (temp != NULL) {
        if (temp->serverHandle == serverHandle || temp->serverWidget == serverWidget) {
            temp->serverHandle = serverWidget;
            return temp;
        }
        temp = temp->next;
    }
    return NULL;
}
Пример #18
0
static GdkWindow *getGdkWindow(PluginInstance *This)
{
#ifdef MOZ_X11
    GdkWindow *gdk_window;
    Window xwin = (Window) This->window;
    Widget xt_w = XtWindowToWidget(This->display, xwin);

    if (xt_w) {
      xt_w = XtParent(xt_w);
      if (xt_w) {
         xwin = XtWindow(xt_w);
         /* xwin = xt_w->core.window; */
      }
    }
    gdk_window = gdk_window_lookup(xwin);
    return gdk_window;
#else
    return NULL;
#endif
}
Пример #19
0
void filePopup(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
 Window root, child, win;
 Widget button;
 FileWindowRec *fw;
 int x, y, x_win, y_win;
 unsigned int mask;
 int item;

 fw = findFileWidgetByForm(w);
 if (!fw || fw->scrolled == None)  return;
 win = XtWindow(fw->icon_box);
 XQueryPointer(dpy, win, &root, &child, &x, &y, &x_win, &y_win, &mask);
 if (child != None)
 {
     button = XtWindowToWidget(dpy, child);
     item = findFileItem(fw, button);
     XtVaSetValues(fw->form, XmNuserData, (XtPointer) item, NULL);
     fileSelect(fw, item);
     if (S_ISDIR(fw->files[item]->stats.st_mode))
     {
	 XmMenuPosition(fw->dirPopup, (XButtonPressedEvent *) event);
	 XtManageChild(fw->dirPopup);
     }
     else if (fw->files[item]->stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
     {
	 XmMenuPosition(fw->execPopup, (XButtonPressedEvent *) event);
	 XtManageChild(fw->execPopup);
     }
     else
     {
	 XmMenuPosition(fw->filePopup, (XButtonPressedEvent *) event);
	 XtManageChild(fw->filePopup);
     }
 }
 else
 {
     XmMenuPosition(fw->formPopup, (XButtonPressedEvent *) event);
     XtManageChild(fw->formPopup);
 }
}
Пример #20
0
void XFE_ComposeAttachFolderView::doCommand(CommandType command, void*,XFE_CommandInfo* info)
{
    if (command==xfeCmdAttachFile) {
        attachFile();
    } else if (command==xfeCmdAttachWebPage) {
        attachLocation();
    } else if ((command==xfeCmdDelete || command==xfeCmdDeleteAttachment) &&
               _folderVisible) {
        deleteAttach();
    } else if (command==xfeCmdShowPopup) {
        // Handle popup menu
        XEvent *event = info->event;
        Widget w = XtWindowToWidget(event->xany.display, event->xany.window);

        if (w == NULL) w=getBaseWidget();

        if (_xfePopup) {
            _xfePopup->position(event);
            _xfePopup->show();
        }
    }
}
Пример #21
0
void INTERNAL_warpcursor(long x, long y)
{
    int destx, desty;
    Widget wid;

    if ((wid=XtWindowToWidget(INTERNAL_display,xwini[GD.win_id].xwin))==NULL)
        return;
    if (XtIsManaged(wid)==FALSE)
        return;
    if (XmGetVisibility(wid) == XmVISIBILITY_FULLY_OBSCURED)
        return;
    destx = (int) x;
    desty = (int) y;
    XWarpPointer(INTERNAL_display,
                 None,
                 xwini[GD.win_id].xwin,
                 0, 0,
                 0, 0,
                 destx, desty);
    xwini[GD.win_id].xlib_old_x = destx;
    xwini[GD.win_id].xlib_old_y = desty;
}
Пример #22
0
Widget
WmPanelistWindowToSubpanel (Display *dpy, Window win)

{
   Widget   subpanel_shell;
   Widget * child_list;
   int      num_children;

   Arg      al[2];
   int      ac;


   /*  Get the widget for the subpanel (Should be only child of the shell!) */

   subpanel_shell = XtWindowToWidget (dpy, win);

   ac = 0; 
   XtSetArg (al[ac], XmNchildren, &child_list);  ac++;
   XtSetArg (al[ac], XmNnumChildren, &num_children);  ac++;
   XtGetValues (subpanel_shell, al, ac);

   return ((num_children > 0) ? child_list[0] : (Widget)NULL);
}
Пример #23
0
JNIEXPORT jobject JNICALL
    awt_GetComponent(JNIEnv* env, void* platformInfo)
{
    Window window = (Window)platformInfo;
    Widget widget = NULL;
    jobject peer = NULL;
    jobject target = NULL;

    AWT_LOCK();

#ifndef XAWT
    if (window != None) {
        widget = XtWindowToWidget(awt_display, window);
    }

    if (widget != NULL) {
        XtVaGetValues (widget, XmNuserData, &peer, NULL);
    }

    if (peer != NULL) {
        target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
    }
#else
    target =  (*env)->GetObjectField(env, peer, targetID);
#endif

    if (target == NULL) {
        JNU_ThrowNullPointerException(env, "NullPointerException");
        AWT_UNLOCK();
        return (jobject)NULL;
    }

    
    AWT_UNLOCK();

    return target;
}
Пример #24
0
Файл: menu.c Проект: thequux/pcb
static void
callback (Widget w, Resource * node, XmPushButtonCallbackStruct * pbcs)
{
  int vi;
  have_xy = 0;
  lesstif_show_crosshair (0);
  if (pbcs->event && pbcs->event->type == KeyPress)
    {
      Dimension wx, wy;
      Widget aw = XtWindowToWidget (display, pbcs->event->xkey.window);
      action_x = pbcs->event->xkey.x;
      action_y = pbcs->event->xkey.y;
      if (aw)
	{
	  Widget p = work_area;
	  while (p && p != aw)
	    {
	      n = 0;
	      stdarg (XmNx, &wx);
	      stdarg (XmNy, &wy);
	      XtGetValues (p, args, n);
	      action_x -= wx;
	      action_y -= wy;
	      p = XtParent (p);
	    }
	  if (p == aw)
	    have_xy = 1;
	}
      //printf("have xy from %s: %d %d\n", XtName(aw), action_x, action_y);
    }

  lesstif_need_idle_proc ();
  for (vi = 1; vi < node->c; vi++)
    if (resource_type (node->v[vi]) == 10)
      if (hid_parse_actions (node->v[vi].value))
	return;
}
Пример #25
0
int findWindow(Window w, FileWindowRec **fw_ret)
{
    Widget w_source = XtWindowToWidget(XtDisplay(toplevel),w);
    return findWidget(w_source, fw_ret);
    
    /* 
    for(fw=file_windows; fw; fw=fw->next)
    {
	if(XtWindow(fw->icon_box)==w || XtWindow(fw->label)==w)
	{
	    *fw_ret=fw;
	    return -1;
	}
	for(i=0;i<fw->n_files;i++)
	    if(XtWindow(fw->files[i]->icon.toggle)==w)
	    {
		*fw_ret = fw;
		return i;
	    }
    }
    *fw_ret=NULL;
    return 0;
    */
}
Пример #26
0
Файл: SetWin.c Проект: aosm/X11
/***********************************************************************
 * This function gets called first when the plugin widget is created and
 * then whenever the plugin is changed.
 ***********************************************************************/
NPError 
NPP_SetWindow(NPP instance, NPWindow* window)
{
    PluginInstance* This;
    Widget netscape_widget;

    if (instance == NULL)
	return NPERR_INVALID_INSTANCE_ERROR;

    if (window == NULL)
	return NPERR_NO_ERROR;

    /*
     * PLUGIN DEVELOPERS:
     *	Before setting window to point to the
     *	new window, you may wish to compare the new window
     *	info to the previous window (if any) to note window
     *	size changes, etc.
     */
    This = (PluginInstance*) instance->pdata;
#ifdef PLUGIN_TRACE
    fprintf(stderr, "SetWindow 0x%x.\n", (Window) window->window);
    fprintf(stderr, "This: 0x%x\n", This);
    if (This->plugin_widget)
	fprintf(stderr, "This->plugin_widget: 0x%x\n", This->plugin_widget);
#endif
    if (RxGlobal.dpy == NULL) {
	RxGlobal.dpy = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
	RxGlobal.wm_delete_window =
	    XInternAtom (RxGlobal.dpy, "WM_DELETE_WINDOW", TRUE);
	RxGlobal.wm_protocols = XInternAtom (RxGlobal.dpy, "WM_PROTOCOLS", TRUE);
    }
    netscape_widget = XtWindowToWidget(RxGlobal.dpy, (Window) window->window);
    if (This->toplevel_widget == NULL)
	This->toplevel_widget = FindToplevel(netscape_widget);

    if (This->plugin_widget != netscape_widget) {

	/* We have a new widget store it */
	This->plugin_widget = netscape_widget;
	This->width = window->width;
	This->height = window->height;

	XtAddCallback (This->plugin_widget, XtNdestroyCallback, 
		       DestroyCB, (XtPointer) This);
	XtAddCallback (This->plugin_widget, "resizeCallback", 
		       ResizeCB, (XtPointer) This);

	if (This->app_group)
	    RxpSetupPluginEventHandlers (This);

	if (This->nclient_windows > 0) {
	    int i;

	    /* We already have the client, so we need to reparent it to the
	       new window */
	    for (i = 0; i < This->nclient_windows; i++) {
		XReparentWindow(RxGlobal.dpy, This->client_windows[i].win,
				XtWindow(netscape_widget), 
				This->client_windows[i].x,
				This->client_windows[i].y);
		if (This->dont_reparent == RxTrue) {
		    XMapWindow (RxGlobal.dpy, This->client_windows[i].win);
		    This->client_windows[i].flags |= RxpMapped;
		}
	    }
	} else			/* no client window, display status widget */
	    RxpSetStatusWidget(This, This->state);
	if (This->dont_reparent != RxFalse) /* can be True or Undef */
	    This->dont_reparent = RxFalse;
	else
	    This->dont_reparent = RxTrue;
    }
    return NPERR_NO_ERROR;
}
Пример #27
0
NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
#if defined(XP_UNIX)
    Window control;
    unsigned int i_control_height = 0, i_control_width = 0;
#endif

    if( ! instance )
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }

    /* NPP_SetWindow may be called before NPP_New (Opera) */
    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
    if( NULL == p_plugin )
    {
        /* we should probably show a splash screen here */
        return NPERR_NO_ERROR;
    }

#if defined(XP_UNIX)
    control = p_plugin->getControlWindow();
#endif

    libvlc_instance_t *p_vlc = p_plugin->getVLC();

    /*
     * PLUGIN DEVELOPERS:
     *  Before setting window to point to the
     *  new window, you may wish to compare the new window
     *  info to the previous window (if any) to note window
     *  size changes, etc.
     */

    /* retrieve current window */
    NPWindow& curwin = p_plugin->getWindow();

#ifdef XP_MACOSX
    if( window && window->window )
    {
        /* check if plugin has a new parent window */
        CGrafPtr drawable = (((NP_Port*) (window->window))->port);

        /* as MacOS X video output is windowless, set viewport */
        libvlc_rectangle_t view, clip;

        /*
        ** browser sets port origin to top-left location of plugin
        ** relative to GrafPort window origin is set relative to document,
        ** which of little use for drawing
        */
        view.top     = ((NP_Port*) (window->window))->porty;
        view.left    = ((NP_Port*) (window->window))->portx;
        view.bottom  = window->height+view.top;
        view.right   = window->width+view.left;

        /* clipRect coordinates are also relative to GrafPort */
        clip.top     = window->clipRect.top;
        clip.left    = window->clipRect.left;
        clip.bottom  = window->clipRect.bottom;
        clip.right   = window->clipRect.right;
#ifdef NOT_WORKING
        libvlc_video_set_viewport(p_vlc, p_plugin->getMD(), &view, &clip);
#else
#warning disabled code
#endif
        /* remember new window */
        p_plugin->setWindow(*window);
    }
    else if( curwin.window )
    {
        /* change/set parent */
        curwin.window = NULL;
    }
#endif /* XP_MACOSX */

#ifdef XP_WIN
    if( window && window->window )
    {
        /* check if plugin has a new parent window */
        HWND drawable = (HWND) (window->window);
        if( !curwin.window || drawable != curwin.window )
        {
            /* reset previous window settings */
            HWND oldwin = (HWND)p_plugin->getWindow().window;
            WNDPROC oldproc = p_plugin->getWindowProc();
            if( oldproc )
            {
                /* reset WNDPROC */
                SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc );
            }
            /* attach our plugin object */
            SetWindowLongPtr((HWND)drawable, GWLP_USERDATA,
                             reinterpret_cast<LONG_PTR>(p_plugin));

            /* install our WNDPROC */
            p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable,
                                             GWL_WNDPROC, (LONG)Manage ) );

            /* change window style to our liking */
            LONG style = GetWindowLong((HWND)drawable, GWL_STYLE);
            style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
            SetWindowLong((HWND)drawable, GWL_STYLE, style);

            /* remember new window */
            p_plugin->setWindow(*window);

            /* Redraw window */
            InvalidateRect( (HWND)drawable, NULL, TRUE );
            UpdateWindow( (HWND)drawable );
        }
    }
    else if( curwin.window )
    {
        /* reset WNDPROC */
        HWND oldwin = (HWND)curwin.window;
        SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
        p_plugin->setWindowProc(NULL);

        curwin.window = NULL;
    }
#endif /* XP_WIN */

#if defined(XP_UNIX)
    /* default to hidden toolbar, shown at the end of this method if asked *
     * developers note : getToolbarSize need to wait the end of this method
     */
    i_control_height = 0;
    i_control_width = window->width;

    if( window && window->window )
    {
        Window  parent  = (Window) window->window;
        if( !curwin.window || (parent != (Window)curwin.window) )
        {
            Display *p_display = ( (NPSetWindowCallbackStruct *)
                                   window->ws_info )->display;

            XResizeWindow( p_display, parent, window->width, window->height );

            int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));

            /* create windows */
            Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
                           window->width, window->height - i_control_height,
                           0, i_blackColor, i_blackColor );
            Window controls = (Window) NULL;
            controls = XCreateSimpleWindow( p_display, parent,
                            0, window->height - i_control_height-1,
                            window->width, i_control_height-1,
                            0, i_blackColor, i_blackColor );

            XMapWindow( p_display, parent );
            XMapWindow( p_display, video );
            if( controls ) { XMapWindow( p_display, controls ); }

            XFlush(p_display);

            /* bind events */
            Widget w = XtWindowToWidget( p_display, parent );

            XtAddEventHandler( w, ExposureMask, FALSE,
                               (XtEventHandler)Redraw, p_plugin );
            XtAddEventHandler( w, StructureNotifyMask, FALSE,
                               (XtEventHandler)Resize, p_plugin );
            XtAddEventHandler( w, ButtonReleaseMask, FALSE,
                               (XtEventHandler)ControlHandler, p_plugin );

            /* remember window */
            p_plugin->setWindow( *window );
            p_plugin->setVideoWindow( video );

            if( controls )
            {
                p_plugin->setControlWindow( controls );
            }

            Redraw( w, (XtPointer)p_plugin, NULL );

            /* now display toolbar if asked through parameters */
            if( p_plugin->b_toolbar )
            {
                p_plugin->showToolbar();
            }
        }
    }
    else if( curwin.window )
    {
        curwin.window = NULL;
    }
#endif /* XP_UNIX */

    if( !p_plugin->b_stream )
    {
        if( p_plugin->psz_target )
        {
            if( p_plugin->playlist_add( p_plugin->psz_target ) != -1 )
            {
                if( p_plugin->b_autoplay )
                {
                    p_plugin->playlist_play();
                }
            }
            p_plugin->b_stream = true;
        }
    }
    return NPERR_NO_ERROR;
}
Пример #28
0
Boolean qnpxt_event_dispatcher( XEvent *event )
{
    static bool grabbed = FALSE;

    QApplication::sendPostedEvents();

    QWidgetIntDict *mapper = &static_d->mapper;
    QWidget* qnpxt = mapper->find( event->xany.window );
    if ( !qnpxt && QWidget::find( event->xany.window) == 0 ) {
	// event is not for Qt, try Xt
	Widget w = XtWindowToWidget( QPaintDevice::x11AppDisplay(),
				     event->xany.window );
	while ( w && ! ( qnpxt = mapper->find( XtWindow( w ) ) ) ) {
	    if ( XtIsShell( w ) ) {
		break;
	    }
	    w = XtParent( w );
	}

 	if ( qnpxt && ( event->type == XKeyPress ||
			 event->type == XKeyRelease ) )  {
	    // remap key events to keep accelerators working
 	    event->xany.window = qnpxt->winId();
 	}

	if ( w ) {
	    if ( !grabbed && ( event->type        == XFocusIn &&
			       event->xfocus.mode == NotifyGrab ) ) {
		// qDebug( "Xt: grab started" );
		grabbed = TRUE;
	    } else if ( grabbed && ( event->type        == XFocusOut &&
				     event->xfocus.mode == NotifyUngrab ) ) {
		// qDebug( "Xt: grab ended" );
		grabbed = FALSE;
	    }
	}
    }

    /*
      If the mouse has been grabbed for a window that we don't know
      about, we shouldn't deliver any pointer events, since this will
      intercept the event that ends the mouse grab that Xt/Motif
      started.
    */
    bool do_deliver = TRUE;
    if ( grabbed && ( event->type == ButtonPress   ||
		      event->type == ButtonRelease ||
		      event->type == MotionNotify  ||
		      event->type == EnterNotify   ||
		      event->type == LeaveNotify ) )
	do_deliver = FALSE;

    last_xevent = event;
    bool delivered = do_deliver && ( qApp->x11ProcessEvent( event ) != -1 );
    last_xevent = 0;
    if ( qnpxt ) {
	switch ( event->type ) {
	case EnterNotify:
	case LeaveNotify:
	    event->xcrossing.focus = False;
	    delivered = FALSE;
	    break;
	case XKeyPress:
	case XKeyRelease:
	    delivered = TRUE;
	    break;
	case XFocusIn:
	case XFocusOut:
	    delivered = FALSE;
	    break;
	default:
	    delivered = FALSE;
	    break;
	}
    }

    qnpxt_keep_alive();

    if ( delivered ) {
	// qDebug( "Qt: delivered event" );
	return True;
    }

    // discard user input events when we have an active popup widget
    if ( QApplication::activePopupWidget() ) {
	switch ( event->type ) {
	case ButtonPress:			// disallow mouse/key events
	case ButtonRelease:
	case MotionNotify:
	case XKeyPress:
	case XKeyRelease:
	case EnterNotify:
	case LeaveNotify:
	case ClientMessage:
	    // qDebug( "Qt: active popup - discarding event" );
	    return True;

	default:
	    break;
	}
    }

    if ( QApplication::activeModalWidget() ) {
	if ( qnpxt ) {
	    // send event through Qt modality handling...
	    if ( !qt_try_modal( qnpxt, event ) ) {
		// qDebug( "Qt: active modal widget discarded event" );
		return True;
	    }
	} else if ( !grabbed ) {
	    // we could have a pure Xt shell as a child of the active
	    // modal widget
	    QWidget *qw = 0;
	    Widget xw = XtWindowToWidget( QPaintDevice::x11AppDisplay(),
					  event->xany.window );
	    while ( xw && !( qw = mapper->find( XtWindow( xw ) ) ) )
		xw = XtParent( xw );

	    while ( qw && qw != QApplication::activeModalWidget() )
		qw = qw->parentWidget();

	    if ( !qw ) {
		// event is destined for an Xt widget, but since Qt has an
		// active modal widget, we stop here...
		switch ( event->type ) {
		case ButtonPress:			// disallow mouse/key events
		case ButtonRelease:
		case MotionNotify:
		case XKeyPress:
		case XKeyRelease:
		case EnterNotify:
		case LeaveNotify:
		case ClientMessage:
		    // qDebug( "Qt: active modal widget discarded unknown event" );
		    return True;
		default:
		    break;
		}
	    }
	}
    }

    if ( static_d->dispatchers[ event->type ]( event ) ) {
	// qDebug( "Xt: delivered event" );
	// Xt handled the event.
	return True;
    }

    return False;
}
Пример #29
0
Boolean qmotif_event_dispatcher( XEvent *event )
{
    TQApplication::sendPostedEvents();

    TQWidgetIntDict *mapper = &static_d->mapper;
    TQWidget* qMotif = mapper->find( event->xany.window );
    if ( !qMotif && TQWidget::find( event->xany.window) == 0 ) {
	// event is not for Qt, try Xt
	Display* dpy = TQPaintDevice::x11AppDisplay();
	Widget w = XtWindowToWidget( dpy, event->xany.window );
	while ( w && ! ( qMotif = mapper->find( XtWindow( w ) ) ) ) {
	    if ( XtIsShell( w ) ) {
		break;
	    }
	    w = XtParent( w );
	}

	if ( qMotif &&
	     ( event->type == XKeyPress || event->type == XKeyRelease ) )  {
	    // remap key events
	    event->xany.window = qMotif->winId();
	}
    }

    last_xevent = event;
    bool delivered = ( tqApp->x11ProcessEvent( event ) != -1 );
    last_xevent = 0;
    if ( qMotif ) {
	switch ( event->type ) {
	case EnterNotify:
	case LeaveNotify:
	    event->xcrossing.focus = False;
	    delivered = FALSE;
	    break;
	case XKeyPress:
	case XKeyRelease:
	    delivered = TRUE;
	    break;
	case XFocusIn:
	case XFocusOut:
	    delivered = FALSE;
	    break;
	default:
	    delivered = FALSE;
	    break;
	}
    }

    if ( delivered )
	return True;


    if ( TQApplication::activePopupWidget() )
	// we get all events through the popup grabs.  discard the event
	return True;

    if ( qMotif && TQApplication::activeModalWidget() ) {
	if ( !tqt_try_modal(qMotif, event) )
	    return True;

    }

    if ( static_d->dispatchers[ event->type ]( event ) )
	// Xt handled the event.
	return True;

    return False;
}
Пример #30
0
/*
**  Button1 press: evaluate at curpos
**  Button2 press: clear marks.  start mark at curpos.
**  Button2 motion: clear old stop mark.  stop mark at curpos
**  Button2 release: same as motion.
*/
static void video_event_handler(Widget w, XtPointer clientData, XEvent *event, Boolean *b)
{
	PLOT *plot = (PLOT *)clientData;
	XButtonEvent *butevent;
	XMotionEvent *motevent;
	XKeyEvent *keyevent;
	char *keybuf;
	KeySym key_sym;
	Modifiers mod_return;
	Widget ew;

	switch (event->type)
	{
		case KeyRelease:
			keyevent = (XKeyEvent *)event;
			ew = XtWindowToWidget(XtDisplay(w), keyevent->window);
			if (ew != plot->plot_widget)
				panel_event_handler(ew, (XtPointer)plot->panel, event, b);
			else
			{
				XtTranslateKeycode(XtDisplay(w), keyevent->keycode, 0, &mod_return, &key_sym);
				if ((keybuf = XKeysymToString(key_sym)) != NULL)
				{
					if (KEY_IS_UP(keybuf))
					{
						panel_unzoom(plot->panel);
					}
					else
					{
						panel_handle_keyrelease(w, plot, keyevent, keybuf);
					}
				}
			}
			break;

		case ButtonPress:
			butevent = (XButtonEvent *) event;
			switch (butevent->button)
			{
				case Button1:
					break;

				case Button2:
					break;

				case Button3:
					XmMenuPosition(plot->plot_popupmenu_widget, butevent);
					XtManageChild(plot->plot_popupmenu_widget);
					break;

				default:
					break;
			}
			break;

		case ButtonRelease:
			butevent = (XButtonEvent *) event;
			switch (butevent->button)
			{
				case Button1:
					break;
				case Button2:
					break;
				case Button3:
					break;
				default:
					break;
			}
			break;

		case MotionNotify:
			motevent = (XMotionEvent *)event;
			if (motevent->state & Button1Mask)
			{
			}
			else if (motevent->state & Button2Mask)
			{
			}
			else if (motevent->state & Button2Mask)
			{
			}
			break;

		default:
			break;
	}
}