bool trayMessageW( DWORD msg ) { resolveLibs(); if ( ! (ptrShell_NotifyIcon && qWinVersion() & Qt::WV_NT_based) ) return trayMessageA( msg ); NOTIFYICONDATAW tnd; ZeroMemory( &tnd, sizeof(NOTIFYICONDATAW) ); tnd.cbSize = sizeof(NOTIFYICONDATAW); tnd.hWnd = winId(); tnd.uID = 1; // michalj if ( msg != NIM_DELETE ) { tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; tnd.uCallbackMessage= WM_NOTIFYICON; tnd.hIcon = hIcon; if ( !iconObject->toolTip().isNull() ) { // Tip is limited to 63 + NULL; lstrcpyn appends a NULL terminator. QString tip = iconObject->toolTip().left( 63 ) + QChar(); lstrcpynW(tnd.szTip, (TCHAR*)tip.unicode(), QMIN( tip.length()+1, 64 ) ); // lstrcpynW(tnd.szTip, (TCHAR*)qt_winTchar( tip, FALSE ), QMIN( tip.length()+1, 64 ) ); } } return ptrShell_NotifyIcon(msg, &tnd); }
static HCURSOR qt_createPixmapCursor( const QCursor &cursor, const QPixmap &pixmap, const QPoint &hotspot ) { QSize size; /* calculate size of cursor */ QPoint pt = hotspot - cursor.hotSpot(); QPoint pixmap_point( 0, 0 ); QPoint cursor_point( 0, 0 ); if ( qWinVersion() <= Qt::WV_95 ) { /* Win95 can only fixed size */ size.setWidth( GetSystemMetrics ( SM_CXCURSOR ) ); size.setHeight ( GetSystemMetrics ( SM_CYCURSOR ) ); } else { /* calculate size (enlarge if needed) */ const QBitmap *tmp = cursor.bitmap(); /* Only bitmap cursors allowed... */ if ( tmp ) { QPoint point; // curent size size = pixmap.size(); // calc position of lower right cursor pos point.setX( pt.x() + tmp->size().width() ); point.setY( pt.y() + tmp->size().height() ); // resize when cursor to large if ( point.x() > pixmap.width() ) size.setWidth( point.x() ); if ( point.y() > pixmap.height() ) size.setHeight( point.y() ); // calc upper left corner where both pixmaps have to be drawn if ( pt.x() >= 0 ) { cursor_point.setX( pt.x() ); } else { pixmap_point.setX( -pt.x() ); // negative position -> resize size.setWidth( size.width() - pt.x() ); } if ( pt.y() >= 0 ) { cursor_point.setX( pt.x() ); } else { pixmap_point.setY( -pt.y() ); // negative position -> resize size.setHeight( size.height() - pt.y() ); } } } /* Mask */ QBitmap andMask( size ); BitBlt( andMask.handle(), 0, 0, size.width(), size.height(), NULL, 0, 0, WHITENESS ); if ( pixmap.mask() ) BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), pixmap.mask() ->handle(), 0, 0, SRCAND ); else BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), NULL, 0, 0, BLACKNESS ); const QBitmap *curMsk = cursor.mask(); if ( curMsk ) BitBlt( andMask.handle(), cursor_point.x(), cursor_point.y(), curMsk->width(), curMsk->height(), curMsk->handle(), 0, 0, SRCAND ); /* create Pixmap */ QPixmap xorMask( size ); xorMask.fill ( Qt::color1 ); QPainter paint2( &xorMask ); paint2.drawPixmap( pixmap_point, pixmap ); QPixmap pm; pm.convertFromImage( cursor.bitmap() ->convertToImage().convertDepth( 8 ) ); pm.setMask( *cursor.mask() ); paint2.drawPixmap ( cursor_point, pm ); paint2.end(); #ifdef DEBUG_QDND_SRC andMask.save ( "pand.png", "PNG" ); xorMask.save ( "pxor.png", "PNG" ); #endif HCURSOR cur = qt_createPixmapCursor ( qt_display_dc(), xorMask, andMask, hotspot, size ); if ( !cur ) { qWarning( "Error creating cursor: %d", GetLastError() ); } return cur; }
extern "C" NPError NPP_SetWindow(NPP instance, NPWindow* window) { if (!qNP) qNP = QNPlugin::create(); NPError result = NPERR_NO_ERROR; _NPInstance* This; if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; This = (_NPInstance*) instance->pdata; // take a shortcut if all that was changed is the geometry if ( This->widget && window #ifdef Q_WS_X11 && This->window == (Window) window->window #endif #ifdef Q_WS_WIN && This->window == (HWND) window->window #endif ) { This->x = window->x; This->y = window->y; This->width = window->width; This->height = window->height; This->widget->resize( This->width, This->height ); return result; } delete This->widget; if ( !window ) return result; #ifdef Q_WS_X11 This->window = (Window) window->window; This->display = ((NPSetWindowCallbackStruct *)window->ws_info)->display; #endif #ifdef Q_WS_WIN This->window = (HWND) window->window; #endif This->x = window->x; This->y = window->y; This->width = window->width; This->height = window->height; if (!qApp) { #ifdef Q_WS_X11 // We are the first Qt-based plugin to arrive event_loop = new QNPXt( "qnp", XtDisplayToApplicationContext(This->display) ); application = new QApplication(This->display); #endif #ifdef Q_WS_WIN static int argc=0; static char **argv={ 0 }; application = new QApplication( argc, argv ); #ifdef UNICODE if ( qWinVersion() & Qt::WV_NT_based ) hhook = SetWindowsHookExW( WH_GETMESSAGE, FilterProc, 0, GetCurrentThreadId() ); else #endif hhook = SetWindowsHookExA( WH_GETMESSAGE, FilterProc, 0, GetCurrentThreadId() ); #endif } #ifdef Q_WS_X11 if ( !original_x_errhandler ) original_x_errhandler = XSetErrorHandler( dummy_x_errhandler ); #endif // New widget on this new window. next_pi = This; /* This->widget = */ // (happens sooner - in QNPWidget constructor) This->instance->newWindow(); if ( !This->widget ) return result; #ifdef Q_WS_X11 This->widget->resize( This->width, This->height ); XReparentWindow( This->widget->x11Display(), This->widget->winId(), This->window, 0, 0 ); XSync( This->widget->x11Display(), False ); #endif #ifdef Q_WS_WIN LONG oldLong = GetWindowLong(This->window, GWL_STYLE); ::SetWindowLong(This->window, GWL_STYLE, oldLong | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); ::SetWindowLong( This->widget->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS ); ::SetParent( This->widget->winId(), This->window ); This->widget->raise(); This->widget->setGeometry( 0, 0, This->width, This->height ); #endif This->widget->show(); return result; }