implement maximize for linux-fb

Thu Oct  3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>

        * gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
        gtk/gtkwindow-decorate.c: implement maximize for linux-fb

        * gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode

        * gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
        gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
        gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
        gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
        gdk/linux-fb/mizerline.c: small cleanups
This commit is contained in:
Eric Warmenhoven 2002-10-03 23:45:03 +00:00 committed by Eric Warmenhoven
parent 92fa223146
commit ccc2ccf221
19 changed files with 442 additions and 96 deletions

View File

@ -1,3 +1,16 @@
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
Thu Oct 3 19:00:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):

View File

@ -1,3 +1,16 @@
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
Thu Oct 3 19:00:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):

View File

@ -1,3 +1,16 @@
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
Thu Oct 3 19:00:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):

View File

@ -1,3 +1,16 @@
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
Thu Oct 3 19:00:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):

View File

@ -1,3 +1,16 @@
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
Thu Oct 3 19:00:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):

View File

@ -1,3 +1,16 @@
Thu Oct 3 16:40:18 2002 Eric Warmenhoven <eric@warmenhoven.org>
* gdk/gdkevents.c, gdk/linux-fb/gdkwindow-fb.c,
gtk/gtkwindow-decorate.c: implement maximize for linux-fb
* gdk/linux-fb/gdkkeyboard-fb.c: implement raw keyboard mode
* gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkdnd-fb.c,
gdk/linux-fb/gdkmain-fb.c, gdk/linux-fb/gdkselection-fb.c,
gdk/linux-fb/miarc.c, gdk/linux-fb/mifpolycon.c,
gdk/linux-fb/miwideline.c, gdk/linux-fb/mizerclip.c,
gdk/linux-fb/mizerline.c: small cleanups
Thu Oct 3 19:00:55 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):

View File

