Skip to content

Commit

Permalink
Fixes #464, broken platform tests broken on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
twall committed Jul 6, 2015
1 parent f6fd136 commit a0954ce
Show file tree
Hide file tree
Showing 7 changed files with 642 additions and 593 deletions.
92 changes: 46 additions & 46 deletions contrib/platform/src/com/sun/jna/platform/DesktopWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,55 @@
* @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de
*/
public class DesktopWindow {
private HWND hwnd;
private String title;
private String filePath;
private Rectangle locAndSize;
private HWND hwnd;
private String title;
private String filePath;
private Rectangle locAndSize;

/**
* @param hwnd
* The associated window handle for this window.
* @param title
* The title text of the window.
* @param filePath
* The full file path to the main process that created the
* window.
* @param locAndSize
* The window's location on screen and its dimensions.
*/
public DesktopWindow(final HWND hwnd, final String title,
final String filePath, final Rectangle locAndSize) {
this.hwnd = hwnd;
this.title = title;
this.filePath = filePath;
this.locAndSize = locAndSize;
}
/**
* @param hwnd
* The associated window handle for this window.
* @param title
* The title text of the window.
* @param filePath
* The full file path to the main process that created the
* window.
* @param locAndSize
* The window's location on screen and its dimensions.
*/
public DesktopWindow(final HWND hwnd, final String title,
final String filePath, final Rectangle locAndSize) {
this.hwnd = hwnd;
this.title = title;
this.filePath = filePath;
this.locAndSize = locAndSize;
}

/**
* @return The associated window handle for this window.
*/
public HWND getHWND() {
return hwnd;
}
/**
* @return The associated window handle for this window.
*/
public HWND getHWND() {
return hwnd;
}

/**
* @return The title text of the window.
*/
public String getTitle() {
return title;
}
/**
* @return The title text of the window.
*/
public String getTitle() {
return title;
}

/**
* @return The full file path to the main process that created the window.
*/
public String getFilePath() {
return filePath;
}
/**
* @return The full file path to the main process that created the window.
*/
public String getFilePath() {
return filePath;
}

/**
* @return The window's location on screen and its dimensions.
*/
public Rectangle getLocAndSize() {
return locAndSize;
}
/**
* @return The window's location on screen and its dimensions.
*/
public Rectangle getLocAndSize() {
return locAndSize;
}
}
209 changes: 101 additions & 108 deletions contrib/platform/src/com/sun/jna/platform/WindowUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,114 +572,107 @@ protected void setForceHeavyweightPopups(Window w, boolean force) {
}
}

/**
* Obtains the set icon for the window associated with the specified
* window handle.
*
* @param hwnd
* The concerning window handle.
* @return Either the window's icon or {@code null} if an error
* occurred.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
* current platform.
*/
protected BufferedImage getWindowIcon(final HWND hwnd) {
throw new UnsupportedOperationException(
"This platform is not supported, yet.");
}

/**
* Detects the size of an icon.
*
* @param hIcon
* The icon handle type.
* @return Either the requested icon's dimension or an {@link Dimension}
* instance of {@code (0, 0)}.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
* current platform.
*/
protected Dimension getIconSize(final HICON hIcon) {
throw new UnsupportedOperationException(
"This platform is not supported, yet.");
}

/**
* Requests a list of all currently available Desktop windows.
*
* @param onlyVisibleWindows
* Specifies whether only currently visible windows will be
* considered ({@code true}). That are windows which are not
* minimized. The {@code WS_VISIBLE} flag will be checked
* (see: <a href=
* "https://msdn.microsoft.com/de-de/library/windows/desktop/ms633530%28v=vs.85%29.aspx"
* >User32.IsWindowVisible(HWND)</a>).
*
* @return A list with all windows and some detailed information.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
* current platform.
*/
protected List<DesktopWindow> getAllWindows(
final boolean onlyVisibleWindows) {
throw new UnsupportedOperationException(
"This platform is not supported, yet.");
}

/**
* Tries to obtain the Window's title which belongs to the specified
* window handle.
*
* @param hwnd
* The concerning window handle.
* @return Either the title or an empty string of no title was found or
* an error occurred.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
*/
protected String getWindowTitle(final HWND hwnd) {
throw new UnsupportedOperationException(
"This platform is not supported, yet.");
}

/**
* Detects the full file path of the process associated with the specified
* window handle.
*
* @param hwnd
* The concerning window handle for which the PE file path is
* required.
* @return The full file path of the PE file that is associated with the
* specified window handle.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
*/
protected String getProcessFilePath(final HWND hwnd){
throw new UnsupportedOperationException(
"This platform is not supported, yet.");
}

/**
* Requests the location and size of the window associated with the
* specified window handle.
*
* @param hwnd
* The concerning window handle.
* @return The location and size of the window.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
*/
protected Rectangle getWindowLocationAndSize(final HWND hwnd) {
throw new UnsupportedOperationException(
"This platform is not supported, yet.");
}
/**
* Obtains the set icon for the window associated with the specified
* window handle.
*
* @param hwnd
* The concerning window handle.
* @return Either the window's icon or {@code null} if an error
* occurred.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
* current platform.
*/
protected BufferedImage getWindowIcon(final HWND hwnd) {
throw new UnsupportedOperationException("This platform is not supported, yet.");
}

/**
* Detects the size of an icon.
*
* @param hIcon
* The icon handle type.
* @return Either the requested icon's dimension or an {@link Dimension}
* instance of {@code (0, 0)}.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
* current platform.
*/
protected Dimension getIconSize(final HICON hIcon) {
throw new UnsupportedOperationException("This platform is not supported, yet.");
}

/**
* Requests a list of all currently available Desktop windows.
*
* @param onlyVisibleWindows
* Specifies whether only currently visible windows will be
* considered ({@code true}). That are windows which are not
* minimized. The {@code WS_VISIBLE} flag will be checked
* (see: <a href=
* "https://msdn.microsoft.com/de-de/library/windows/desktop/ms633530%28v=vs.85%29.aspx"
* >User32.IsWindowVisible(HWND)</a>).
*
* @return A list with all windows and some detailed information.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
* current platform.
*/
protected List<DesktopWindow> getAllWindows(final boolean onlyVisibleWindows) {
throw new UnsupportedOperationException("This platform is not supported, yet.");
}

/**
* Tries to obtain the Window's title which belongs to the specified
* window handle.
*
* @param hwnd
* The concerning window handle.
* @return Either the title or an empty string of no title was found or
* an error occurred.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
*/
protected String getWindowTitle(final HWND hwnd) {
throw new UnsupportedOperationException("This platform is not supported, yet.");
}

/**
* Detects the full file path of the process associated with the specified
* window handle.
*
* @param hwnd
* The concerning window handle for which the PE file path is
* required.
* @return The full file path of the PE file that is associated with the
* specified window handle.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
*/
protected String getProcessFilePath(final HWND hwnd){
throw new UnsupportedOperationException("This platform is not supported, yet.");
}

/**
* Requests the location and size of the window associated with the
* specified window handle.
*
* @param hwnd
* The concerning window handle.
* @return The location and size of the window.
*
* @throws UnsupportedOperationException
* Thrown if this method wasn't yet implemented for the
*/
protected Rectangle getWindowLocationAndSize(final HWND hwnd) {
throw new UnsupportedOperationException("This platform is not supported, yet.");
}
}
/** Canonical lazy loading of a singleton. */
private static class Holder {
Expand Down
Loading

0 comments on commit a0954ce

Please sign in to comment.