x11embedcontainer.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2009 Girish Ramakrishnan (girish@forwardbias.in)
  4. ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
  5. **
  6. ** Use, modification and distribution is allowed without limitation,
  7. ** warranty, liability or support of any kind.
  8. **
  9. ****************************************************************************/
  10. #include "x11embedcontainer.h"
  11. #include <QX11Info>
  12. #include "stream.h"
  13. X11EmbedContainer::X11EmbedContainer(Instance *instance, QWidget *parent)
  14. : QX11EmbedContainer(parent), m_instance(instance)
  15. {
  16. memset(&m_ws_info, 0, sizeof(NPSetWindowCallbackStruct));
  17. connect(this, SIGNAL(clientIsEmbedded()), this, SLOT(startStream()));
  18. }
  19. void X11EmbedContainer::resizeEvent(QResizeEvent *event)
  20. {
  21. NPWindow npwindow;
  22. memset(&npwindow, 0, sizeof(NPWindow));
  23. m_ws_info.type = NP_SETWINDOW; // ??
  24. m_ws_info.display = QX11Info::display();
  25. m_ws_info.visual = (Visual *) QX11Info::appVisual();
  26. m_ws_info.colormap = QX11Info::appColormap();
  27. m_ws_info.depth = QX11Info::appDepth();
  28. npwindow.ws_info = &m_ws_info; // needed, whether windowless or not!
  29. npwindow.type = NPWindowTypeWindow;
  30. npwindow.window = (void *) winId(); // Window
  31. npwindow.x = x();
  32. npwindow.y = y();
  33. npwindow.width = event->size().width();
  34. npwindow.height = event->size().height();
  35. Plugin *plugin = m_instance->plugin();
  36. NPError error = plugin->funcs()->setwindow(m_instance->npInstance(), &npwindow);
  37. if (error != NPERR_NO_ERROR) {
  38. qDebug() << "X11EmbedContainer: Failed to setwindow";
  39. }
  40. }
  41. void X11EmbedContainer::startStream()
  42. {
  43. Stream stream;
  44. stream.write(m_instance);
  45. }