@ -1053,10 +1053,10 @@ gdk_synthesize_window_state (GdkWindow *window,
old = ((GdkWindowObject*) temp_event.window_state.window)->state;
temp_event.window_state.changed_mask = (unset_flags | set_flags) ^ old;
temp_event.window_state.new_window_state = old;
temp_event.window_state.new_window_state |= set_flags;
temp_event.window_state.new_window_state &= ~unset_flags;
temp_event.window_state.changed_mask = temp_event.window_state.new_window_state ^ old;
if (temp_event.window_state.new_window_state == old)
return; /* No actual work to do, nothing changed. */

View File

@ -29,9 +29,11 @@ libgdkinclude_HEADERS= \
libgdk_linux_fb_la_SOURCES = \
gdkcolor-fb.c \
gdkcursor-fb.c \
gdkdnd-fb.c \
gdkdisplay-fb.c \
gdkdnd-fb.c \
gdkdrawable-fb2.c \
gdkevents-fb.c \
gdkfbmanager.h \
gdkfont-fb.c \
gdkgc-fb.c \
gdkgeometry-fb.c \
@ -39,19 +41,19 @@ libgdk_linux_fb_la_SOURCES = \
gdkim-fb.c \
gdkimage-fb.c \
gdkinput.c \
gdkmain-fb.c \
gdkpixmap-fb.c \
gdkproperty-fb.c \
gdkselection-fb.c \
gdkscreen-fb.c \
gdkvisual-fb.c \
gdkwindow-fb.c \
gdkprivate-fb.h \
gdkinputprivate.h \
gdkkeyboard-fb.c \
gdkmain-fb.c \
gdkmouse-fb.c \
gdkevents-fb.c \
gdkpango-fb.c \
gdkpixmap-fb.c \
gdkprivate-fb.h \
gdkproperty-fb.c \
gdkrender-fb.c \
gdkscreen-fb.c \
gdkselection-fb.c \
gdkvisual-fb.c \
gdkwindow-fb.c \
mi.h \
miarc.c \
midash.c \
@ -65,16 +67,14 @@ libgdk_linux_fb_la_SOURCES = \
mipolygen.c \
mipolyutil.c \
miscanfill.h \
mispans.h \
mispans.c \
mispans.h \
mistruct.h \
mitypes.h \
miwideline.c \
miwideline.h \
mizerclip.c \
mizerline.c \
gdkpango-fb.c \
gdkfbmanager.h
mizerline.c
gdkfbmanager_sources = gdkfbmanager.c
gdkfbmanager_LDFLAGS = $(GLIB_LIBS)

View File

@ -383,7 +383,7 @@ gdk_drag_get_protocol (guint32 xid,
{
GdkWindow *window;
window = gdk_window_lookup (xid);
window = gdk_window_lookup ((GdkNativeWindow) xid);
if (GPOINTER_TO_INT (gdk_drawable_get_data (window, "gdk-dnd-registered")))
{
@ -392,7 +392,7 @@ gdk_drag_get_protocol (guint32 xid,
}
*protocol = GDK_DRAG_PROTO_NONE;
return GDK_NONE;
return 0;
}
static GdkWindow *
@ -466,7 +466,7 @@ gdk_drag_find_window (GdkDragContext *context,
/* Check if new destination accepts drags, and which protocol */
if ((recipient = gdk_drag_get_protocol ((guint32)dest, protocol)))
{
*dest_window = gdk_window_lookup (recipient);
*dest_window = gdk_window_lookup ((GdkNativeWindow) recipient);
gdk_window_ref (*dest_window);
}
else

View File

@ -817,6 +817,10 @@ xlate_io (GIOChannel *gioc,
gdk_fb_set_rotation (deg);
}
if ((xlate_codes[j].code == GDK_F8) &&
(xlate_codes[j].modifier & GDK_SHIFT_MASK))
exit (1);
gdk_fb_handle_key (xlate_codes[j].code,
xlate_codes[j].code,
@ -1140,16 +1144,16 @@ static const guint trans_table[256][3] = {
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{GDK_Home, 0, 0},
{GDK_Up, 0, 0},
{GDK_Page_Up, 0, 0},
{GDK_Left, 0, 0},
{GDK_Right, 0, 0},
{GDK_End, 0, 0},
{GDK_Down, 0, 0},
{GDK_Page_Down, 0, 0},
{GDK_Insert, 0, 0},
{GDK_Delete, 0, 0},
/* 0x70 */
{0, 0, 0},
@ -1456,7 +1460,7 @@ raw_open (GdkFBKeyboard *kb)
if (ioctl (gdk_display->tty_fd, KDSKBMODE, K_MEDIUMRAW) < 0)
{
g_warning ("setting tty to K_MEDIUMRAW failed");
g_warning ("setting tty to K_MEDIUMRAW failed (are you root?)");
return FALSE;
}
@ -1491,47 +1495,185 @@ raw_close (GdkFBKeyboard *kb)
static guint
raw_lookup (GdkFBKeyboard *kb,
const GdkKeymapKey *key)
const GdkKeymapKey *key)
{
g_warning ("raw_lookup() NIY");
return FALSE;
if (key->group != 0)
return 0;
if ((key->keycode < 0) || (key->keycode >= 256))
return 0;
if ((key->level < 0) || (key->level >= 3))
return 0;
return trans_table[key->keycode][key->level];
}
static gboolean
raw_translate (GdkFBKeyboard *kb,
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers)
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers)
{
g_warning ("raw_translate() NIY");
return FALSE;
guint tmp_keyval;
gint tmp_level;
if (keyval)
*keyval = 0;
if (effective_group)
*effective_group = 0;
if (level)
*level = 0;
if (consumed_modifiers)
*consumed_modifiers = 0;
if ((hardware_keycode < 0) || (hardware_keycode >= 256))
return FALSE;
if (group != 0)
return FALSE;
if (state & GDK_CONTROL_MASK)
tmp_level = 2;
else if (state & GDK_SHIFT_MASK)
tmp_level = 1;
else
tmp_level = 0;
do {
tmp_keyval = trans_table[hardware_keycode][tmp_level --];
} while (!tmp_keyval && (tmp_level >= 0));
if (keyval)
*keyval = tmp_keyval;
if (level)
*level = tmp_level;
return TRUE;
}
static gboolean
raw_get_for_keyval (GdkFBKeyboard *kb,
guint keyval,
GdkKeymapKey **keys,
gint *n_keys)
guint keyval,
GdkKeymapKey **keys,
gint *n_keys)
{
g_warning ("raw_get_for_keyval() NIY");
if (keys) *keys=NULL;
if (n_keys) *n_keys=0;
return FALSE;
GArray *retval;
int i, j;
retval = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
for (i = 0; i < 256; i++)
for (j = 0; j < 3; j++)
if (trans_table[i][j] == keyval)
{
GdkKeymapKey key;
key.keycode = i;
key.group = 0;
key.level = j;
g_array_append_val (retval, key);
}
if (retval->len > 0)
{
*keys = (GdkKeymapKey*) retval->data;
*n_keys = retval->len;
}
else
{
*keys = NULL;
*n_keys = 0;
}
g_array_free (retval, retval->len > 0 ? FALSE : TRUE);
return *n_keys > 0;
}
static gboolean
raw_get_for_keycode (GdkFBKeyboard *kb,
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries)
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries)
{
g_warning ("raw_get_for_keycode() NIY");
if (keys) *keys=NULL;
if (n_entries) *n_entries=0;
return FALSE;
GArray *key_array;
GArray *keyval_array;
int i;
if (hardware_keycode <= 0 ||
hardware_keycode >= 256)
{
if (keys)
*keys = NULL;
if (keyvals)
*keyvals = NULL;
*n_entries = 0;
return FALSE;
}
if (keys)
key_array = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
else
key_array = NULL;
if (keyvals)
keyval_array = g_array_new (FALSE, FALSE, sizeof (guint));
else
keyval_array = NULL;
for (i = 0; i < 3; i++)
{
if (key_array)
{
GdkKeymapKey key;
key.keycode = hardware_keycode;
key.group = 0;
key.level = i;
g_array_append_val (key_array, key);
}
if (keyval_array)
{
g_array_append_val (keyval_array, trans_table[hardware_keycode][i]);
}
}
if ((key_array && key_array->len > 0) ||
(keyval_array && keyval_array->len > 0))
{
if (keys)
*keys = (GdkKeymapKey*) key_array->data;
if (keyvals)
*keyvals = (guint*) keyval_array->data;
if (key_array)
*n_entries = key_array->len;
else
*n_entries = keyval_array->len;
}
else
{
if (keys)
*keys = NULL;
if (keyvals)
*keyvals = NULL;
*n_entries = 0;
}
if (key_array)
g_array_free (key_array, key_array->len > 0 ? FALSE : TRUE);
if (keyval_array)
g_array_free (keyval_array, keyval_array->len > 0 ? FALSE : TRUE);
return *n_entries > 0;
}

View File

@ -409,7 +409,7 @@ gdk_fb_setup_mode_from_name (struct fb_var_screeninfo *modeinfo,
scanner->input_name = filename;
for (i = 0; i < sizeof(fb_modes_keywords)/sizeof(fb_modes_keywords[0]); i++)
g_scanner_add_symbol (scanner, fb_modes_keywords[i], GINT_TO_POINTER (i));
g_scanner_scope_add_symbol (scanner, 0, fb_modes_keywords[i], GINT_TO_POINTER (i));
g_scanner_input_file (scanner, fd);

View File

@ -216,7 +216,7 @@ gdk_selection_send_notify_for_display (GdkDisplay *display,
GdkEvent *event;
GdkWindow *event_window;
event_window = gdk_fb_other_event_window (gdk_window_lookup (requestor), GDK_SELECTION_NOTIFY);
event_window = gdk_fb_other_event_window (gdk_window_lookup ((GdkNativeWindow) requestor), GDK_SELECTION_NOTIFY);
if (event_window)
{
event = gdk_event_make (event_window, GDK_SELECTION_NOTIFY, TRUE);

View File

@ -2154,7 +2154,9 @@ gdk_window_maximize (GdkWindow *window)
{
g_return_if_fail (GDK_IS_WINDOW (window));
g_warning ("gdk_window_maximize() not implemented.\n");
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_MAXIMIZED);
}
void
@ -2162,7 +2164,9 @@ gdk_window_unmaximize (GdkWindow *window)
{
g_return_if_fail (GDK_IS_WINDOW (window));
/* g_warning ("gdk_window_unmaximize() not implemented.\n");*/
gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_MAXIMIZED,
0);
}
void

View File

@ -401,8 +401,8 @@ miComputeCircleSpans(int lw, miArc *parc, miArcSpanData *spdata)
register int x, y, e;
int xk, yk, xm, ym, dx, dy;
register int slw, inslw;
int inx, iny, ine;
int inxk, inyk, inxm, inym;
int inx = 0, iny, ine = 0;
int inxk = 0, inyk = 0, inxm = 0, inym = 0;
doinner = -lw;
slw = parc->width - doinner;
@ -464,7 +464,7 @@ miComputeEllipseSpans(int lw, miArc *parc, miArcSpanData *spdata)
register miArcSpan *span;
double w, h, r, xorg;
double Hs, Hf, WH, K, Vk, Nk, Fk, Vr, N, Nc, Z, rs;
double A, T, b, d, x, y, t, inx, outx, hepp, hepm;
double A, T, b, d, x, y, t, inx, outx = 0.0, hepp, hepm;
int flip, solution;
w = (double)parc->width / 2.0;
@ -986,8 +986,8 @@ miPolyArc(GdkDrawable *pDraw, GdkGC *pGC, int narcs, miArc *parcs)
register int i;
miArc *parc;
int xMin, xMax, yMin, yMax;
int pixmapWidth, pixmapHeight;
int xOrg, yOrg;
int pixmapWidth = 0, pixmapHeight = 0;
int xOrg = 0, yOrg = 0;
int width;
gboolean fTricky;
GdkDrawable* pDrawTo;
@ -1243,7 +1243,7 @@ miArcJoin (GdkDrawable *pDraw, GdkGC *pGC, miArcFacePtr pLeft, miArcFacePtr pRig
int cpt;
SppArcRec arc;
miArcFaceRec Right, Left;
int polyLen;
int polyLen = 0;
int xOrg, yOrg;
double xFtrans, yFtrans;
double a;
@ -1746,7 +1746,7 @@ computeDashMap (arcp, map)
dashMap *map;
{
int di;
double a, x, y, prevx, prevy, dist;
double a, x, y, prevx = 0.0, prevy = 0.0, dist;
for (di = 0; di < DASH_MAP_SIZE; di++) {
a = dashIndexToAngle (di);
@ -1773,7 +1773,7 @@ miComputeArcs (miArc *parcs, int narcs, GdkGC *pGC)
int isDashed, isDoubleDash;
int dashOffset;
miPolyArcPtr arcs;
int start, i, j, k, nexti, nextk;
int start, i, j, k = 0, nexti, nextk = 0;
int joinSize[2];
int capSize[2];
int arcSize[2];
@ -1782,13 +1782,13 @@ miComputeArcs (miArc *parcs, int narcs, GdkGC *pGC)
struct arcData *data;
miArcDataPtr arc;
miArc xarc;
int iphase, prevphase, joinphase;
int iphase, prevphase = 0, joinphase;
int arcsJoin;
int selfJoin;
int iDash, dashRemaining;
int iDashStart, dashRemainingStart, iphaseStart;
int startAngle, spanAngle, endAngle, backwards;
int iDash = 0, dashRemaining;
int iDashStart = 0, dashRemainingStart = 0, iphaseStart;
int startAngle, spanAngle, endAngle, backwards = 0;
int prevDashAngle, dashAngle;
dashMap map;
@ -2330,7 +2330,7 @@ drawZeroArc (pDraw, pGC, tarc, lw, left, right)
int lw;
miArcFacePtr right, left;
{
double x0, y0, x1, y1, w, h, x, y;
double x0 = 0.0, y0 = 0.0, x1 = 0.0, y1 = 0.0, w, h, x, y;
double xmax, ymax, xmin, ymin;
int a0, a1;
double a, startAngle, endAngle;
@ -3222,9 +3222,9 @@ drawArc (miArc *tarc, int l, int a0, int a1, miArcFacePtr right, miArcFacePtr le
struct arc_def def;
struct accelerators acc;
int startq, endq, curq;
int rightq, leftq, righta, lefta;
int rightq, leftq = 0, righta = 0, lefta = 0;
miArcFacePtr passRight, passLeft;
int q0, q1, mask;
int q0 = 0, q1 = 0, mask;
struct band {
int a0, a1;
int mask;

View File

@ -79,9 +79,9 @@ miFillSppPoly(GdkDrawable *dst, GdkGC *pgc, int count, SppPointPtr ptsIn, int xT
*/
#endif
{
double xl, xr, /* x vals of left and right edges */
ml, /* left edge slope */
mr, /* right edge slope */
double xl = 0.0, xr = 0.0, /* x vals of left and right edges */
ml = 0.0, /* left edge slope */
mr = 0.0, /* right edge slope */
dy, /* delta y */
i; /* loop counter */
int y, /* current scanline */

View File

@ -81,7 +81,7 @@ miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, overall_height,
int left_height = 0, right_height = 0;
register GdkSpan* ppt;
GdkSpan* pptInit;
GdkSpan* pptInit = NULL;
GdkColor oldPixel;
int xorg;
Spans spanRec;

View File

@ -406,13 +406,13 @@ miZeroClipLine(xmin, ymin, xmax, ymax,
{
int swapped = 0;
int clipDone = 0;
guint32 utmp;
guint32 utmp = 0;
int clip1, clip2;
int x1, y1, x2, y2;
int x1_orig, y1_orig, x2_orig, y2_orig;
int xmajor;
int negslope, anchorval;
unsigned int eqn;
int negslope = 0, anchorval = 0;
unsigned int eqn = 0;
x1 = x1_orig = *new_x1;
y1 = y1_orig = *new_y1;

View File

@ -92,13 +92,13 @@ miZeroLine(pDraw, pGC, mode, npt, pptInit)
int npt; /* number of points */
GdkPoint* pptInit;
{
int Nspans, current_y;
int Nspans, current_y = 0;
GdkPoint* ppt;
GdkSpan* pspanInit, *spans;
int list_len;
int xleft, ytop, xright, ybottom;
int new_x1, new_y1, new_x2, new_y2;
int x, y, x1, y1, x2, y2, xstart, ystart;
int x = 0, y = 0, x1, y1, x2, y2, xstart, ystart;
int oc1, oc2;
int result;
int pt1_clipped, pt2_clipped = 0;

View File

@ -36,6 +36,7 @@
typedef enum
{
GTK_WINDOW_REGION_TITLE,
GTK_WINDOW_REGION_MAXIMIZE,
GTK_WINDOW_REGION_CLOSE,
GTK_WINDOW_REGION_BR_RESIZE
} GtkWindowRegionType;
@ -68,6 +69,7 @@ struct _GtkWindowDecoration
GtkWindowRegion *regions;
gint last_x, last_y;
gint last_w, last_h;
PangoLayout *title_layout;
@ -75,6 +77,9 @@ struct _GtkWindowDecoration
gboolean moving : 1;
gboolean closing : 1;
gboolean maximizing : 1;
gboolean maximized : 1;
gboolean maximizable : 1;
gboolean decorated : 1;
gboolean real_inner_move : 1;
gboolean focused : 1;
@ -102,6 +107,8 @@ static gint gtk_decorated_window_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_decorated_window_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_decorated_window_window_state (GtkWidget *widget,
GdkEventWindowState *event);
static void gtk_decorated_window_paint (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_decorated_window_focus_change (GtkWidget *widget,
@ -133,6 +140,9 @@ gtk_decorated_window_init (GtkWindow *window)
deco->moving = FALSE;
deco->decorated = TRUE;
deco->closing = FALSE;
deco->maximizing = FALSE;
deco->maximized = FALSE;
deco->maximizable = FALSE;
deco->real_inner_move = FALSE;
g_object_set_data_full (G_OBJECT (window), "gtk-window-decoration", deco,
@ -189,12 +199,20 @@ gtk_decorated_window_calculate_frame_size (GtkWindow *window)
{
if ((decorations & GDK_DECOR_BORDER) &&
(decorations & GDK_DECOR_TITLE))
deco->decorated = TRUE;
{
deco->decorated = TRUE;
if ((decorations & GDK_DECOR_MAXIMIZE) &&
(gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL))
deco->maximizable = TRUE;
}
else
deco->decorated = FALSE;
}
else
deco->decorated = (window->type != GTK_WINDOW_POPUP);
{
deco->decorated = (window->type != GTK_WINDOW_POPUP);
deco->maximizable = (gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL);
}
if (deco->decorated)
gtk_window_set_frame_dimensions (window,
@ -312,6 +330,8 @@ gtk_decorated_window_frame_event (GtkWindow *window, GdkEvent *event)
break;
case GDK_BUTTON_RELEASE:
return gtk_decorated_window_button_release (widget, (GdkEventButton *)event);
case GDK_WINDOW_STATE:
return gtk_decorated_window_window_state (widget, (GdkEventWindowState *)event);
default:
break;
}
@ -441,22 +461,32 @@ gtk_decorated_window_button_press (GtkWidget *widget,
type = gtk_decorated_window_region_type (window, x, y);
deco->last_x = x;
deco->last_y = y;
switch (type)
{
case GTK_WINDOW_REGION_TITLE:
if (!deco->maximized && event->state & GDK_BUTTON1_MASK)
{
deco->last_x = x;
deco->last_y = y;
deco->moving = TRUE;
}
break;
case GTK_WINDOW_REGION_MAXIMIZE:
if (event->state & GDK_BUTTON1_MASK)
deco->moving = TRUE;
deco->maximizing = TRUE;
break;
case GTK_WINDOW_REGION_CLOSE:
if (event->state & GDK_BUTTON1_MASK)
deco->closing = TRUE;
break;
case GTK_WINDOW_REGION_BR_RESIZE:
if (event->state & GDK_BUTTON1_MASK)
deco->resize = RESIZE_BOTTOM_RIGHT;
if (!deco->maximized)
{
if (event->state & GDK_BUTTON1_MASK)
deco->resize = RESIZE_BOTTOM_RIGHT;
deco->last_x = x;
deco->last_y = y;
}
break;
default:
break;
@ -491,13 +521,67 @@ gtk_decorated_window_button_release (GtkWidget *widget,
gdk_event_free (event);
}
}
else if (deco->maximizing)
{
type = gtk_decorated_window_region_type (window, event->x, event->y);
if (type == GTK_WINDOW_REGION_MAXIMIZE)
{
if (deco->maximized)
gtk_window_unmaximize (window);
else
gtk_window_maximize (window);
}
}
deco->closing = FALSE;
deco->maximizing = FALSE;
deco->moving = FALSE;
deco->resize = RESIZE_NONE;
return TRUE;
}
static gint
gtk_decorated_window_window_state (GtkWidget *widget,
GdkEventWindowState *event)
{
GtkWindow *window;
GtkWindowDecoration *deco;
GdkWindowObject *priv;
window = GTK_WINDOW (widget);
deco = get_decoration (window);
priv = GDK_WINDOW_OBJECT (window->frame);
if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
{
if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
{
int w, h;
gdk_window_get_geometry (widget->window, NULL, NULL,
&deco->last_w, &deco->last_h, NULL);
gdk_window_get_origin (widget->window, &deco->last_x, &deco->last_y);
w = gdk_screen_get_width(gdk_screen_get_default()) - DECORATION_BORDER_TOT_X;
h = gdk_screen_get_height(gdk_screen_get_default()) - DECORATION_BORDER_TOT_Y;
_gtk_window_constrain_size (window, w, h, &w, &h);
if (w != deco->last_w || h != deco->last_h)
{
_gtk_window_reposition (window, DECORATION_BORDER_LEFT, DECORATION_BORDER_TOP);
gdk_window_resize (widget->window, w, h);
deco->maximized = TRUE;
}
}
else
{
_gtk_window_reposition (window, deco->last_x, deco->last_y);
_gtk_window_constrain_size (window, deco->last_w, deco->last_h,
&deco->last_w, &deco->last_h);
gdk_window_resize (widget->window, deco->last_w, deco->last_h);
deco->maximized = FALSE;
}
}
return TRUE;
}
static void
gtk_decorated_window_paint (GtkWidget *widget,
GdkRectangle *area)
@ -551,6 +635,31 @@ gtk_decorated_window_paint (GtkWidget *widget,
DECORATION_BORDER_LEFT - 2, DECORATION_BORDER_TOP - 2,
width - (DECORATION_BORDER_LEFT + DECORATION_BORDER_RIGHT) + 3,
height - (DECORATION_BORDER_TOP + DECORATION_BORDER_BOTTOM) + 3);
if (deco->maximizable)
{
/* Maximize button: */
x1 = width - (DECORATION_BORDER_LEFT * 2) - (DECORATION_BUTTON_SIZE * 2);
y1 = DECORATION_BUTTON_Y_OFFSET;
x2 = x1 + DECORATION_BUTTON_SIZE;
y2 = y1 + DECORATION_BUTTON_SIZE;
if (area)
gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], area);
gdk_draw_rectangle (frame, widget->style->bg_gc[widget->state], TRUE,
x1, y1, x2 - x1, y2 - y1);
gdk_draw_line (frame, widget->style->black_gc, x1 + 1, y1 + 1, x2 - 2, y1 + 1);
gdk_draw_rectangle (frame, widget->style->black_gc, FALSE,
x1 + 1, y1 + 2,
DECORATION_BUTTON_SIZE - 3, DECORATION_BUTTON_SIZE - 4);
if (area)
gdk_gc_set_clip_rectangle (widget->style->black_gc, NULL);
}
/* Close button: */
@ -584,14 +693,14 @@ gtk_decorated_window_paint (GtkWidget *widget,
if (deco->title_layout)
{
if (area)
gdk_gc_set_clip_rectangle (widget->style->fg_gc [widget->state], area);
gdk_gc_set_clip_rectangle (widget->style->fg_gc [border_state], area);
gdk_draw_layout (frame,
widget->style->fg_gc [widget->state],
widget->style->fg_gc [border_state],
DECORATION_BORDER_LEFT, 1,
deco->title_layout);
if (area)
gdk_gc_set_clip_rectangle (widget->style->fg_gc [widget->state], NULL);
gdk_gc_set_clip_rectangle (widget->style->fg_gc [border_state], NULL);
}
}
@ -612,6 +721,8 @@ gtk_decorated_window_recalculate_regions (GtkWindow *window)
return;
n_regions += 2; /* close, Title */
if (deco->maximizable)
n_regions += 1;
if (window->allow_shrink || window->allow_grow)
n_regions += 2;
@ -627,9 +738,20 @@ gtk_decorated_window_recalculate_regions (GtkWindow *window)
region = deco->regions;
/* Maximize button */
if (deco->maximizable)
{
region->rect.x = width - (DECORATION_BORDER_LEFT * 2) - (DECORATION_BUTTON_SIZE * 2);
region->rect.y = DECORATION_BUTTON_Y_OFFSET;
region->rect.width = DECORATION_BUTTON_SIZE;
region->rect.height = DECORATION_BUTTON_SIZE;
region->type = GTK_WINDOW_REGION_MAXIMIZE;
region++;
}
/* Close button */
region->rect.x = width - DECORATION_BORDER_LEFT - DECORATION_BUTTON_SIZE;
region->rect.y = 2;
region->rect.y = DECORATION_BUTTON_Y_OFFSET;
region->rect.width = DECORATION_BUTTON_SIZE;
region->rect.height = DECORATION_BUTTON_SIZE;
region->type = GTK_WINDOW_REGION_CLOSE;