rendered paste body--- Shell2.java 2008-02-28 21:22:18.000000000 -0500+++ Shell.java 2008-02-28 21:21:45.000000000 -0500@@ -114,12 +114,11 @@ * @see SWT */ public class Shell extends Decorations {- int /*long*/ shellHandle, tooltipsHandle, tooltipWindow;- boolean mapped, moved, resized, opened;+ int /*long*/ shellHandle, tooltipsHandle, tooltipWindow, group, modalGroup;+ boolean mapped, moved, resized, opened, fullScreen, showWithParent; int oldX, oldY, oldWidth, oldHeight; int minWidth, minHeight; Control lastActive;- Region region; static final int MAXIMUM_TRIM = 128; @@ -355,6 +354,7 @@ static int checkStyle (int style) { style = Decorations.checkStyle (style);+ style &= ~SWT.TRANSPARENT; if ((style & SWT.ON_TOP) != 0) style &= ~SWT.SHELL_TRIM; int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL; int bits = style & ~mask;@@ -609,11 +609,6 @@ OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color); OS.gtk_widget_modify_bg (shellHandle, OS.GTK_STATE_NORMAL, color); }- int bits = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;- boolean modal = (style & bits) != 0;- //TEMPORARY CODE- if ((style & SWT.ON_TOP) == 0) modal |= (parent != null && (parent.style & bits) != 0);- OS.gtk_window_set_modal (shellHandle, modal); } else { vboxHandle = OS.gtk_bin_get_child (shellHandle); if (vboxHandle == 0) error (SWT.ERROR_NO_HANDLES);@@ -626,6 +621,8 @@ handle = OS.gtk_bin_get_child (scrolledHandle); if (handle == 0) error (SWT.ERROR_NO_HANDLES); }+ group = OS.gtk_window_group_new ();+ if (group == 0) error (SWT.ERROR_NO_HANDLES); /* * Feature in GTK. Realizing the shell triggers a size allocate event, * which may be confused for a resize event from the window manager if@@ -761,6 +758,14 @@ } } +int /*long*/ fixedSizeAllocateProc(int /*long*/ widget, int /*long*/ allocationPtr) {+ int clientWidth = 0;+ if ((style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();+ int /*long*/ result = super.fixedSizeAllocateProc (widget, allocationPtr);+ if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth);+ return result;+}+ void fixStyle (int /*long*/ handle) { } @@ -780,6 +785,21 @@ OS.gtk_widget_size_allocate (vboxHandle, allocation); } +public int getAlpha () {+ checkWidget ();+ if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {+ if (OS.gtk_widget_is_composited (shellHandle)) {+ return (int) (OS.gtk_window_get_opacity (shellHandle) * 255);+ }+ }+ return 255; +}++public boolean getFullScreen () {+ checkWidget();+ return fullScreen;+}+ public Point getLocation () { checkWidget (); int [] x = new int [1], y = new int [1];@@ -787,6 +807,11 @@ return new Point (x [0], y [0]); } +public boolean getMaximized () {+ checkWidget();+ return !fullScreen && super.getMaximized ();+}+ /** * Returns a point describing the minimum receiver's size. The * x coordinate of the result is the minimum width of the receiver.@@ -809,6 +834,34 @@ return new Point (width, height); } +Shell getModalShell () {+ Shell shell = null;+ Shell [] modalShells = display.modalShells;+ if (modalShells != null) {+ int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;+ int index = modalShells.length;+ while (--index >= 0) {+ Shell modal = modalShells [index];+ if (modal != null) {+ if ((modal.style & bits) != 0) {+ Control control = this;+ while (control != null) {+ if (control == modal) break;+ control = control.parent;+ }+ if (control != modal) return modal;+ break;+ }+ if ((modal.style & SWT.PRIMARY_MODAL) != 0) {+ if (shell == null) shell = getShell ();+ if (modal.parent == shell) return modal;+ }+ }+ }+ }+ return null;+}+ public Point getSize () { checkWidget (); int width = OS.GTK_WIDGET_WIDTH (vboxHandle);@@ -840,6 +893,7 @@ * */ public Region getRegion () {+ /* This method is needed for @since 3.0 Javadoc */ checkWidget (); return region; }@@ -967,7 +1021,6 @@ int /*long*/ gtk_map_event (int /*long*/ widget, int /*long*/ event) { minimized = false;- sendEvent (SWT.Deiconify); return 0; } @@ -1012,7 +1065,6 @@ int /*long*/ gtk_unmap_event (int /*long*/ widget, int /*long*/ event) { minimized = true;- sendEvent (SWT.Iconify); return 0; } @@ -1021,6 +1073,14 @@ OS.memmove (gdkEvent, event, GdkEventWindowState.sizeof); minimized = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_ICONIFIED) != 0; maximized = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_MAXIMIZED) != 0;+ fullScreen = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_FULLSCREEN) != 0;+ if ((gdkEvent.changed_mask & OS.GDK_WINDOW_STATE_ICONIFIED) != 0) {+ if (minimized) {+ sendEvent (SWT.Iconify);+ } else {+ sendEvent (SWT.Deiconify);+ }+ } return 0; } @@ -1144,6 +1204,16 @@ } } +public void setAlpha (int alpha) {+ checkWidget ();+ if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {+ if (OS.gtk_widget_is_composited (shellHandle)) {+ alpha &= 0xFF;+ OS.gtk_window_set_opacity (shellHandle, alpha / 255f);+ }+ }+}+ void resizeBounds (int width, int height, boolean notify) { if (redrawWindow != 0) { OS.gdk_window_resize (redrawWindow, width, height);@@ -1168,6 +1238,7 @@ } int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {+ if (fullScreen) setFullScreen (false); /* * Bug in GTK. When either of the location or size of * a shell is changed while the shell is maximized, the@@ -1281,6 +1352,19 @@ } } +public void setFullScreen (boolean fullScreen) {+ checkWidget();+ if (fullScreen) {+ OS.gtk_window_fullscreen (shellHandle);+ } else {+ OS.gtk_window_unfullscreen (shellHandle);+ if (maximized) {+ setMaximized (true);+ }+ }+ this.fullScreen = fullScreen;+}+ /** * Sets the input method editor mode to the argument which * should be the result of bitwise OR'ing together one or more@@ -1429,11 +1513,7 @@ public void setRegion (Region region) { checkWidget (); if ((style & SWT.NO_TRIM) == 0) return;- if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);- int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);- int /*long*/ shape_region = (region == null) ? 0 : region.handle;- OS.gdk_window_shape_combine_region (window, shape_region, 0, 0);- this.region = region;+ super.setRegion (region); } /*@@ -1463,6 +1543,18 @@ public void setVisible (boolean visible) { checkWidget(); if ((OS.GTK_WIDGET_MAPPED (shellHandle) == visible)) return;+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;+ if ((style & mask) != 0) {+ if (visible) {+ display.setModalShell (this);+ OS.gtk_window_set_modal (shellHandle, true);+ } else {+ display.clearModal (this);+ OS.gtk_window_set_modal (shellHandle, false);+ }+ } else {+ updateModal ();+ } if (visible) { sendEvent (SWT.Show); if (isDisposed ()) return;@@ -1479,6 +1571,7 @@ * unminimized or shown on the desktop. */ OS.gtk_widget_show (shellHandle);+ if (enableWindow != 0) OS.gdk_window_raise (enableWindow); if (!OS.GTK_IS_PLUG (shellHandle)) { mapped = false; if (isDisposed ()) return;@@ -1509,7 +1602,6 @@ } mapped = true; - int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; if ((style & mask) != 0) { OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME); }@@ -1603,6 +1695,7 @@ } int trimHeight () { if ((style & SWT.NO_TRIM) != 0) return 0;+ if (fullScreen) return 0; boolean hasTitle = false, hasResize = false, hasBorder = false; hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; hasResize = (style & SWT.RESIZE) != 0;@@ -1619,6 +1712,7 @@ int trimWidth () { if ((style & SWT.NO_TRIM) != 0) return 0;+ if (fullScreen) return 0; boolean hasTitle = false, hasResize = false, hasBorder = false; hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; hasResize = (style & SWT.RESIZE) != 0;@@ -1633,6 +1727,71 @@ return 0; } +void updateModal () {+ int /*long*/ group = 0;+ if (display.getModalDialog () == null) {+ Shell modal = getModalShell ();+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;+ Composite shell = null;+ if (modal == null) {+ if ((style & mask) != 0) shell = this;+ } else {+ shell = modal;+ }+ while (shell != null) {+ if ((shell.style & mask) == 0) {+ group = shell.getShell ().group;+ break;+ }+ shell = shell.parent;+ }+ }+ if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0) && group == 0) { + /*+ * Feature in GTK. Starting with GTK version 2.10, GTK+ * doesn't assign windows to a default group. The fix is to+ * get the handle of the default group and add windows to the+ * group.+ */+ group = OS.gtk_window_get_group(0);+ }+ if (group != 0) {+ OS.gtk_window_group_add_window (group, shellHandle);+ } else {+ if (modalGroup != 0) {+ OS.gtk_window_group_remove_window (modalGroup, shellHandle);+ }+ }+ if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {+ fixModal (group, modalGroup);+ }+ modalGroup = group;+}++void updateShells () {+ Shell [] shells = getShells ();+ for (int i=0; i<shells.length; i++) {+ boolean update = false;+ Shell shell = shells [i];+ if (shell.isUndecorated ()) {+ update = true;+ } else {+ do {+ shell = (Shell) shell.getParent ();+ } while (shell != null && shell != this && !shell.isUndecorated ());+ if (shell != null && shell != this) update = true;+ }+ if (update) {+ if (minimized) {+ OS.gtk_widget_hide (shells [i].shellHandle);+ } else if (showWithParent) {+ OS.gtk_widget_show (shells [i].shellHandle);+ }+ }+ }+ showWithParent = minimized;+}+ void deregister () { super.deregister (); display.removeWidget (shellHandle);@@ -1707,19 +1866,32 @@ void releaseWidget () { super.releaseWidget (); destroyAccelGroup ();+ display.clearModal (this); if (display.activeShell == this) display.activeShell = null; if (tooltipsHandle != 0) OS.g_object_unref (tooltipsHandle); tooltipsHandle = 0;+ if (group != 0) OS.g_object_unref (group);+ group = modalGroup = 0; int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle); OS.gdk_window_remove_filter(window, display.filterProc, shellHandle);- region = null; lastActive = null; } void setToolTipText (int /*long*/ widget, String string) {+ if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {+ byte [] buffer = null;+ if (string != null && string.length () > 0) {+ char [] chars = fixMnemonic (string, false);+ buffer = Converter.wcsToMbcs (null, chars, true);+ }+ OS.gtk_widget_set_tooltip_text (widget, null);+ OS.gtk_tooltip_trigger_tooltip_query (OS.gdk_display_get_default ());+ OS.gtk_widget_set_tooltip_text (widget, buffer); + } else { byte [] buffer = null; if (string != null && string.length () > 0) {- buffer = Converter.wcsToMbcs (null, string, true);+ char [] chars = fixMnemonic (string, false);+ buffer = Converter.wcsToMbcs (null, chars, true); } if (tooltipsHandle == 0) { tooltipsHandle = OS.gtk_tooltips_new ();@@ -1781,5 +1953,7 @@ } } if (set) OS.gtk_tooltips_set_tip (tooltipsHandle, widget, buffer, null);+ }+ } }