--- /dev/null 2015-11-19 20:55:17.685707015 +0300 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp 2015-11-24 19:06:58.016601948 +0300 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "jni_util.h" +#include "awt.h" +#include +#include "awt_Taskbar.h" +#include "java_awt_Taskbar.h" +#include "awt_Window.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: nativeInit + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WTaskbarPeer_nativeInit + (JNIEnv *env, jclass) +{ + if (SUCCEEDED(::CoInitialize(NULL)) + && SUCCEEDED(::CoCreateInstance(CLSID_TaskbarList, NULL, + CLSCTX_INPROC_SERVER, IID_ITaskbarList, (LPVOID *)&m_Taskbar))) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: setProgressValue + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressValue + (JNIEnv *, jobject, jlong window, jint value) +{ + m_Taskbar->SetProgressValue((HWND)window, value, 100); +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: setProgressState + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressState + (JNIEnv *, jobject, jlong window, jint state) +{ + TBPFLAG flag = TBPF_NOPROGRESS; + switch (state) { + case java_awt_Taskbar_STATE_OFF: flag = TBPF_NOPROGRESS; break; + case java_awt_Taskbar_STATE_NORMAL: flag = TBPF_NORMAL; break; + case java_awt_Taskbar_STATE_PAUSED: flag = TBPF_PAUSED; break; + case java_awt_Taskbar_STATE_INDETERMINATE: flag = TBPF_INDETERMINATE; break; + case java_awt_Taskbar_STATE_ERROR: flag = TBPF_ERROR; break; + } + m_Taskbar->SetProgressState((HWND)window, flag); + +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: flashWindow + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_flashWindow + (JNIEnv *, jobject, jlong window) +{ + AwtWindow::FlashWindowEx((HWND) window, 3, 0, FLASHW_TIMERNOFG); +} + +/* + * Class: sun_awt_windows_WTaskbarPeer + * Method: setOverlayIcon + * Signature: (J[III)V + */ +JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setOverlayIcon + (JNIEnv *env, jobject, jlong window, jintArray buf, jint w, jint h) +{ + HICON icon = CreateIconFromRaster(env, buf, w, h); + m_Taskbar->SetOverlayIcon((HWND)window, icon, NULL); + ::DestroyIcon(icon); +} +#ifdef __cplusplus +} +#endif