do not print line numbers as they screw up dependency management

--- libasn1compiler/asn1c_C.c
+++ libasn1compiler/asn1c_C.c
@@ -7,7 +7,6 @@
 #include "asn1c_constraint.h"
 #include "asn1c_out.h"
 #include "asn1c_misc.h"
-#include "asn1c_compat.h"
 #include <asn1fix_export.h>	/* Stuff exported by libasn1fix */

 typedef struct tag2el_s {
@@ -1704,9 +1703,6 @@
 	int using_type_name = 0;
 	char *p;

-	OUT("/* %s defined in %s near line %d */\n",
-		MKID_nc(expr->Identifier),
-		a1c_basename(arg->mod->source_file_name), expr->_lineno);
 	if(HIDE_INNER_DEFS)
 		OUT("static /* Use -fall-defs-global to expose */\n");
 	OUT("asn_TYPE_descriptor_t asn_DEF_%s", MKID_nc(expr->Identifier));


fixed setting IPvX address family values

--- network.c
+++ network.c
@@ -47,6 +47,7 @@
 	}

 	memset(&addr, 0, sizeof(addr));
+	addr.sin_family = AF_INET;
 	addr.sin_addr.s_addr = INADDR_ANY;
 	addr.sin_port = htons(port);
 	if ((r = bind(s, (struct sockaddr *)&addr, sizeof(addr))) < 0) {
@@ -74,6 +75,7 @@
 	}

 	memset(&addr, 0, sizeof(addr));
+	addr.sin6_family = AF_INET6;
 	addr.sin6_addr = in6addr_any;
 	addr.sin6_port = htons(port);
 	if ((r = bind(s, (struct sockaddr *)&addr, sizeof(addr))) < 0) {


matroskadec: remove useless dummy_level variable

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@14565 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavformat/matroskadec.c
+++ libavformat/matroskadec.c
@@ -1346,7 +1346,6 @@
     uint32_t peek_id_cache = matroska->peek_id;
     uint32_t level_up = matroska->level_up;
     offset_t before_pos = url_ftell(matroska->ctx->pb);
-    int dummy_level = 0;
     MatroskaLevel level;
     uint32_t id;
     int i, res;
@@ -1375,7 +1374,6 @@
                         level.length = (uint64_t)-1;
                         matroska->levels[matroska->num_levels] = level;
                         matroska->num_levels++;
-                        dummy_level = 1;

                         /* check ID */
                         if (!(id = ebml_peek_id (matroska,
@@ -1410,7 +1408,6 @@

                     finish:
                         /* remove dummy level */
-                        if (dummy_level)
                             while (matroska->num_levels) {
                                 uint64_t length = matroska->levels[--matroska->num_levels].length;
                                 if (length == (uint64_t)-1)


fix invalid memory read problem in replicatespuReplicateWindows()

--- spu/replicate/replicatespu_redirect.c
+++ spu/replicate/replicatespu_redirect.c
@@ -179,6 +179,7 @@
 	Window root;
 	int x, y;
 	unsigned int width, height, bw, d;
+	GLboolean unviewable = GL_FALSE;
 	XWindowAttributes winAtt;

 	CRASSERT(ServerIndex >= 0);
@@ -193,6 +194,9 @@
 	XGetWindowAttributes(replicate_spu.glx_display,
 											 (Window) winInfo->nativeWindow, &winAtt);
 	XSetErrorHandler( old_xerror_handler );
+	if (!caught_x11_error) {
+		 unviewable = (winAtt.map_state == IsUnviewable);
+	}
 	caught_x11_error = 0;

 	/*
@@ -228,7 +232,7 @@
 	/*
 	 * If the app window is not visible, hide the server-side window too.
 	 */
-	if (winAtt.map_state == IsUnviewable)
+	if (unviewable)
 	{
 		if (replicate_spu.swap)
 			crPackWindowShowSWAP( window, GL_FALSE );


Get rid of useless braces

Get rid of useless braces

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@10382 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavformat/matroskaenc.c
+++ libavformat/matroskaenc.c
@@ -473,13 +473,12 @@
     url_open_dyn_buf(&dyn_cp);

     if (native_id) {
-        if (codec->codec_id == CODEC_ID_VORBIS || codec->codec_id == CODEC_ID_THEORA) {
+        if (codec->codec_id == CODEC_ID_VORBIS || codec->codec_id == CODEC_ID_THEORA)
             ret = put_xiph_codecpriv(&dyn_cp, codec);
-        } else if (codec->codec_id == CODEC_ID_FLAC) {
+        else if (codec->codec_id == CODEC_ID_FLAC)
             ret = put_flac_codecpriv(&dyn_cp, codec);
-        } else if (codec->extradata_size) {
+        else if (codec->extradata_size)
             put_buffer(&dyn_cp, codec->extradata, codec->extradata_size);
-        }
     } else if (codec->codec_type == CODEC_TYPE_VIDEO) {
         if (!codec->codec_tag)
             codec->codec_tag = codec_get_tag(codec_bmp_tags, codec->codec_id);
@@ -558,10 +557,10 @@
             case CODEC_TYPE_VIDEO:
                 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);

-                if (!native_id) {
+                if (!native_id)
                     // if there is no mkv-specific codec id, use VFW mode
                     put_ebml_string(pb, MATROSKA_ID_CODECID, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
-                }
+
                 subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0);
                 // XXX: interlace flag?
                 put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
@@ -578,10 +577,10 @@
             case CODEC_TYPE_AUDIO:
                 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_AUDIO);

-                if (!native_id) {
+                if (!native_id)
                     // no mkv-specific ID, use ACM mode
                     put_ebml_string(pb, MATROSKA_ID_CODECID, MATROSKA_CODEC_ID_AUDIO_ACM);
-                }
+
                 subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
                 put_ebml_uint  (pb, MATROSKA_ID_AUDIOCHANNELS    , codec->channels);
                 put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate);


experimental: Use full namespace on Phonon::GlobalConfig in Experimental::GlobalConfig

It seems some compilers (e.g. the one used on Solaris/Sun Studio 12 U1) need this to compile cleanly.

CCBUG: 216158

--- phonon/experimental/globalconfig.h
+++ phonon/experimental/globalconfig.h
@@ -39,7 +39,7 @@

 class GlobalConfig : public Phonon::GlobalConfig
 {
-    K_DECLARE_PRIVATE(GlobalConfig)
+    K_DECLARE_PRIVATE(Phonon::GlobalConfig)
 public:
     QList<int> videoCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
     int videoCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;


gtkstyle: add a gtkstyle-fallback style class for RC colors

As an addition to 10423726709539724be0ea19bed76ba4331af774, themes might
want to avoid using the hardcoded GTK defaults for legacy GtkStyle
values. Add a gtkstyle-fallback style class that can be used by themes
to tweak the legacy GtkStyle defaults.

https://bugzilla.gnome.org/show_bug.cgi?id=679092

--- gtk/deprecated/gtkstyle.c
+++ gtk/deprecated/gtkstyle.c
@@ -617,6 +617,56 @@
     }
 }

+static gboolean
+set_color_from_context (GtkStyle *style,
+                        GtkStateType state,
+                        GtkStyleContext *context,
+                        GtkStateFlags flags,
+                        GtkRcFlags prop)
+{
+  GdkRGBA *color = NULL;
+  GdkColor *dest = { 0 }; /* Shut up gcc */
+
+  switch (prop)
+    {
+    case GTK_RC_BG:
+      gtk_style_context_get (context, flags,
+                             "background-color", &color,
+                             NULL);
+      dest = &style->bg[state];
+      break;
+    case GTK_RC_FG:
+      gtk_style_context_get (context, flags,
+                             "color", &color,
+                             NULL);
+      dest = &style->fg[state];
+      break;
+    case GTK_RC_TEXT:
+      gtk_style_context_get (context, flags,
+                             "color", &color,
+                             NULL);
+      dest = &style->text[state];
+      break;
+    case GTK_RC_BASE:
+      gtk_style_context_get (context, flags,
+                             "background-color", &color,
+                             NULL);
+      dest = &style->base[state];
+      break;
+    }
+
+  if (!color || !(color->alpha > 0.01))
+    return FALSE;
+
+  dest->pixel = 0;
+  dest->red = CLAMP ((guint) (color->red * 65535), 0, 65535);
+  dest->green = CLAMP ((guint) (color->green * 65535), 0, 65535);
+  dest->blue = CLAMP ((guint) (color->blue * 65535), 0, 65535);
+  gdk_rgba_free (color);
+
+  return TRUE;
+}
+
 static void
 set_color (GtkStyle        *style,
            GtkStyleContext *context,
@@ -624,8 +674,6 @@
            GtkRcFlags       prop)
 {
   GtkStateFlags flags;
-  GdkRGBA *color = NULL;
-  GdkColor *dest = { 0 }; /* Shut up gcc */

   switch (state)
     {
@@ -645,41 +693,19 @@
       flags = 0;
     }

-  switch (prop)
-    {
-    case GTK_RC_BG:
-      gtk_style_context_get (context, flags,
-                             "background-color", &color,
-                             NULL);
-      dest = &style->bg[state];
-      break;
-    case GTK_RC_FG:
-      gtk_style_context_get (context, flags,
-                             "color", &color,
-                             NULL);
-      dest = &style->fg[state];
-      break;
-    case GTK_RC_TEXT:
-      gtk_style_context_get (context, flags,
-                             "color", &color,
-                             NULL);
-      dest = &style->text[state];
-      break;
-    case GTK_RC_BASE:
-      gtk_style_context_get (context, flags,
-                             "background-color", &color,
-                             NULL);
-      dest = &style->base[state];
-      break;
-    }
-
-  if (color && color->alpha > 0.01)
-    {
-      dest->pixel = 0;
-      dest->red = CLAMP ((guint) (color->red * 65535), 0, 65535);
-      dest->green = CLAMP ((guint) (color->green * 65535), 0, 65535);
-      dest->blue = CLAMP ((guint) (color->blue * 65535), 0, 65535);
-      gdk_rgba_free (color);
+  /* Try to fill in the values from the associated GtkStyleContext.
+   * Since fully-transparent black is a very common default (e.g. for
+   * background-color properties), and we must store the result in a GdkColor
+   * to retain API compatibility, in case the fetched color is fully transparent
+   * we give themes a fallback style class they can style, before using the
+   * hardcoded default values.
+   */
+  if (!set_color_from_context (style, state, context, flags, prop))
+    {
+      gtk_style_context_save (context);
+      gtk_style_context_add_class (context, "gtkstyle-fallback");
+      set_color_from_context (style, state, context, flags, prop);
+      gtk_style_context_restore (context);
     }
 }


isl: Add missing break statement in array pitch calculation

Fixes regression in ed98c374bd3f1952fbab3031afaf5ff4d178ef41.

--- src/isl/isl.c
+++ src/isl/isl.c
@@ -734,6 +734,7 @@
       switch (array_pitch_span) {
       case ISL_ARRAY_PITCH_SPAN_COMPACT:
          pitch_sa_rows = isl_align_npot(phys_slice0_sa->h, image_align_sa->h);
+         break;
       case ISL_ARRAY_PITCH_SPAN_FULL: {
          /* The QPitch equation is found in the Broadwell PRM >> Volume 5:
           * Memory Views >> Common Surface Formats >> Surface Layout >> 2D


Use GDBus for fetch_email_body call

Use GDBus for fetch_email_body call

--- libeasclient/libeasmail.c
+++ libeasclient/libeasmail.c
@@ -1262,11 +1262,7 @@
 				   GCancellable *cancellable,
 				   GError **error)
 {
-	gboolean ret = TRUE;
-	EasEmailHandlerPrivate *priv;
-	guint request_id;
-	DBusGProxyCall *call;
-	guint cancel_handler_id;
+	gboolean ret = FALSE;

 	g_debug ("eas_mail_handler_fetch_email_body++");

@@ -1275,72 +1271,16 @@
 			     EAS_MAIL_ERROR,
 			     EAS_MAIL_ERROR_BADARG,
 			     "eas_mail_handler_fetch_email_body requires valid arguments");
-		ret = FALSE;
 		goto out;
 	}

-	g_assert (self);
-	g_assert (folder_id);
-	g_assert (server_id);
-	g_assert (mime_directory);
-
-	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-	priv = self->priv;
-	// if there's a progress function supplied, add it (and the progress_data) to the hashtable, indexed by id
-	request_id = priv->next_request_id++;
-
-	if (progress_fn) {
-		ret = eas_mail_add_progress_info_to_table (self, request_id, progress_fn, progress_data, error);
-		if (!ret)
-			goto finish;
-	}
-
-	if (cancellable) {
-		EasCancelInfo *cancel_info = g_new0 (EasCancelInfo, 1);	// freed on disconnect
-
-		cancel_info->handler = self;
-		cancel_info->request_id = request_id;
-		// connect to the "cancelled" signal
-		g_debug ("connect to cancellable");
-		cancel_handler_id = g_cancellable_connect (cancellable,
-							   G_CALLBACK (eas_mail_handler_cancel_mail_request),
-							   (gpointer) cancel_info,
-							   g_free);				// data destroy func
-	}
-
-	call = dbus_g_proxy_begin_call (priv->remoteEas,
-					"fetch_email_body",
-					dbus_call_completed,
-					NULL, 							// userdata passed to callback
-					NULL, 							// destroy notification
-					G_TYPE_STRING, priv->account_uid,
-					G_TYPE_STRING, folder_id,
-					G_TYPE_STRING, server_id,
-					G_TYPE_STRING, mime_directory,
-					G_TYPE_UINT, request_id,
-					G_TYPE_INVALID);
-
-	g_debug ("block until results available");
-	// blocks until results are available:
-	ret = dbus_g_proxy_end_call (priv->remoteEas,
-				     call,
-				     error,
-				     G_TYPE_INVALID);
-
-	if (cancellable) {
-		// disconnect from cancellable
-		g_debug ("disconnect from cancellable");
-		g_cancellable_disconnect (cancellable, cancel_handler_id);
-	}
-
-finish:
-	g_hash_table_remove (priv->email_progress_fns_table,
-			     GUINT_TO_POINTER (request_id));
+	ret = eas_gdbus_mail_call (self, "fetch_email_body",
+				   progress_fn, progress_data,
+				   "(ssssu)", NULL,
+				   cancellable, error,
+				   self->priv->account_uid, folder_id,
+				   server_id, mime_directory, 0);
 out:
-	if (!ret) {
-		g_assert (error == NULL || *error != NULL);
-	}
 	g_debug ("eas_mail_handler_fetch_email_body--");
 	return ret;
 }


Squashed 'nk_pugl/' changes from d4e9daf..2a37459

2a37459 increase font oversampling.
279c529 always render, but only convert upon changes.
adeaf2a add NK_PUGL_ALWAYS_RENDER preprocessor switch.
524cc81 DPI and dynamic scaling with Ctrl +/- and wheel.
95069b8 add NK_PUGL_API preprocessor constant.
5656cbf implement clipboard, fix osx shortcuts.
eed4cf4 fix key handling, add function to detect shortcuts.
977a816 force RGBA format in stbi_load.
e9bcb3b add min_width/height to config.
bcd82b8 fixes to work with missing key release events.
319a94c add missing static attribute.
181f85d imporove/fix last commit.
a4d9f48 fix refresh upon focus change.
aff82e0 fix cntrl + enter concurrency bug.
62d7223 fix utf8 characters.
a7d5527 win: fix event input and render.
5f2b08f fix keyboard shortcuts, again.
956ede3 fix last commit.
74ec6c5 suppress control escaped keys.
8f6b446 add fallback for GenerateMipMap for GL >= 1.4.

git-subtree-dir: nk_pugl
git-subtree-split: 2a3745976638e1a37321500428e368d7d92b0065

--- nk_pugl.h
+++ nk_pugl.h
@@ -19,6 +19,7 @@
 #define _NK_PUGL_H

 #include <stdatomic.h>
+#include <ctype.h> // isalpha

 #ifdef __cplusplus
 extern C {
@@ -53,6 +54,10 @@
 #include "nuklear/nuklear.h"
 #include "nuklear/example/stb_image.h"

+#ifndef NK_PUGL_API
+#	define NK_PUGL_API static
+#endif
+
 typedef struct _nk_pugl_config_t nk_pugl_config_t;
 typedef struct _nk_pugl_window_t nk_pugl_window_t;
 typedef void (*nkglGenerateMipmap)(GLenum target);
@@ -62,18 +67,23 @@
 struct _nk_pugl_config_t {
 	unsigned width;
 	unsigned height;
+	unsigned min_width;
+	unsigned min_height;

 	bool resizable;
+	bool fixed_aspect;
 	bool ignore;
 	const char *class;
 	const char *title;

 	struct {
-		const char *face;
+		char *face;
 		int size;
 	} font;

 	intptr_t parent;
+
+	LV2UI_Resize *host_resize;

 	void *data;
 	nk_pugl_expose_t expose;
@@ -81,12 +91,14 @@

 struct _nk_pugl_window_t {
 	nk_pugl_config_t cfg;
+	float scale;

 	PuglView *view;
 	int quit;
-	bool input_active;

 	struct nk_buffer cmds;
+	struct nk_buffer vbuf;
+	struct nk_buffer ebuf;
 	struct nk_draw_null_texture null;
 	struct nk_context ctx;
 	struct nk_font_atlas atlas;
@@ -95,49 +107,64 @@
 		void *buffer;
 		size_t size;
 	} last;
+	bool has_left;
+	bool has_entered;

 	GLuint font_tex;
 	nkglGenerateMipmap glGenerateMipmap;

 	intptr_t widget;
+	PuglMod state;
 #if !defined(__APPLE__) && !defined(_WIN32)
 	atomic_flag async;
 	Display *disp;
 #endif
 };

-static inline intptr_t
+NK_PUGL_API intptr_t
 nk_pugl_init(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_show(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_hide(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_shutdown(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_wait_for_event(nk_pugl_window_t *win);

-static inline int
+NK_PUGL_API int
 nk_pugl_process_events(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_post_redisplay(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_async_redisplay(nk_pugl_window_t *win);

-static inline void
+NK_PUGL_API void
 nk_pugl_quit(nk_pugl_window_t *win);

-static struct nk_image
+NK_PUGL_API struct nk_image
 nk_pugl_icon_load(nk_pugl_window_t *win, const char *filename);

-static void
+NK_PUGL_API void
 nk_pugl_icon_unload(nk_pugl_window_t *win, struct nk_image img);
+
+NK_PUGL_API bool
+nk_pugl_is_shortcut_pressed(struct nk_input *in, char letter, bool clear);
+
+NK_PUGL_API void
+nk_pugl_copy_to_clipboard(nk_pugl_window_t *win, const char *selection, size_t len);
+
+NK_PUGL_API const char *
+nk_pugl_paste_from_clipboard(nk_pugl_window_t *win, size_t *len);
+
+NK_PUGL_API float
+nk_pugl_get_scale(nk_pugl_window_t *win);

 #ifdef __cplusplus
 }
@@ -186,9 +213,8 @@

 #if defined(__APPLE__)
 #	define GL_EXT(name) name
-#endif
-
-#if defined(_WIN32)
+
+#elif defined(_WIN32)
 static void *
 _nk_pugl_gl_ext(const char *name)
 {
@@ -207,9 +233,8 @@
   return p;
 }
 #	define GL_EXT(name) (nk##name)_nk_pugl_gl_ext(#name)
-#endif
-
-#if !defined(__APPLE__) && !defined(_WIN32)
+
+#else
 static void *
 _nk_pugl_gl_ext(const char *name)
 {
@@ -291,104 +316,194 @@
 _nk_pugl_render_gl2(nk_pugl_window_t *win)
 {
 	nk_pugl_config_t *cfg = &win->cfg;
+	bool has_changes = win->has_left || win->has_entered;

 	// compare current command buffer with last one to defer any changes
-	bool has_changes = false;
-	const size_t size = win->ctx.memory.allocated;
-	const void *commands = nk_buffer_memory_const(&win->ctx.memory);
-
-	if( (size != win->last.size) || memcmp(commands, win->last.buffer, size))
-	{
-		// swap last buffer with current one for next comparison
-		win->last.buffer = realloc(win->last.buffer, size);
-		if(win->last.buffer)
-		{
-			win->last.size = size;
-			memcpy(win->last.buffer, commands, size);
-		}
-		else
-		{
-			win->last.size = 0;
-		}
-		has_changes = true;
-	}
-
-	// only render if there were actually any changes
+	if(!has_changes)
+	{
+		const size_t size = win->ctx.memory.allocated;
+		const void *commands = nk_buffer_memory_const(&win->ctx.memory);
+
+		if( (size != win->last.size) || memcmp(commands, win->last.buffer, size) )
+		{
+			// swap last buffer with current one for next comparison
+			win->last.buffer = realloc(win->last.buffer, size);
+			if(win->last.buffer)
+			{
+				win->last.size = size;
+				memcpy(win->last.buffer, commands, size);
+			}
+			else
+			{
+				win->last.size = 0;
+			}
+			has_changes = true;
+		}
+	}
+
 	if(has_changes)
 	{
-		// convert shapes into vertexes
-		struct nk_buffer vbuf, ebuf;
-		nk_buffer_init_default(&vbuf);
-		nk_buffer_init_default(&ebuf);
-		nk_convert(&win->ctx, &win->cmds, &vbuf, &ebuf, &win->conv);
-
-		_nk_pugl_render_gl2_push(cfg->width, cfg->height);
-
-		// setup vertex buffer pointers
-		const GLsizei vs = sizeof(nk_pugl_vertex_t);
-		const size_t vp = offsetof(nk_pugl_vertex_t, position);
-		const size_t vt = offsetof(nk_pugl_vertex_t, uv);
-		const size_t vc = offsetof(nk_pugl_vertex_t, col);
-		const nk_byte *vertices = nk_buffer_memory_const(&vbuf);
-		glVertexPointer(2, GL_FLOAT, vs, &vertices[vp]);
-		glTexCoordPointer(2, GL_FLOAT, vs, &vertices[vt]);
-		glColorPointer(4, GL_UNSIGNED_BYTE, vs, &vertices[vc]);
-
-		// iterate over and execute each draw command
-		const nk_draw_index *offset = nk_buffer_memory_const(&ebuf);
-		const struct nk_draw_command *cmd;
-		nk_draw_foreach(cmd, &win->ctx, &win->cmds)
-		{
-			if(!cmd->elem_count)
-				continue;
-
-			glBindTexture(GL_TEXTURE_2D, cmd->texture.id);
-			glScissor(
-				cmd->clip_rect.x,
-				cfg->height - (cmd->clip_rect.y + cmd->clip_rect.h),
-				cmd->clip_rect.w,
-				cmd->clip_rect.h);
-			glDrawElements(GL_TRIANGLES, cmd->elem_count, GL_UNSIGNED_SHORT, offset);
-
-			offset += cmd->elem_count;
-		}
-
-		_nk_pugl_render_gl2_pop();
-
-		nk_buffer_free(&vbuf);
-		nk_buffer_free(&ebuf);
-	}
+		// clear command/vertex buffers of last stable view
+		nk_buffer_clear(&win->cmds);
+		nk_buffer_clear(&win->vbuf);
+		nk_buffer_clear(&win->ebuf);
+		nk_draw_list_clear(&win->ctx.draw_list);
+
+		// convert shapes into vertexes if there were changes
+		nk_convert(&win->ctx, &win->cmds, &win->vbuf, &win->ebuf, &win->conv);
+	}
+
+	_nk_pugl_render_gl2_push(cfg->width, cfg->height);
+
+	// setup vertex buffer pointers
+	const GLsizei vs = sizeof(nk_pugl_vertex_t);
+	const size_t vp = offsetof(nk_pugl_vertex_t, position);
+	const size_t vt = offsetof(nk_pugl_vertex_t, uv);
+	const size_t vc = offsetof(nk_pugl_vertex_t, col);
+	const nk_byte *vertices = nk_buffer_memory_const(&win->vbuf);
+	glVertexPointer(2, GL_FLOAT, vs, &vertices[vp]);
+	glTexCoordPointer(2, GL_FLOAT, vs, &vertices[vt]);
+	glColorPointer(4, GL_UNSIGNED_BYTE, vs, &vertices[vc]);
+
+	// iterate over and execute each draw command
+	const nk_draw_index *offset = nk_buffer_memory_const(&win->ebuf);
+	const struct nk_draw_command *cmd;
+	nk_draw_foreach(cmd, &win->ctx, &win->cmds)
+	{
+		if(!cmd->elem_count)
+			continue;
+
+		glBindTexture(GL_TEXTURE_2D, cmd->texture.id);
+		glScissor(
+			cmd->clip_rect.x,
+			cfg->height - (cmd->clip_rect.y + cmd->clip_rect.h),
+			cmd->clip_rect.w,
+			cmd->clip_rect.h);
+		glDrawElements(GL_TRIANGLES, cmd->elem_count, GL_UNSIGNED_SHORT, offset);
+
+		offset += cmd->elem_count;
+	}
+
+	_nk_pugl_render_gl2_pop();
+
+	win->has_entered = false;

 	nk_clear(&win->ctx);
 }

-static inline void
-_nk_pugl_font_stash_begin(nk_pugl_window_t *win)
-{
+static void
+_nk_pugl_font_init(nk_pugl_window_t *win)
+{
+	nk_pugl_config_t *cfg = &win->cfg;
+
+	const int font_size = cfg->font.size * win->scale;
+
+	// init nuklear font
+	struct nk_font *ttf = NULL;
+	struct nk_font_config fcfg = nk_font_config(font_size);
+	static const nk_rune range [] = {
+		0x0020, 0x007F, // Basic Latin
+		0x00A0, 0x00FF, // Latin-1 Supplement
+		0x0100, 0x017F, // Latin Extended-A
+		0x0180, 0x024F, // Latin Extended-B
+		0x0300, 0x036F, // Combining Diacritical Marks
+		0x0370, 0x03FF, // Greek and Coptic
+		0x0400, 0x04FF, // Cyrillic
+		0x0500, 0x052F, // Cyrillic Supplementary
+		0
+	};
+	fcfg.range = range;
+	fcfg.oversample_h = 8;
+	fcfg.oversample_v = 8;
+
 	struct nk_font_atlas *atlas = &win->atlas;
-
 	nk_font_atlas_init_default(atlas);
 	nk_font_atlas_begin(atlas);
-}
-
-static inline void
-_nk_pugl_font_stash_end(nk_pugl_window_t *win)
-{
-	struct nk_font_atlas *atlas = &win->atlas;
+
+	if(cfg->font.face && font_size)
+		ttf = nk_font_atlas_add_from_file(&win->atlas, cfg->font.face, font_size, &fcfg);
+
 	int w = 0;
 	int h = 0;
-
+	struct nk_draw_null_texture null;
 	const void *image = nk_font_atlas_bake(atlas, &w, &h, NK_FONT_ATLAS_RGBA32);
 	_nk_pugl_device_upload_atlas(win, image, w, h);
-	nk_font_atlas_end(atlas, nk_handle_id(win->font_tex), &win->null);
+	nk_font_atlas_end(atlas, nk_handle_id(win->font_tex), &null);

 	if(atlas->default_font)
 		nk_style_set_font(&win->ctx, &atlas->default_font->handle);
+
+	if(ttf)
+		nk_style_set_font(&win->ctx, &ttf->handle);
 }

 static void
-_nk_pugl_special_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
-{
+_nk_pugl_font_deinit(nk_pugl_window_t *win)
+{
+	nk_font_atlas_clear(&win->atlas);
+
+	if(win->font_tex)
+		glDeleteTextures(1, (const GLuint *)&win->font_tex);
+}
+
+static void
+_nk_pugl_resize(nk_pugl_window_t *win)
+{
+	nk_pugl_config_t *cfg = &win->cfg;
+
+	if(cfg->host_resize)
+	{
+		cfg->host_resize->ui_resize(cfg->host_resize->handle,
+			cfg->width*win->scale, cfg->height*win->scale);
+	}
+}
+
+static void
+_nk_pugl_reconfigure(nk_pugl_window_t *win)
+{
+	puglEnterContext(win->view);
+	{
+		_nk_pugl_font_deinit(win);
+		_nk_pugl_font_init(win);
+	}
+	puglLeaveContext(win->view, false);
+
+#if 0
+	if(!win->cfg->resizable)
+		_nk_pugl_resize(win);
+#endif
+}
+
+static void
+_nk_pugl_zoom_in(nk_pugl_window_t *win)
+{
+	win->scale += 0.1;
+
+	_nk_pugl_reconfigure(win);
+}
+
+static void
+_nk_pugl_zoom_out(nk_pugl_window_t *win)
+{
+	if(win->scale >= 0.6)
+	{
+		win->scale -= 0.1;
+
+		_nk_pugl_reconfigure(win);
+	}
+}
+
+static void
+_nk_pugl_key_press(struct nk_context *ctx, enum nk_keys key)
+{
+	nk_input_key(ctx, key, nk_true);
+	nk_input_key(ctx, key, nk_false);
+}
+
+static bool
+_nk_pugl_special_key_down(nk_pugl_window_t *win, const PuglEventKey *ev)
+{
+	struct nk_context *ctx = &win->ctx;
 	const bool control = ev->state & PUGL_MOD_CTRL;

 	switch(ev->special)
@@ -411,150 +526,285 @@
 		case PUGL_KEY_LEFT:
 		{
 			if(control)
-				nk_input_key(ctx, NK_KEY_TEXT_WORD_LEFT, down);
+				_nk_pugl_key_press(ctx, NK_KEY_TEXT_WORD_LEFT);
 			else
-				nk_input_key(ctx, NK_KEY_LEFT, down);
+				_nk_pugl_key_press(ctx, NK_KEY_LEFT);
 		}	break;
 		case PUGL_KEY_RIGHT:
 		{
 			if(control)
-				nk_input_key(ctx, NK_KEY_TEXT_WORD_RIGHT, down);
+				_nk_pugl_key_press(ctx, NK_KEY_TEXT_WORD_RIGHT);
 			else
-				nk_input_key(ctx, NK_KEY_RIGHT, down);
+				_nk_pugl_key_press(ctx, NK_KEY_RIGHT);
 		}	break;
 		case PUGL_KEY_UP:
 		{
-			nk_input_key(ctx, NK_KEY_UP, down);
+			_nk_pugl_key_press(ctx, NK_KEY_UP);
 		}	break;
 		case PUGL_KEY_DOWN:
 		{
-			nk_input_key(ctx, NK_KEY_DOWN, down);
+			_nk_pugl_key_press(ctx, NK_KEY_DOWN);
 		}	break;
 		case PUGL_KEY_PAGE_UP:
 		{
-			nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
+			_nk_pugl_key_press(ctx, NK_KEY_SCROLL_UP);
 		}	break;
 		case PUGL_KEY_PAGE_DOWN:
 		{
-			nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
+			_nk_pugl_key_press(ctx, NK_KEY_SCROLL_DOWN);
 		}	break;
 		case PUGL_KEY_HOME:
 		{
-			nk_input_key(ctx, NK_KEY_TEXT_START, down);
-			nk_input_key(ctx, NK_KEY_SCROLL_START, down);
+			if(control)
+			{
+				_nk_pugl_key_press(ctx, NK_KEY_TEXT_START);
+				_nk_pugl_key_press(ctx, NK_KEY_SCROLL_START);
+			}
+			else
+			{
+				_nk_pugl_key_press(ctx, NK_KEY_TEXT_LINE_START);
+			}
 		}	break;
 		case PUGL_KEY_END:
 		{
-			nk_input_key(ctx, NK_KEY_TEXT_END, down);
-			nk_input_key(ctx, NK_KEY_SCROLL_END, down);
+			if(control)
+			{
+				_nk_pugl_key_press(ctx, NK_KEY_TEXT_END);
+				_nk_pugl_key_press(ctx, NK_KEY_SCROLL_END);
+			}
+			else
+			{
+				_nk_pugl_key_press(ctx, NK_KEY_TEXT_LINE_END);
+			}
+		}	break;
+		case PUGL_KEY_INSERT:
+		{
+			_nk_pugl_key_press(ctx, NK_KEY_TEXT_INSERT_MODE);
 		}	break;
 		case PUGL_KEY_SHIFT:
 		{
-			nk_input_key(ctx, NK_KEY_SHIFT, down);
-		}	break;
+			win->state |= PUGL_MOD_SHIFT;
+			nk_input_key(ctx, NK_KEY_SHIFT, nk_true);
+		}	return true;
 		case PUGL_KEY_CTRL:
 		{
-			nk_input_key(ctx, NK_KEY_CTRL, down);
-		}	break;
+			win->state |= PUGL_MOD_CTRL;
+			nk_input_key(ctx, NK_KEY_CTRL, nk_true);
+		}	return true;
+		case PUGL_KEY_ALT:
+		{
+			// TODO
+		}	break;
+		case PUGL_KEY_SUPER:
+		{
+			// TODO
+		}	break;
+	}
+
+	return false;
+}
+
+static bool
+_nk_pugl_special_key_up(nk_pugl_window_t *win, const PuglEventKey *ev)
+{
+	struct nk_context *ctx = &win->ctx;
+
+	switch(ev->special)
+	{
+		case PUGL_KEY_F1:
+		case PUGL_KEY_F2:
+		case PUGL_KEY_F3:
+		case PUGL_KEY_F4:
+		case PUGL_KEY_F5:
+		case PUGL_KEY_F6:
+		case PUGL_KEY_F7:
+		case PUGL_KEY_F8:
+		case PUGL_KEY_F9:
+		case PUGL_KEY_F10:
+		case PUGL_KEY_F11:
+		case PUGL_KEY_F12:
+		case PUGL_KEY_LEFT:
+		case PUGL_KEY_RIGHT:
+		case PUGL_KEY_UP:
+		case PUGL_KEY_DOWN:
+		case PUGL_KEY_PAGE_UP:
+		case PUGL_KEY_PAGE_DOWN:
+		case PUGL_KEY_HOME:
+		case PUGL_KEY_END:
 		case PUGL_KEY_INSERT:
 		{
-			//TODO
-		}	break;
+			// ignore
+		}	break;
+		case PUGL_KEY_SHIFT:
+		{
+			nk_input_key(ctx, NK_KEY_SHIFT, nk_false);
+			win->state &= ~PUGL_MOD_SHIFT;
+		}	return true;
+		case PUGL_KEY_CTRL:
+		{
+			nk_input_key(ctx, NK_KEY_CTRL, nk_false);
+			win->state &= ~PUGL_MOD_CTRL;
+		}	return true;
 		case PUGL_KEY_ALT:
 		{
-			//TODO
+			// TODO
 		}	break;
 		case PUGL_KEY_SUPER:
 		{
-			//TODO
-		}	break;
-	}
+			// TODO
+		}	break;
+	}
+
+	return false;
+}
+
+static bool
+_nk_pugl_other_key_down(nk_pugl_window_t *win, const PuglEventKey *ev)
+{
+	struct nk_context *ctx = &win->ctx;
+#if defined(__APPLE__)
+	const bool modifier = ev->state & PUGL_MOD_SUPER;
+#else
+	const bool modifier = ev->state & PUGL_MOD_CTRL;
+#endif
+	const bool shift = ev->state & PUGL_MOD_SHIFT;
+
+	// automatically enter insert mode upon non-special key press
+	_nk_pugl_key_press(ctx, NK_KEY_TEXT_INSERT_MODE);
+
+	switch(ev->character)
+	{
+		case '\n':
+		case '\r':
+		{
+			_nk_pugl_key_press(ctx, NK_KEY_ENTER);
+		}	break;
+		case '\t':
+		{
+			_nk_pugl_key_press(ctx, NK_KEY_TAB);
+		}	break;
+		case PUGL_CHAR_DELETE:
+		{
+#if defined(__APPLE__) // quirk around Apple's Delete key strangeness
+			_nk_pugl_key_press(ctx, NK_KEY_BACKSPACE);
+#else
+			_nk_pugl_key_press(ctx, NK_KEY_DEL);
+#endif
+		}	break;
+		case PUGL_CHAR_BACKSPACE:
+		{
+#if defined(__APPLE__) // quirk around Apple's Delete key strangeness
+			_nk_pugl_key_press(ctx, NK_KEY_DEL);
+#else
+			_nk_pugl_key_press(ctx, NK_KEY_BACKSPACE);
+#endif
+		}	break;
+		case PUGL_CHAR_ESCAPE:
+		{
+			_nk_pugl_key_press(ctx, NK_KEY_TEXT_RESET_MODE);
+		} break;
+
+		default:
+		{
+			if(modifier)
+			{
+				if(ev->character == '+')
+				{
+					_nk_pugl_zoom_in(win);
+					break;
+				}
+				else if(ev->character == '-')
+				{
+					_nk_pugl_zoom_out(win);
+					break;
+				}
+
+				// unescape ASCII control chars + Control
+				const uint32_t character = ev->character | 0x60;
+
+				switch(character)
+				{
+					case 'c':
+					{
+						_nk_pugl_key_press(ctx, NK_KEY_COPY);
+					}	break;
+					case 'v':
+					{
+						_nk_pugl_key_press(ctx, NK_KEY_PASTE);
+					}	break;
+					case 'x':
+					{
+						_nk_pugl_key_press(ctx, NK_KEY_CUT);
+					}	break;
+					case 'z':
+					{
+						if(shift)
+							_nk_pugl_key_press(ctx, NK_KEY_TEXT_REDO);
+						else
+							_nk_pugl_key_press(ctx, NK_KEY_TEXT_UNDO);
+					}	break;
+
+					default:
+					{
+						nk_input_glyph(ctx, (const char *)ev->utf8);
+					} break;
+				}
+			}
+			else
+			{
+				nk_input_glyph(ctx, (const char *)ev->utf8);
+			}
+		} break;
+	}
+
+	return false;
 }

 static void
-_nk_pugl_other_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
-{
-	const bool control = ev->state & PUGL_MOD_CTRL;
-
-	if(control)
-	{
-		switch(ev->character + 96) //FIXME why +96?
-		{
-			case 'c':
-			{
-				nk_input_key(ctx, NK_KEY_COPY, down);
-			}	break;
-			case 'v':
-			{
-				nk_input_key(ctx, NK_KEY_PASTE, down);
-			}	break;
-			case 'x':
-			{
-				nk_input_key(ctx, NK_KEY_CUT, down);
-			}	break;
-			case 'z':
-			{
-				nk_input_key(ctx, NK_KEY_TEXT_UNDO, down);
-			}	break;
-			case 'r':
-			{
-				nk_input_key(ctx, NK_KEY_TEXT_REDO, down);
-			}	break;
-			case 'b':
-			{
-				nk_input_key(ctx, NK_KEY_TEXT_LINE_START, down);
-			}	break;
-			case 'e':
-			{
-				nk_input_key(ctx, NK_KEY_TEXT_LINE_END, down);
-			}	break;
-		}
-
-		if(down)
-			nk_input_char(ctx, ev->character + 96);
-	}
-	else // !control
-	{
-		switch(ev->character)
-		{
-			case '\r':
-			{
-				nk_input_key(ctx, NK_KEY_ENTER, down);
-			}	break;
-			case '\t':
-			{
-				nk_input_key(ctx, NK_KEY_TAB, down);
-			}	break;
-			case 127: // Delete
-			{
-				nk_input_key(ctx, NK_KEY_DEL, down);
-			}	break;
-			case '\b':
-			{
-				nk_input_key(ctx, NK_KEY_BACKSPACE, down);
-			}	break;
-
-			default:
-			{
-				if(ev->character == 'i')
-					nk_input_key(ctx, NK_KEY_TEXT_INSERT_MODE, down);
-				else if(ev->character == 'r')
-					nk_input_key(ctx, NK_KEY_TEXT_REPLACE_MODE, down);
-
-				if(down)
-					nk_input_glyph(ctx, (const char *)ev->utf8);
-			}	break;
-		}
-	}
-}
-
-static void
-_nk_pugl_key(struct nk_context *ctx, const PuglEventKey *ev, int down)
+_nk_pugl_modifiers(nk_pugl_window_t *win, PuglMod state)
+{
+	struct nk_context *ctx = &win->ctx;
+
+	if(win->state != state) // modifiers changed
+	{
+		if( (win->state & PUGL_MOD_SHIFT) != (state & PUGL_MOD_SHIFT))
+			nk_input_key(ctx, NK_KEY_SHIFT, (state & PUGL_MOD_SHIFT) == PUGL_MOD_SHIFT);
+
+		if( (win->state & PUGL_MOD_CTRL) != (state & PUGL_MOD_CTRL))
+			nk_input_key(ctx, NK_KEY_CTRL, (state & PUGL_MOD_CTRL) == PUGL_MOD_CTRL);
+
+		if( (win->state & PUGL_MOD_ALT) != (state & PUGL_MOD_ALT))
+		{
+			// not yet supported in nuklear
+		}
+
+		if( (win->state & PUGL_MOD_SUPER) != (state & PUGL_MOD_SUPER))
+		{
+			// not yet supported in nuklear
+		}
+
+		win->state = state; // switch old and new modifier states
+	}
+}
+
+static bool
+_nk_pugl_key_down(nk_pugl_window_t *win, const PuglEventKey *ev)
 {
 	if(ev->special)
-		_nk_pugl_special_key(ctx, ev, down);
+		return _nk_pugl_special_key_down(win, ev);
 	else if(ev->character && !ev->filter)
-		_nk_pugl_other_key(ctx, ev, down);
+		return _nk_pugl_other_key_down(win, ev);
+
+	return false;
+}
+
+static bool
+_nk_pugl_key_up(nk_pugl_window_t *win, const PuglEventKey *ev)
+{
+	if(ev->special)
+		return _nk_pugl_special_key_up(win, ev);
+
+	return false;
 }

 static inline void
@@ -611,6 +861,7 @@
 		{
 			const PuglEventButton *ev = (const PuglEventButton *)e;

+			_nk_pugl_modifiers(win, ev->state);
 			nk_input_button(ctx, ev->button - 1, ev->x, ev->y, 1);

 			puglPostRedisplay(win->view);
@@ -620,6 +871,7 @@
 		{
 			const PuglEventButton *ev = (const PuglEventButton *)e;

+			_nk_pugl_modifiers(win, ev->state);
 			nk_input_button(ctx, ev->button - 1, ev->x, ev->y, 0);

 			puglPostRedisplay(win->view);
@@ -637,13 +889,10 @@
 		}
 		case PUGL_EXPOSE:
 		{
-			if(win->input_active)
-			{
-				win->input_active = false;
-				nk_input_end(ctx);
-			}
-
+			nk_input_end(ctx);
 			_nk_pugl_expose(win->view);
+			nk_input_begin(ctx);
+
 			break;
 		}
 		case PUGL_CLOSE:
@@ -656,7 +905,8 @@
 		{
 			const PuglEventKey *ev = (const PuglEventKey *)e;

-			_nk_pugl_key(ctx, ev, 1);
+			if(!_nk_pugl_key_down(win, ev)) // no modifier change
+				_nk_pugl_modifiers(win, ev->state);

 			puglPostRedisplay(win->view);
 			break;
@@ -665,7 +915,8 @@
 		{
 			const PuglEventKey *ev = (const PuglEventKey *)e;

-			_nk_pugl_key(ctx, ev, 0);
+			if(!_nk_pugl_key_up(win, ev)) // no modifier change
+				_nk_pugl_modifiers(win, ev->state);

 			puglPostRedisplay(win->view);
 			break;
@@ -674,6 +925,7 @@
 		{
 			const PuglEventMotion *ev = (const PuglEventMotion *)e;

+			_nk_pugl_modifiers(win, ev->state);
 			nk_input_motion(ctx, ev->x, ev->y);

 			puglPostRedisplay(win->view);
@@ -683,42 +935,84 @@
 		{
 			const PuglEventScroll *ev = (const PuglEventScroll *)e;

-			nk_input_scroll(ctx, ev->dy);
+			_nk_pugl_modifiers(win, ev->state);
+			if(win->state & PUGL_MOD_CTRL)
+			{
+				if(ev->dy > 0)
+					_nk_pugl_zoom_in(win);
+				else
+					_nk_pugl_zoom_out(win);
+			}
+			else
+				nk_input_scroll(ctx, ev->dy);

 			puglPostRedisplay(win->view);
 			break;
 		}
-		case PUGL_ENTER_NOTIFY:
-			// fall-through
 		case PUGL_LEAVE_NOTIFY:
-			// fall-through
-		case PUGL_FOCUS_IN:
-			// fall-through
-		case PUGL_FOCUS_OUT:
-		{
+		{
+			const PuglEventCrossing *ev = (const PuglEventCrossing *)e;
+
+			_nk_pugl_modifiers(win, ev->state);
+			win->has_left = true;
 			puglPostRedisplay(win->view);
 			break;
 		}
-	}
-}
-
-static inline intptr_t
+		case PUGL_ENTER_NOTIFY:
+		{
+			const PuglEventCrossing *ev = (const PuglEventCrossing *)e;
+
+			_nk_pugl_modifiers(win, ev->state);
+			win->has_left = false;
+			win->has_entered = true;
+			puglPostRedisplay(win->view);
+			break;
+		}
+
+		case PUGL_FOCUS_OUT:
+		case PUGL_FOCUS_IN:
+		{
+			break;
+		}
+	}
+}
+
+NK_PUGL_API intptr_t
 nk_pugl_init(nk_pugl_window_t *win)
 {
 	nk_pugl_config_t *cfg = &win->cfg;
 	struct nk_convert_config *conv = &win->conv;

-#if !defined(__APPLE__) && !defined(_WIN32)
+	const char *NK_SCALE = getenv("NK_SCALE");
+	const float scale = NK_SCALE ? atof(NK_SCALE) : 1.f;
+	const float dpi0 = 96.f; // reference DPI we're designing for
+
+#if defined(__APPLE__)
+	const float dpi1 = dpi0; //TODO implement this
+#elif defined(_WIN32)
+	// GetDpiForSystem/Monitor/Window is Win10 only
+	HDC screen = GetDC(NULL);
+	const float dpi1 = GetDeviceCaps(screen, LOGPIXELSX);
+	ReleaseDC(NULL, screen);
+#else
 	win->async = (atomic_flag)ATOMIC_FLAG_INIT;
 	win->disp = XOpenDisplay(0);
-#endif
+	const float dpi1 = XDisplayWidth(win->disp, 0) * 25.4f / XDisplayWidthMM(win->disp, 0);
+#endif
+
+	win->scale = scale * dpi1 / dpi0;
+	if(win->scale < 0.5)
+		win->scale = 0.5;
+	win->has_left = true;

 	// init pugl
 	win->view = puglInit(NULL, NULL);
 	puglInitWindowClass(win->view, cfg->class ? cfg->class : "nuklear");
-	puglInitWindowSize(win->view, cfg->width, cfg->height);
-	puglInitWindowMinSize(win->view, cfg->width, cfg->height);
+	puglInitWindowSize(win->view, cfg->width*win->scale, cfg->height*win->scale);
+	puglInitWindowMinSize(win->view, cfg->min_width*win->scale, cfg->min_height*win->scale);
 	puglInitResizable(win->view, cfg->resizable);
+	if(cfg->fixed_aspect)
+		puglInitWindowAspectRatio(win->view, cfg->width, cfg->height, cfg->width, cfg->height);
 	puglInitWindowParent(win->view, cfg->parent);
 	puglInitTransientFor(win->view, cfg->parent);
 	puglSetHandle(win->view, win);
@@ -728,23 +1022,16 @@
 	const int stat = puglCreateWindow(win->view, cfg->title ? cfg->title : "Nuklear");
 	assert(stat == 0);

+	// init nuklear
+	nk_buffer_init_default(&win->cmds);
+	nk_buffer_init_default(&win->vbuf);
+	nk_buffer_init_default(&win->ebuf);
+	nk_init_default(&win->ctx, 0);
+
 	puglEnterContext(win->view);
 	{
-		// init nuklear
-		nk_buffer_init_default(&win->cmds);
-		nk_init_default(&win->ctx, 0);
-
-		// init nuklear font
-		struct nk_font *ttf = NULL;
-		struct nk_font_config fcfg = nk_font_config(cfg->font.size);
-		fcfg.range = nk_font_cyrillic_glyph_ranges();
-
-		_nk_pugl_font_stash_begin(win);
-		if(cfg->font.face && cfg->font.size)
-			ttf = nk_font_atlas_add_from_file(&win->atlas, cfg->font.face, cfg->font.size, &fcfg);
-		_nk_pugl_font_stash_end(win);
-		if(ttf)
-			nk_style_set_font(&win->ctx, &ttf->handle);
+		// init font system
+		_nk_pugl_font_init(win);

 		win->glGenerateMipmap = GL_EXT(glGenerateMipmap);
 	}
@@ -763,21 +1050,23 @@
 	conv->line_AA = NK_ANTI_ALIASING_ON;

 	puglSetEventFunc(win->view, _nk_pugl_event_func);
+	nk_input_begin(&win->ctx);

 	win->widget = puglGetNativeWindow(win->view);
 	return win->widget;
 }

-static inline void
+NK_PUGL_API void
 nk_pugl_show(nk_pugl_window_t *win)
 {
 	if(!win->view)
 		return;

 	puglShowWindow(win->view);
-}
-
-static inline void
+	_nk_pugl_resize(win);
+}
+
+NK_PUGL_API void
 nk_pugl_hide(nk_pugl_window_t *win)
 {
 	if(!win->view)
@@ -786,27 +1075,29 @@
 	puglHideWindow(win->view);
 }

-static inline void
+NK_PUGL_API void
 nk_pugl_shutdown(nk_pugl_window_t *win)
 {
 	if(!win->view)
 		return;

+	nk_input_end(&win->ctx);
+
 	if(win->last.buffer)
 		free(win->last.buffer);

 	puglEnterContext(win->view);
 	{
-		// shutdown nuklear font
-		nk_font_atlas_clear(&win->atlas);
-		if(win->font_tex)
-			glDeleteTextures(1, &win->font_tex);
-
-		// shutdown nuklear
-		nk_free(&win->ctx);
-		nk_buffer_free(&win->cmds);
+		// deinit font system
+		_nk_pugl_font_deinit(win);
 	}
 	puglLeaveContext(win->view, false);
+
+	// shutdown nuklear
+	nk_buffer_free(&win->cmds);
+	nk_buffer_free(&win->vbuf);
+	nk_buffer_free(&win->ebuf);
+	nk_free(&win->ctx);

 	// shutdown pugl
 	puglDestroy(win->view);
@@ -817,7 +1108,7 @@
 #endif
 }

-static inline void
+NK_PUGL_API void
 nk_pugl_wait_for_event(nk_pugl_window_t *win)
 {
 	if(!win->view)
@@ -826,7 +1117,7 @@
 	puglWaitForEvent(win->view);
 }

-static inline int
+NK_PUGL_API int
 nk_pugl_process_events(nk_pugl_window_t *win)
 {
 	if(!win->view)
@@ -834,19 +1125,13 @@

 	struct nk_context *ctx = &win->ctx;

-	if(!win->input_active)
-	{
-		win->input_active = true;
-		nk_input_begin(ctx);
-	}
-
 	PuglStatus stat = puglProcessEvents(win->view);
 	(void)stat;

 	return win->quit;
 }

-static inline void
+NK_PUGL_API void
 nk_pugl_post_redisplay(nk_pugl_window_t *win)
 {
 	if(!win->view)
@@ -855,7 +1140,7 @@
 	puglPostRedisplay(win->view);
 }

-static inline void
+NK_PUGL_API void
 nk_pugl_async_redisplay(nk_pugl_window_t *win)
 {
 	if(!win->view)
@@ -863,15 +1148,11 @@

 #if defined(__APPLE__)
 // TODO
-#endif
-
-#if defined(_WIN32)
+#elif defined(_WIN32)
 	const HWND widget = (HWND)win->widget;
 	const int status = SendNotifyMessage(widget, WM_PAINT, 0, 0);
 	(void)status;
-#endif
-
-#if !defined(__APPLE__) && !defined(_WIN32)
+#else
 	const Window widget = (Window)win->widget;
 	XExposeEvent xevent = {
 		.type = Expose,
@@ -893,13 +1174,13 @@
 #endif
 }

-static inline void
+NK_PUGL_API void
 nk_pugl_quit(nk_pugl_window_t *win)
 {
 	win->quit = 1;
 }

-static struct nk_image
+NK_PUGL_API struct nk_image
 nk_pugl_icon_load(nk_pugl_window_t *win, const char *filename)
 {
 	GLuint tex = 0;
@@ -908,19 +1189,22 @@
 		return nk_image_id(tex);

 	int w, h, n;
-	uint8_t *data = stbi_load(filename, &w, &h, &n, 0);
-	if(data && win->glGenerateMipmap)
+	uint8_t *data = stbi_load(filename, &w, &h, &n, 4);
+	if(data)
 	{
 		puglEnterContext(win->view);
 		{
 			glGenTextures(1, &tex);
 			glBindTexture(GL_TEXTURE_2D, tex);
-			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
-			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+			if(!win->glGenerateMipmap) // for GL >= 1.4 && < 3.1
+				glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
-			win->glGenerateMipmap(GL_TEXTURE_2D);
+			if(win->glGenerateMipmap) // for GL >= 3.1
+				win->glGenerateMipmap(GL_TEXTURE_2D);
 		}
 		puglLeaveContext(win->view, false);

@@ -930,7 +1214,7 @@
 	return nk_image_id(tex);
 }

-static void
+NK_PUGL_API void
 nk_pugl_icon_unload(nk_pugl_window_t *win, struct nk_image img)
 {
 	if(!win->view)
@@ -946,6 +1230,46 @@
 	}
 }

+NK_PUGL_API bool
+nk_pugl_is_shortcut_pressed(struct nk_input *in, char letter, bool clear)
+{
+	const bool control = nk_input_is_key_down(in, NK_KEY_CTRL);
+
+	if(control && (in->keyboard.text_len == 1) )
+	{
+		// unescape ASCII control chars + Control
+		const char ch = in->keyboard.text[0] | 0x60;
+
+		if(isalpha(ch) && (ch == letter) ) // pass non-alpha characters through
+		{
+			if(clear)
+				in->keyboard.text_len = 0;
+
+			return true; // matching shortcut
+		}
+	}
+
+	return false;
+}
+
+NK_PUGL_API void
+nk_pugl_copy_to_clipboard(nk_pugl_window_t *win, const char *selection, size_t len)
+{
+	puglCopyToClipboard(win->view, selection, len);
+}
+
+NK_PUGL_API const char *
+nk_pugl_paste_from_clipboard(nk_pugl_window_t *win, size_t *len)
+{
+	return puglPasteFromClipboard(win->view, len);
+}
+
+NK_PUGL_API float
+nk_pugl_get_scale(nk_pugl_window_t *win)
+{
+	return win->scale;
+}
+
 #ifdef __cplusplus
 }
 #endif


Bug 592883 - Spin cell rendererer problem with double click

Block 2BUTTON and 3BUTTON press events using a button press event
handler in GtkCellRendererSpin, so that they won't be eaten and
processed by tree view.

--- gtk/gtkcellrendererspin.c
+++ gtk/gtkcellrendererspin.c
@@ -271,6 +271,21 @@
   return FALSE;
 }

+static gboolean
+gtk_cell_renderer_spin_button_press_event (GtkWidget      *widget,
+                                           GdkEventButton *event,
+                                           gpointer        user_data)
+{
+  /* Block 2BUTTON and 3BUTTON here, so that they won't be eaten
+   * by tree view.
+   */
+  if (event->type == GDK_2BUTTON_PRESS
+      || event->type == GDK_3BUTTON_PRESS)
+    return TRUE;
+
+  return FALSE;
+}
+
 static GtkCellEditable *
 gtk_cell_renderer_spin_start_editing (GtkCellRenderer     *cell,
 				      GdkEvent            *event,
@@ -296,6 +311,10 @@
   spin = gtk_spin_button_new (priv->adjustment,
 			      priv->climb_rate, priv->digits);

+  g_signal_connect (spin, "button-press-event",
+                    G_CALLBACK (gtk_cell_renderer_spin_button_press_event),
+                    NULL);
+
   if (cell_text->text)
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin),
 			       g_ascii_strtod (cell_text->text, NULL));


idle: added a comment to explain _is_just_connected

Signed-off-by: Jonny Lamb <54cd04502facfcf96b325c60af9b1611ee761860@gnome.org>

--- libempathy/empathy-idle.c
+++ libempathy/empathy-idle.c
@@ -723,6 +723,9 @@
 	return priv->requested_presence_type;
 }

+/* This function returns %TRUE if EmpathyIdle considers the account
+ * @account as having just connected recently. Otherwise, it returns
+ * %FALSE. In doubt, %FALSE is returned. */
 gboolean
 empathy_idle_account_is_just_connected (EmpathyIdle *idle,
 					TpAccount *account)


update nl80211.h

update nl80211.h

Signed-off-by: Johannes Berg <bff32994ff0f8d048f262a8388145a71b6071bfe@intel.com>

--- nl80211.h
+++ nl80211.h
@@ -28,6 +28,13 @@
 #include <linux/types.h>

 #define NL80211_GENL_NAME "nl80211"
+
+#define NL80211_MULTICAST_GROUP_CONFIG		"config"
+#define NL80211_MULTICAST_GROUP_SCAN		"scan"
+#define NL80211_MULTICAST_GROUP_REG		"regulatory"
+#define NL80211_MULTICAST_GROUP_MLME		"mlme"
+#define NL80211_MULTICAST_GROUP_VENDOR		"vendor"
+#define NL80211_MULTICAST_GROUP_TESTMODE	"testmode"

 /**
  * DOC: Station handling
@@ -173,8 +180,8 @@
  *	%NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
  *
  * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
- *	either a dump request on a %NL80211_ATTR_WIPHY or a specific get
- *	on an %NL80211_ATTR_IFINDEX is supported.
+ *	either a dump request for all interfaces or a specific get with a
+ *	single %NL80211_ATTR_IFINDEX is supported.
  * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
  *	%NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
  * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
@@ -317,7 +324,9 @@
  *	if passed, define which channels should be scanned; if not
  *	passed, all channels allowed for the current regulatory domain
  *	are used.  Extra IEs can also be passed from the userspace by
- *	using the %NL80211_ATTR_IE attribute.
+ *	using the %NL80211_ATTR_IE attribute.  The first cycle of the
+ *	scheduled scan can be delayed by %NL80211_ATTR_SCHED_SCAN_DELAY
+ *	is supplied.
  * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT if
  *	scheduled scan is not running. The caller may assume that as soon
  *	as the call returns, it is safe to start a new scheduled scan again.
@@ -1713,6 +1722,24 @@
  *	obtained from it is coming from the device's wiphy and not the global
  *	cfg80211 regdomain.
  *
+ * @NL80211_ATTR_EXT_FEATURES: extended feature flags contained in a byte
+ *	array. The feature flags are identified by their bit index (see &enum
+ *	nl80211_ext_feature_index). The bit index is ordered starting at the
+ *	least-significant bit of the first byte in the array, ie. bit index 0
+ *	is located at bit 0 of byte 0. bit index 25 would be located at bit 1
+ *	of byte 3 (u8 array).
+ *
+ * @NL80211_ATTR_SURVEY_RADIO_STATS: Request overall radio statistics to be
+ *	returned along with other survey data. If set, @NL80211_CMD_GET_SURVEY
+ *	may return a survey entry without a channel indicating global radio
+ *	statistics (only some values are valid and make sense.)
+ *	For devices that don't return such an entry even then, the information
+ *	should be contained in the result as the sum of the respective counters
+ *	over all channels.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_DELAY: delay before a scheduled scan (or a
+ *	WoWLAN net-detect scan) is started, u32 in seconds.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2071,6 +2098,14 @@
 	NL80211_ATTR_MAC_MASK,

 	NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
+
+	NL80211_ATTR_EXT_FEATURES,
+
+	NL80211_ATTR_SURVEY_RADIO_STATS,
+
+	NL80211_ATTR_NETNS_FD,
+
+	NL80211_ATTR_SCHED_SCAN_DELAY,

 	/* add attributes here, update the policy in nl80211.c */

@@ -2112,7 +2147,7 @@

 #define NL80211_MAX_SUPP_RATES			32
 #define NL80211_MAX_SUPP_HT_RATES		77
-#define NL80211_MAX_SUPP_REG_RULES		32
+#define NL80211_MAX_SUPP_REG_RULES		64
 #define NL80211_TKIP_DATA_OFFSET_ENCR_KEY	0
 #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY	16
 #define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY	24
@@ -2252,8 +2287,15 @@
  * @NL80211_RATE_INFO_VHT_MCS: MCS index for VHT (u8)
  * @NL80211_RATE_INFO_VHT_NSS: number of streams in VHT (u8)
  * @NL80211_RATE_INFO_80_MHZ_WIDTH: 80 MHz VHT rate
- * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: 80+80 MHz VHT rate
+ * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: unused - 80+80 is treated the
+ *	same as 160 for purposes of the bitrates
  * @NL80211_RATE_INFO_160_MHZ_WIDTH: 160 MHz VHT rate
+ * @NL80211_RATE_INFO_10_MHZ_WIDTH: 10 MHz width - note that this is
+ *	a legacy rate and will be reported as the actual bitrate, i.e.
+ *	half the base (20 MHz) rate
+ * @NL80211_RATE_INFO_5_MHZ_WIDTH: 5 MHz width - note that this is
+ *	a legacy rate and will be reported as the actual bitrate, i.e.
+ *	a quarter of the base (20 MHz) rate
  * @__NL80211_RATE_INFO_AFTER_LAST: internal use
  */
 enum nl80211_rate_info {
@@ -2268,6 +2310,8 @@
 	NL80211_RATE_INFO_80_MHZ_WIDTH,
 	NL80211_RATE_INFO_80P80_MHZ_WIDTH,
 	NL80211_RATE_INFO_160_MHZ_WIDTH,
+	NL80211_RATE_INFO_10_MHZ_WIDTH,
+	NL80211_RATE_INFO_5_MHZ_WIDTH,

 	/* keep last */
 	__NL80211_RATE_INFO_AFTER_LAST,
@@ -2312,18 +2356,24 @@
  *
  * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
  * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
- * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
- * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
- * @NL80211_STA_INFO_RX_BYTES64: total received bytes (u64, from this station)
- * @NL80211_STA_INFO_TX_BYTES64: total transmitted bytes (u64, to this station)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (MPDU length)
+ *	(u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (MPDU length)
+ *	(u32, to this station)
+ * @NL80211_STA_INFO_RX_BYTES64: total received bytes (MPDU length)
+ *	(u64, from this station)
+ * @NL80211_STA_INFO_TX_BYTES64: total transmitted bytes (MPDU length)
+ *	(u64, to this station)
  * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
  * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
  * 	containing info as possible, see &enum nl80211_rate_info
- * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
- * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
- *	station)
- * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
- * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_RX_PACKETS: total received packet (MSDUs and MMPDUs)
+ *	(u32, from this station)
+ * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (MSDUs and MMPDUs)
+ *	(u32, to this station)
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (MPDUs) (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (MPDUs)
+ *	(u32, to this station)
  * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
  * @NL80211_STA_INFO_LLID: the station's mesh LLID
  * @NL80211_STA_INFO_PLID: the station's mesh PLID
@@ -2347,6 +2397,16 @@
  *	Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
  * @NL80211_STA_EXPECTED_THROUGHPUT: expected throughput considering also the
  *	802.11 header (u32, kbps)
+ * @NL80211_STA_INFO_RX_DROP_MISC: RX packets dropped for unspecified reasons
+ *	(u64)
+ * @NL80211_STA_INFO_BEACON_RX: number of beacons received from this peer (u64)
+ * @NL80211_STA_INFO_BEACON_SIGNAL_AVG: signal strength average
+ *	for beacons only (u8, dBm)
+ * @NL80211_STA_INFO_TID_STATS: per-TID statistics (see &enum nl80211_tid_stats)
+ *	This is a nested attribute where each the inner attribute number is the
+ *	TID+1 and the special TID 16 (i.e. value 17) is used for non-QoS frames;
+ *	each one of those is again nested with &enum nl80211_tid_stats
+ *	attributes carrying the actual values.
  * @__NL80211_STA_INFO_AFTER_LAST: internal
  * @NL80211_STA_INFO_MAX: highest possible station info attribute
  */
@@ -2379,10 +2439,39 @@
 	NL80211_STA_INFO_CHAIN_SIGNAL,
 	NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
 	NL80211_STA_INFO_EXPECTED_THROUGHPUT,
+	NL80211_STA_INFO_RX_DROP_MISC,
+	NL80211_STA_INFO_BEACON_RX,
+	NL80211_STA_INFO_BEACON_SIGNAL_AVG,
+	NL80211_STA_INFO_TID_STATS,

 	/* keep last */
 	__NL80211_STA_INFO_AFTER_LAST,
 	NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_tid_stats - per TID statistics attributes
+ * @__NL80211_TID_STATS_INVALID: attribute number 0 is reserved
+ * @NL80211_TID_STATS_RX_MSDU: number of MSDUs received (u64)
+ * @NL80211_TID_STATS_TX_MSDU: number of MSDUs transmitted (or
+ *	attempted to transmit; u64)
+ * @NL80211_TID_STATS_TX_MSDU_RETRIES: number of retries for
+ *	transmitted MSDUs (not counting the first attempt; u64)
+ * @NL80211_TID_STATS_TX_MSDU_FAILED: number of failed transmitted
+ *	MSDUs (u64)
+ * @NUM_NL80211_TID_STATS: number of attributes here
+ * @NL80211_TID_STATS_MAX: highest numbered attribute here
+ */
+enum nl80211_tid_stats {
+	__NL80211_TID_STATS_INVALID,
+	NL80211_TID_STATS_RX_MSDU,
+	NL80211_TID_STATS_TX_MSDU,
+	NL80211_TID_STATS_TX_MSDU_RETRIES,
+	NL80211_TID_STATS_TX_MSDU_FAILED,
+
+	/* keep last */
+	NUM_NL80211_TID_STATS,
+	NL80211_TID_STATS_MAX = NUM_NL80211_TID_STATS - 1
 };

 /**
@@ -2799,16 +2888,18 @@
  * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
  * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
  * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
- * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
- *	spent on this channel
- * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
+ * @NL80211_SURVEY_INFO_TIME: amount of time (in ms) that the radio
+ *	was turned on (on channel or globally)
+ * @NL80211_SURVEY_INFO_TIME_BUSY: amount of the time the primary
  *	channel was sensed busy (either due to activity or energy detect)
- * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
+ * @NL80211_SURVEY_INFO_TIME_EXT_BUSY: amount of time the extension
  *	channel was sensed busy
- * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
- *	receiving data
- * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
- *	transmitting data
+ * @NL80211_SURVEY_INFO_TIME_RX: amount of time the radio spent
+ *	receiving data (on channel or globally)
+ * @NL80211_SURVEY_INFO_TIME_TX: amount of time the radio spent
+ *	transmitting data (on channel or globally)
+ * @NL80211_SURVEY_INFO_TIME_SCAN: time the radio spent for scan
+ *	(on this channel or globally)
  * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
  *	currently defined
  * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
@@ -2818,16 +2909,24 @@
 	NL80211_SURVEY_INFO_FREQUENCY,
 	NL80211_SURVEY_INFO_NOISE,
 	NL80211_SURVEY_INFO_IN_USE,
-	NL80211_SURVEY_INFO_CHANNEL_TIME,
-	NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
-	NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
-	NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
-	NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
+	NL80211_SURVEY_INFO_TIME,
+	NL80211_SURVEY_INFO_TIME_BUSY,
+	NL80211_SURVEY_INFO_TIME_EXT_BUSY,
+	NL80211_SURVEY_INFO_TIME_RX,
+	NL80211_SURVEY_INFO_TIME_TX,
+	NL80211_SURVEY_INFO_TIME_SCAN,

 	/* keep last */
 	__NL80211_SURVEY_INFO_AFTER_LAST,
 	NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
 };
+
+/* keep old names for compatibility */
+#define NL80211_SURVEY_INFO_CHANNEL_TIME		NL80211_SURVEY_INFO_TIME
+#define NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY		NL80211_SURVEY_INFO_TIME_BUSY
+#define NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY	NL80211_SURVEY_INFO_TIME_EXT_BUSY
+#define NL80211_SURVEY_INFO_CHANNEL_TIME_RX		NL80211_SURVEY_INFO_TIME_RX
+#define NL80211_SURVEY_INFO_CHANNEL_TIME_TX		NL80211_SURVEY_INFO_TIME_TX

 /**
  * enum nl80211_mntr_flags - monitor configuration flags
@@ -3265,6 +3364,9 @@
 /**
  * enum nl80211_bss_status - BSS "status"
  * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
+ *	Note that this is no longer used since cfg80211 no longer
+ *	keeps track of whether or not authentication was done with
+ *	a given BSS.
  * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
  * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
  *
@@ -3648,9 +3750,12 @@
  * @NL80211_WOWLAN_TRIG_NET_DETECT: wake up when a configured network
  *	is detected.  This is a nested attribute that contains the
  *	same attributes used with @NL80211_CMD_START_SCHED_SCAN.  It
- *	specifies how the scan is performed (e.g. the interval and the
- *	channels to scan) as well as the scan results that will
- *	trigger a wake (i.e. the matchsets).
+ *	specifies how the scan is performed (e.g. the interval, the
+ *	channels to scan and the initial delay) as well as the scan
+ *	results that will trigger a wake (i.e. the matchsets).  This
+ *	attribute is also sent in a response to
+ *	@NL80211_CMD_GET_WIPHY, indicating the number of match sets
+ *	supported by the driver (u32).
  * @NL80211_WOWLAN_TRIG_NET_DETECT_RESULTS: nested attribute
  *	containing an array with information about what triggered the
  *	wake up.  If no elements are present in the array, it means
@@ -4221,6 +4326,19 @@
 };

 /**
+ * enum nl80211_ext_feature_index - bit index of extended features.
+ *
+ * @NUM_NL80211_EXT_FEATURES: number of extended features.
+ * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
+ */
+enum nl80211_ext_feature_index {
+
+	/* add new features before the definition below */
+	NUM_NL80211_EXT_FEATURES,
+	MAX_NL80211_EXT_FEATURES = NUM_NL80211_EXT_FEATURES - 1
+};
+
+/**
  * enum nl80211_probe_resp_offload_support_attr - optional supported
  *	protocols for probe-response offloading by the driver/FW.
  *	To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute.


Done with multiGPU SaPD

Done with multiGPU SaPD

--- sap/precond.h
+++ sap/precond.h
@@ -211,12 +211,14 @@

     PrecVector           m_buffer;
     PrecVector           m_buffer2;
+    std::vector<PrecVector>   m_buffers;

     std::vector<PrecVector>   m_all_Bs;               // For multi-GPU only
     std::vector<IntVector>    m_all_BOffsets;         // For multi-GPU only
     std::vector<IntVector>    m_all_ks;               // For multi-GPU only
     std::vector<IntVectorH>   m_all_BOffsets_host;    // For multi-GPU only
     std::vector<IntVectorH>   m_all_ks_host;          // For multi-GPU only
+    std::vector<IntVectorH>   m_all_ks_col_host;      // For multi-GPU only
     IntVectorH           m_all_num_rows;              // For multi-GPU only
     IntVectorH           m_all_num_partitions;        // For multi-GPU only

@@ -276,19 +278,54 @@
     void partBlockedBandedLU_one();
     void partBlockedBandedLU_const();
     void partBlockedBandedCholesky_one();
-    void partBlockedBandedCholesky_var();
+    void partBlockedBandedCholesky_var(
+        int                     n,
+        int                     num_partitions,
+        PrecVector&             B,
+        IntVector&              ks,
+        IntVector&              b_offsets,
+        IntVectorH&             ks_host,
+        IntVectorH&             b_offsets_host,
+        IntVectorH&             ks_col_host
+    );
     void partBandedLU_var();
-    void partBlockedBandedLU_var();
+    void partBlockedBandedLU_var(
+        int                     n,
+        int                     num_partitions,
+        PrecVector&             B,
+        IntVector&              ks,
+        IntVector&              b_offsets,
+        IntVectorH&             ks_host,
+        IntVectorH&             b_offsets_host,
+        IntVectorH&             ks_col_host
+    );
+
     void partBandedUL(PrecVector& B);
     void partBlockedBandedUL(PrecVector& B);
     void sparseFactorization();

     void partBandedFwdSweep(PrecVector& v);
     void partBandedFwdSweep_const(PrecVector& v);
-    void partBandedFwdSweep_var(PrecVector& v);
+    void partBandedFwdSweep_var(
+        PrecVector&  v,
+        int          n,
+        int          num_partitions,
+        PrecVector&  B,
+        IntVector&   ks,
+        IntVector&   b_offsets
+    );
+
     void partBandedBckSweep(PrecVector& v);
     void partBandedBckSweep_const(PrecVector& v);
-    void partBandedBckSweep_var(PrecVector& v);
+    void partBandedBckSweep_var(
+        PrecVector&  v,
+        int          n,
+        int          num_partitions,
+        PrecVector&  B,
+        IntVector&   ks,
+        IntVector&   b_offsets
+    );
+
     void partBandedSweepsH(PrecVector& v);
     void sparseSweep(PrecVector& v, PrecVector& w);

@@ -322,6 +359,14 @@
     void assembleReducedMat(PrecVector& WV);

     void copyLastPartition(PrecVector& B2);
+
+    void copyFromToMultiGPUs (
+        PrecVector&                v,
+        std::vector<PrecVector>&   vs,
+        int                        n,
+        IntVectorH&                num_rows,
+        bool                       from
+    );

     void leftTrans(PrecVector& v, PrecVector& z);
     void rightTrans(PrecVector& v, PrecVector& z);
@@ -803,7 +848,19 @@
         m_timer.Start();
         partBandedLU();
         // m_Bh = m_B;
-        m_actual_nnz = (2 * m_k + 1) * m_n - thrust::count(m_B.begin(), m_B.end(), 0.0);
+        if (m_gpuCount == 1) {
+            m_actual_nnz = (2 * m_k + 1) * m_n - thrust::count(m_B.begin(), m_B.end(), 0.0);
+        } else {
+            m_actual_nnz = (2 * m_k + 1) * m_n;
+            int cur_device = 0;
+            cudaGetDevice(&cur_device);
+            for (int i = 0; i < m_gpuCount; i++) {
+                cudaSetDevice(i);
+                m_actual_nnz -= thrust::count(m_all_Bs[i].begin(), m_all_Bs[i].end(), 0.0);
+            }
+            cudaSetDevice(cur_device);
+        }
+
         m_timer.Stop();
         m_time_bandLU = m_timer.getElapsed();
         ////cusp::io::write_matrix_market_file(m_B, "B_lu.mtx");
@@ -1058,8 +1115,8 @@

     // Get purified solution
     // if (m_numPartitions > CPU_GPU_SWEEP_THRESHOLD) {
-        partBandedFwdSweep(sol);
-        partBandedBckSweep(sol);
+    partBandedFwdSweep(sol);
+    partBandedBckSweep(sol);
     // } else
         // partBandedSweepsH(sol);
 }
@@ -1377,6 +1434,7 @@
                 m_all_ks_host.resize(m_gpuCount);
                 m_all_num_rows.resize(m_gpuCount);
                 m_all_num_partitions.resize(m_gpuCount);
+                m_all_ks_col_host.resize(m_gpuCount);

                 std::vector<PrecMatrixCooH> my_Acoohs(m_gpuCount);
                 std::vector<PrecMatrixCoo>  my_Acoos(m_gpuCount);
@@ -1410,6 +1468,9 @@
                         r_begin = rowEnd;
                     }
                     m_all_BOffsets_host[i][partEnd - partBegin] = m_BOffsets_host[partEnd] - b_offset_begin;
+                    m_all_ks_col_host[i].resize(rowEnd - rowBegin);
+
+                    thrust::copy(m_ks_col_host.begin() + rowBegin, m_ks_col_host.begin() + rowEnd, m_all_ks_col_host[i].begin());

                     m_all_Bs[i].resize(m_BOffsets_host[partEnd] - b_offset_begin);

@@ -1467,7 +1528,6 @@
                 cudaSetDevice(cur_device);
             }
         }
-
         m_timer.Stop();
         m_time_toBanded = m_timer.getElapsed();
     } else {
@@ -3159,10 +3219,67 @@
         // Variable bandwidth method. Note that in this situation, there
         // must be more than one partition.
         // partBandedLU_var();
-        if (m_saveMem)
-            partBlockedBandedCholesky_var();
-        else
-            partBlockedBandedLU_var();
+        if (m_gpuCount == 1) {
+            if (m_saveMem) {
+                partBlockedBandedCholesky_var(
+                    m_n,
+                    m_numPartitions,
+                    m_B,
+                    m_ks,
+                    m_BOffsets,
+                    m_ks_host,
+                    m_BOffsets_host,
+                    m_ks_col_host
+                );
+            } else {
+                partBlockedBandedLU_var(
+                    m_n,
+                    m_numPartitions,
+                    m_B,
+                    m_ks,
+                    m_BOffsets,
+                    m_ks_host,
+                    m_BOffsets_host,
+                    m_ks_col_host
+                );
+            }
+        } else {
+            omp_set_num_threads(m_gpuCount);
+            int cur_device = 0;
+            cudaGetDevice(&cur_device);
+
+#pragma omp parallel for
+            for (int i = 0; i < m_gpuCount; i++) {
+                cudaSetDevice(i);
+                IntVectorH ks_host = m_all_ks[i];
+                IntVectorH b_offsets_host = m_all_BOffsets[i];
+                if (m_saveMem) {
+                    partBlockedBandedCholesky_var(
+                        m_all_num_rows[i],
+                        m_all_num_partitions[i],
+                        m_all_Bs[i],
+                        m_all_ks[i],
+                        m_all_BOffsets[i],
+                        ks_host,
+                        b_offsets_host,
+                        m_all_ks_col_host[i]
+                    );
+                } else {
+                    partBlockedBandedLU_var(
+                        m_all_num_rows[i],
+                        m_all_num_partitions[i],
+                        m_all_Bs[i],
+                        m_all_ks[i],
+                        m_all_BOffsets[i],
+                        ks_host,
+                        b_offsets_host,
+                        m_all_ks_col_host[i]
+                    );
+                }
+            }
+
+            cudaSetDevice(cur_device);
+        }
     } else {
         // Constant bandwidth method.
         if (m_numPartitions > 1) {
@@ -3738,26 +3855,35 @@

 template <typename PrecVector>
 void
-Precond<PrecVector>::partBlockedBandedLU_var()
+Precond<PrecVector>::partBlockedBandedLU_var(
+    int                     n,
+    int                     num_partitions,
+    PrecVector&             B,
+    IntVector&              ks,
+    IntVector&              b_offsets,
+    IntVectorH&             ks_host,
+    IntVectorH&             b_offsets_host,
+    IntVectorH&             ks_col_host
+)
 {
     // Note that this function can only be called if there are two or more partitions.
     // Also, in this case, the factorization method is LU_only which implies that all
     // partitions are LU factorized.

-    PrecValueType* dB         = thrust::raw_pointer_cast(&m_B[0]);
-    int*           p_ks       = thrust::raw_pointer_cast(&m_ks[0]);
-    int*           p_BOffsets = thrust::raw_pointer_cast(&m_BOffsets[0]);
-
-    int tmp_k = cusp::blas::nrmmax(m_ks);
-    int partSize  = m_n / m_numPartitions;
-    int remainder = m_n % m_numPartitions;
+    PrecValueType* dB         = thrust::raw_pointer_cast(&B[0]);
+    int*           p_ks       = thrust::raw_pointer_cast(&ks[0]);
+    int*           p_BOffsets = thrust::raw_pointer_cast(&b_offsets[0]);
+
+    int tmp_k = cusp::blas::nrmmax(ks);
+    int partSize  = n / num_partitions;
+    int remainder = n % num_partitions;

     if(tmp_k >= CRITICAL_THRESHOLD)
     {
         int final_partition_size = (remainder == 0 ? partSize : (partSize + 1));
-        int threadsNum = adjustNumThreads(cusp::blas::nrm1(m_ks) / m_numPartitions);
-
-        IntVector ks_col = m_ks_col_host;
+        int threadsNum = adjustNumThreads(cusp::blas::nrm1(ks) / num_partitions);
+
+        IntVector ks_col = ks_col_host;
         int *ks_col_ptr = thrust::raw_pointer_cast(&ks_col[0]);

         const int BLOCK_FACTOR = 8;
@@ -3767,69 +3893,78 @@
                 last_row = final_partition_size;
             int block_num = last_row - st_row;

-            device::var::blockedBandLU_critical_phase1_safe<PrecValueType> <<< m_numPartitions, threadsNum>>>(dB, st_row, p_ks, p_BOffsets, ks_col_ptr, block_num, partSize, remainder, false);
+            device::var::blockedBandLU_critical_phase1_safe<PrecValueType> <<< num_partitions, threadsNum>>>(dB, st_row, p_ks, p_BOffsets, ks_col_ptr, block_num, partSize, remainder, false);

             if (last_row == final_partition_size)
                 break;

-            dim3 grids(tmp_k, m_numPartitions);
+            dim3 grids(tmp_k, num_partitions);

             device::var::blockedBandLU_critical_phase2<PrecValueType> <<<grids, BLOCK_FACTOR, BLOCK_FACTOR * sizeof(PrecValueType)>>> (dB, st_row, p_ks, p_BOffsets, BLOCK_FACTOR, partSize, remainder);

             device::var::blockedBandLU_critical_phase3<PrecValueType> <<<grids, threadsNum, BLOCK_FACTOR * sizeof(PrecValueType)>>> (dB, st_row, p_ks, p_BOffsets, BLOCK_FACTOR, partSize, remainder, false);
         }
     } else if (tmp_k > 27)
-        device::var::bandLU_g32_safe<PrecValueType><<<m_numPartitions, 512>>>(dB, p_ks, p_BOffsets, partSize, remainder, false);
+        device::var::bandLU_g32_safe<PrecValueType><<<num_partitions, 512>>>(dB, p_ks, p_BOffsets, partSize, remainder, false);
     else
-        device::var::bandLU_safe<PrecValueType><<<m_numPartitions,  tmp_k * tmp_k >>>(dB, p_ks, p_BOffsets, partSize, remainder, false);
-
-    if (m_safeFactorization)
-        device::var::boostLastPivot<PrecValueType><<<m_numPartitions, 1>>>(dB, partSize, p_ks, p_BOffsets, partSize, remainder);
+        device::var::bandLU_safe<PrecValueType><<<num_partitions,  tmp_k * tmp_k >>>(dB, p_ks, p_BOffsets, partSize, remainder, false);
+
+    if (m_safeFactorization) {
+        device::var::boostLastPivot<PrecValueType><<<num_partitions, 1>>>(dB, partSize, p_ks, p_BOffsets, partSize, remainder);
+    }

     int gridX = partSize+1;
     int gridY = 1;
     kernelConfigAdjust(gridX, gridY, MAX_GRID_DIMENSION);
     dim3 grids(gridX, gridY);

-    for (int i=0; i<m_numPartitions ; i++) {
+    for (int i=0; i<num_partitions ; i++) {
         if (i < remainder) {
-            if (m_ks_host[i] <= 1024)
-                device::var::bandLU_post_divide_per_partition<PrecValueType><<<grids, m_ks_host[i]>>>(dB, m_ks_host[i], m_BOffsets_host[i], partSize + 1);
+            if (ks_host[i] <= 1024)
+                device::var::bandLU_post_divide_per_partition<PrecValueType><<<grids, ks_host[i]>>>(dB, ks_host[i], b_offsets_host[i], partSize + 1);
             else
-                device::var::bandLU_post_divide_per_partition_general<PrecValueType><<<grids, 512>>>(dB, m_ks_host[i], m_BOffsets_host[i], partSize + 1);
+                device::var::bandLU_post_divide_per_partition_general<PrecValueType><<<grids, 512>>>(dB, ks_host[i], b_offsets_host[i], partSize + 1);
         }
         else {
-            if (m_ks_host[i] <= 1024)
-                device::var::bandLU_post_divide_per_partition<PrecValueType><<<grids, m_ks_host[i]>>>(dB, m_ks_host[i], m_BOffsets_host[i], partSize);
+            if (ks_host[i] <= 1024)
+                device::var::bandLU_post_divide_per_partition<PrecValueType><<<grids, ks_host[i]>>>(dB, ks_host[i], b_offsets_host[i], partSize);
             else
-                device::var::bandLU_post_divide_per_partition_general<PrecValueType><<<grids, 512>>>(dB, m_ks_host[i], m_BOffsets_host[i], partSize);
-        }
-    }
-
+                device::var::bandLU_post_divide_per_partition_general<PrecValueType><<<grids, 512>>>(dB, ks_host[i], b_offsets_host[i], partSize);
+        }
+    }
 }

 template <typename PrecVector>
 void
-Precond<PrecVector>::partBlockedBandedCholesky_var()
+Precond<PrecVector>::partBlockedBandedCholesky_var(
+    int                     n,
+    int                     num_partitions,
+    PrecVector&             B,
+    IntVector&              ks,
+    IntVector&              b_offsets,
+    IntVectorH&             ks_host,
+    IntVectorH&             b_offsets_host,
+    IntVectorH&             ks_col_host
+)
 {
     // Note that this function can only be called if there are two or more partitions.
     // Also, in this case, the factorization method is LU_only which implies that all
     // partitions are LU factorized.

-    PrecValueType* dB         = thrust::raw_pointer_cast(&m_B[0]);
-    int*           p_ks       = thrust::raw_pointer_cast(&m_ks[0]);
-    int*           p_BOffsets = thrust::raw_pointer_cast(&m_BOffsets[0]);
-
-    int tmp_k = cusp::blas::nrmmax(m_ks);
-    int partSize  = m_n / m_numPartitions;
-    int remainder = m_n % m_numPartitions;
+    PrecValueType* dB         = thrust::raw_pointer_cast(&B[0]);
+    int*           p_ks       = thrust::raw_pointer_cast(&ks[0]);
+    int*           p_BOffsets = thrust::raw_pointer_cast(&b_offsets[0]);
+
+    int tmp_k = cusp::blas::nrmmax(ks);
+    int partSize  = n / num_partitions;
+    int remainder = n % num_partitions;

     if(tmp_k >= CRITICAL_THRESHOLD)
     {
         int final_partition_size = partSize + 1;
-        int threadsNum = adjustNumThreads(cusp::blas::nrm1(m_ks) / m_numPartitions);
-
-        IntVector ks_col = m_ks_col_host;
+        int threadsNum = adjustNumThreads(cusp::blas::nrm1(ks) / num_partitions);
+
+        IntVector ks_col = ks_col_host;
         int *ks_col_ptr = thrust::raw_pointer_cast(&ks_col[0]);

         const int BLOCK_FACTOR = 8;
@@ -3839,19 +3974,19 @@
                 last_row = final_partition_size;
             int block_num = last_row - st_row;

-            device::var::blockedBandLU_critical_phase1_safe<PrecValueType> <<< m_numPartitions, threadsNum>>>(dB, st_row, p_ks, p_BOffsets, ks_col_ptr, block_num, partSize, remainder, true);
+            device::var::blockedBandLU_critical_phase1_safe<PrecValueType> <<< num_partitions, threadsNum>>>(dB, st_row, p_ks, p_BOffsets, ks_col_ptr, block_num, partSize, remainder, true);

             if (last_row == final_partition_size)
                 break;

-            dim3 grids(tmp_k, m_numPartitions);
+            dim3 grids(tmp_k, num_partitions);

             device::var::blockedBandLU_critical_phase3<PrecValueType> <<<grids, threadsNum, BLOCK_FACTOR * sizeof(PrecValueType)>>> (dB, st_row, p_ks, p_BOffsets, BLOCK_FACTOR, partSize, remainder, true);
         }
     } else if (tmp_k > 27)
-        device::var::bandLU_g32_safe<PrecValueType><<<m_numPartitions, 512>>>(dB, p_ks, p_BOffsets, partSize, remainder, true);
+        device::var::bandLU_g32_safe<PrecValueType><<<num_partitions, 512>>>(dB, p_ks, p_BOffsets, partSize, remainder, true);
     else
-        device::var::bandLU_safe<PrecValueType><<<m_numPartitions,  tmp_k * tmp_k >>>(dB, p_ks, p_BOffsets, partSize, remainder, true);
+        device::var::bandLU_safe<PrecValueType><<<num_partitions,  tmp_k * tmp_k >>>(dB, p_ks, p_BOffsets, partSize, remainder, true);

 }

@@ -4027,8 +4162,56 @@
 {
     if (!m_variableBandwidth)
         partBandedFwdSweep_const(v);
-    else
-        partBandedFwdSweep_var(v);
+    else {
+        if (m_gpuCount == 1) {
+            partBandedFwdSweep_var(
+                v,
+                m_n,
+                m_numPartitions,
+                m_B,
+                m_ks,
+                m_BOffsets
+            );
+        } else {
+            omp_set_num_threads(m_gpuCount);
+            int cur_device = 0;
+            cudaGetDevice(&cur_device);
+
+            if (m_buffers.size() != m_gpuCount) {
+                m_buffers.resize(m_gpuCount);
+            }
+
+            copyFromToMultiGPUs (
+                v,
+                m_buffers,
+                m_n,
+                m_all_num_rows,
+                false
+            );
+
+#pragma omp parallel for
+            for (int i = 0; i < m_gpuCount; i++) {
+                partBandedFwdSweep_var(
+                    m_buffers[i],
+                    m_all_num_rows[i],
+                    m_all_num_partitions[i],
+                    m_all_Bs[i],
+                    m_all_ks[i],
+                    m_all_BOffsets[i]
+                );
+            }
+
+            copyFromToMultiGPUs (
+                v,
+                m_buffers,
+                m_n,
+                m_all_num_rows,
+                true
+            );
+
+            cudaSetDevice(cur_device);
+        }
+    }
 }

 template <typename PrecVector>
@@ -4067,31 +4250,38 @@

 template <typename PrecVector>
 void
-Precond<PrecVector>::partBandedFwdSweep_var(PrecVector&  v)
-{
-    PrecValueType* p_B        = thrust::raw_pointer_cast(&m_B[0]);
+Precond<PrecVector>::partBandedFwdSweep_var(
+    PrecVector&  v,
+    int          n,
+    int          num_partitions,
+    PrecVector&  B,
+    IntVector&   ks,
+    IntVector&   b_offsets
+)
+{
+    PrecValueType* p_B        = thrust::raw_pointer_cast(&B[0]);
     PrecValueType* p_v        = thrust::raw_pointer_cast(&v[0]);
-    int*           p_ks       = thrust::raw_pointer_cast(&m_ks[0]);
-    int*           p_BOffsets = thrust::raw_pointer_cast(&m_BOffsets[0]);
-
-    int tmp_k     = cusp::blas::nrmmax(m_ks);
-    int partSize  = m_n / m_numPartitions;
-    int remainder = m_n % m_numPartitions;
+    int*           p_ks       = thrust::raw_pointer_cast(&ks[0]);
+    int*           p_BOffsets = thrust::raw_pointer_cast(&b_offsets[0]);
+
+    int tmp_k     = cusp::blas::nrmmax(ks);
+    int partSize  = n / num_partitions;
+    int remainder = n % num_partitions;

     if (m_saveMem)
         if (tmp_k > 1024)
-            device::var::fwdElimCholesky_sol<PrecValueType><<<m_numPartitions, 512>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::fwdElimCholesky_sol<PrecValueType><<<num_partitions, 512>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else if (tmp_k > 32)
-            device::var::fwdElimCholesky_sol_medium<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::fwdElimCholesky_sol_medium<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else
-            device::var::fwdElimCholesky_sol_narrow<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::fwdElimCholesky_sol_narrow<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
     else {
         if (tmp_k > 1024)
-            device::var::fwdElim_sol<PrecValueType><<<m_numPartitions, 512>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::fwdElim_sol<PrecValueType><<<num_partitions, 512>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else if (tmp_k > 32)
-            device::var::fwdElim_sol_medium<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::fwdElim_sol_medium<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else
-            device::var::fwdElim_sol_narrow<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::fwdElim_sol_narrow<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
     }
 }

@@ -4107,8 +4297,56 @@
 {
     if (!m_variableBandwidth)
         partBandedBckSweep_const(v);
-    else
-        partBandedBckSweep_var(v);
+    else {
+        if (m_gpuCount == 1) {
+            partBandedBckSweep_var(
+                v,
+                m_n,
+                m_numPartitions,
+                m_B,
+                m_ks,
+                m_BOffsets
+            );
+        } else {
+            omp_set_num_threads(m_gpuCount);
+            int cur_device = 0;
+            cudaGetDevice(&cur_device);
+
+            if (m_buffers.size() != m_gpuCount) {
+                m_buffers.resize(m_gpuCount);
+            }
+
+            copyFromToMultiGPUs (
+                v,
+                m_buffers,
+                m_n,
+                m_all_num_rows,
+                false
+            );
+
+#pragma omp parallel for
+            for (int i = 0; i < m_gpuCount; i++) {
+                partBandedBckSweep_var(
+                    m_buffers[i],
+                    m_all_num_rows[i],
+                    m_all_num_partitions[i],
+                    m_all_Bs[i],
+                    m_all_ks[i],
+                    m_all_BOffsets[i]
+                );
+            }
+
+            copyFromToMultiGPUs (
+                v,
+                m_buffers,
+                m_n,
+                m_all_num_rows,
+                true
+            );
+
+            cudaSetDevice(cur_device);
+        }
+    }
 }

 template <typename PrecVector>
@@ -4168,37 +4406,44 @@

 template <typename PrecVector>
 void
-Precond<PrecVector>::partBandedBckSweep_var(PrecVector&  v)
-{
-    PrecValueType* p_B        = thrust::raw_pointer_cast(&m_B[0]);
+Precond<PrecVector>::partBandedBckSweep_var(
+    PrecVector&  v,
+    int          n,
+    int          num_partitions,
+    PrecVector&  B,
+    IntVector&   ks,
+    IntVector&   b_offsets
+)
+{
+    PrecValueType* p_B        = thrust::raw_pointer_cast(&B[0]);
     PrecValueType* p_v        = thrust::raw_pointer_cast(&v[0]);
-    int*           p_ks       = thrust::raw_pointer_cast(&m_ks[0]);
-    int*           p_BOffsets = thrust::raw_pointer_cast(&m_BOffsets[0]);
-
-    int tmp_k      = cusp::blas::nrmmax(m_ks);
-    int partSize   = m_n / m_numPartitions;
-    int remainder  = m_n % m_numPartitions;
+    int*           p_ks       = thrust::raw_pointer_cast(&ks[0]);
+    int*           p_BOffsets = thrust::raw_pointer_cast(&b_offsets[0]);
+
+    int tmp_k      = cusp::blas::nrmmax(ks);
+    int partSize   = n / num_partitions;
+    int remainder  = n % num_partitions;

     int gridX = 1, blockX = partSize + 1;
     kernelConfigAdjust(blockX, gridX, BLOCK_SIZE);
-    dim3 grids(gridX, m_numPartitions);
-    device::var::preBck_sol_divide<PrecValueType><<<grids, blockX>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder, m_saveMem);
+    dim3 grids(gridX, num_partitions);
+    device::var::preBck_sol_divide<PrecValueType><<<grids, blockX>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder, m_saveMem);

     if (m_saveMem) {
         if (tmp_k > 1024)
-            device::var::bckElimCholesky_sol<PrecValueType><<<m_numPartitions, 512>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::bckElimCholesky_sol<PrecValueType><<<num_partitions, 512>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else if (tmp_k > 32)
-            device::var::bckElimCholesky_sol_medium<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::bckElimCholesky_sol_medium<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else
-            device::var::bckElimCholesky_sol_narrow<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::bckElimCholesky_sol_narrow<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
     }
     else {
         if (tmp_k > 1024)
-            device::var::bckElim_sol<PrecValueType><<<m_numPartitions, 512>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::bckElim_sol<PrecValueType><<<num_partitions, 512>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else if (tmp_k > 32)
-            device::var::bckElim_sol_medium<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::bckElim_sol_medium<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
         else
-            device::var::bckElim_sol_narrow<PrecValueType><<<m_numPartitions, tmp_k>>>(m_n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
+            device::var::bckElim_sol_narrow<PrecValueType><<<num_partitions, tmp_k>>>(n, p_ks, p_BOffsets, p_B, p_v, partSize, remainder);
     }
 }

@@ -5203,6 +5448,52 @@
 }

 /**
+ * This function copies a vector to several vectors on different GPUs,
+ * or copy back.
+ */
+template <typename PrecVector>
+void
+Precond<PrecVector>::copyFromToMultiGPUs (
+    PrecVector&                v,
+    std::vector<PrecVector>&   vs,
+    int                        n,
+    IntVectorH&                num_rows,
+    bool                       from
+) {
+    int cur_device = 0;
+    cudaGetDevice(&cur_device);
+
+    if (v.size() != n) {
+        v.resize(n);
+    }
+
+    for (int i = 0; i < m_gpuCount; i++) {
+        cudaSetDevice(i);
+        if (vs[i].size() != num_rows[i]) {
+            vs[i].resize(num_rows[i]);
+        }
+    }
+
+    int row_begin = 0;
+
+    for (int i = 0; i < m_gpuCount; i++) {
+        cudaSetDevice(i);
+
+        int row_end = row_begin + num_rows[i];
+
+        if (from) {
+            thrust::copy(vs[i].begin(), vs[i].end(), v.begin() + row_begin);
+        } else {
+            thrust::copy(v.begin() + row_begin, v.begin() + row_end, vs[i].begin());
+        }
+
+        row_begin = row_end;
+    }
+
+    cudaSetDevice(cur_device);
+}
+
+/**
  * This function put p largest elements at the beginning p positions of
  * an array. This is used in ILUT(p, tau) factorization algorithm.
  */


core: Fixed segfault when connecting with nla

--- libfreerdp-core/ntlmssp.c
+++ libfreerdp-core/ntlmssp.c
@@ -1968,7 +1968,7 @@
 NTLMSSP* ntlmssp_client_new()
 {
 	NTLMSSP* ntlmssp = ntlmssp_new();
-	ntlmssp->server = true;
+	ntlmssp->server = false;
 	return ntlmssp;
 }


Fix fatal crash if enduser_setup.stop() called twice.

--- app/modules/enduser_setup.c
+++ app/modules/enduser_setup.c
@@ -332,7 +332,8 @@
 {
   ENDUSER_SETUP_DEBUG(lua_getstate(), "enduser_setup_check_station_stop");

-  os_timer_disarm(&(state->check_station_timer));
+  if (state != NULL)
+    os_timer_disarm(&(state->check_station_timer));
 }

@@ -1197,7 +1198,7 @@
 {
   ENDUSER_SETUP_DEBUG(lua_getstate(), "enduser_setup_dns_stop");

-  if (state->espconn_dns_udp != NULL)
+  if (state != NULL && state->espconn_dns_udp != NULL)
   {
     espconn_delete(state->espconn_dns_udp);
   }


remove obsolete GL_MESA_trace stuff

remove obsolete GL_MESA_trace stuff

--- include/GL/gl.h
+++ include/GL/gl.h
@@ -2173,37 +2173,6 @@

 /*
- * ???. GL_MESA_trace
- * XXX obsolete
- */
-#ifndef GL_MESA_trace
-#define GL_MESA_trace 1
-
-#define GL_TRACE_ALL_BITS_MESA			0xFFFF
-#define GL_TRACE_OPERATIONS_BIT_MESA		0x0001
-#define GL_TRACE_PRIMITIVES_BIT_MESA		0x0002
-#define GL_TRACE_ARRAYS_BIT_MESA		0x0004
-#define GL_TRACE_TEXTURES_BIT_MESA		0x0008
-#define GL_TRACE_PIXELS_BIT_MESA		0x0010
-#define GL_TRACE_ERRORS_BIT_MESA		0x0020
-#define GL_TRACE_MASK_MESA			0x8755
-#define GL_TRACE_NAME_MESA			0x8756
-
-GLAPI void GLAPIENTRY glEnableTraceMESA( GLbitfield mask );
-GLAPI void GLAPIENTRY glDisableTraceMESA( GLbitfield mask );
-GLAPI void GLAPIENTRY glNewTraceMESA( GLbitfield mask, const GLubyte * traceName );
-GLAPI void GLAPIENTRY glEndTraceMESA( void );
-GLAPI void GLAPIENTRY glTraceAssertAttribMESA( GLbitfield attribMask );
-GLAPI void GLAPIENTRY glTraceCommentMESA( const GLubyte * comment );
-GLAPI void GLAPIENTRY glTraceTextureMESA( GLuint name, const GLubyte* comment );
-GLAPI void GLAPIENTRY glTraceListMESA( GLuint name, const GLubyte* comment );
-GLAPI void GLAPIENTRY glTracePointerMESA( GLvoid* pointer, const GLubyte* comment );
-GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid* last, const GLubyte* comment );
-
-#endif /* GL_MESA_trace */
-
-
-/*
  * ???. GL_MESA_packed_depth_stencil
  * XXX obsolete
  */


fix cmd_tetris.c for small screen

fix cmd_tetris.c for small screen

--- src/kernel/command/cmd_tetris.c
+++ src/kernel/command/cmd_tetris.c
@@ -40,7 +40,7 @@

 /* dimensions of playing area */
 #define	GAME_AREA_WIDTH				(12)
-#define	GAME_AREA_HEIGHT			(22)
+#define	GAME_AREA_HEIGHT			(17)

 /*
  * define tetris shape


mp3dec: Increase number and size of input and output buffers.

This is to change the size and number of input and output buffers.
Larger buffers help to lower ARM and DSP load.

Signed-off-by: Daniel Diaz <ed054987dd20aebbd314fbb0d175066628f13717@ti.com>

--- libgoo-ti/goo-ti-mp3dec.c
+++ libgoo-ti/goo-ti-mp3dec.c
@@ -33,8 +33,10 @@
 #define DASF_PARAM_NAME "OMX.TI.index.config.mp3headerinfo"
 #define FRAME_PARAM_NAME "OMX.TI.index.config.mp3headerinfo"
 #define STREAMID_PARAM_NAME "OMX.TI.index.config.mp3streamIDinfo"
-#define INPUT_BUFFERSIZE 24576
-#define OUTPUT_BUFFERSIZE 18432
+#define INPUT_BUFFERSIZE 8000
+#define OUTPUT_BUFFERSIZE 81920
+#define INPUT_NUM_BUFFERS 4
+#define OUTPUT_NUM_BUFFERS 4

 G_DEFINE_TYPE (GooTiMp3Dec, goo_ti_mp3dec, GOO_TYPE_TI_AUDIO_DECODER)

@@ -164,7 +166,7 @@
 		g_assert (port != NULL);

 		GOO_PORT_GET_DEFINITION (port)->nBufferSize = INPUT_BUFFERSIZE;
-		GOO_PORT_GET_DEFINITION (port)->nBufferCountActual = 2;
+		GOO_PORT_GET_DEFINITION (port)->nBufferCountActual = INPUT_NUM_BUFFERS;
 		GOO_PORT_GET_DEFINITION (port)->format.audio.eEncoding =
 			OMX_AUDIO_CodingMP3;

@@ -182,7 +184,7 @@

 		GOO_PORT_GET_DEFINITION (port)->nBufferSize =
 			OUTPUT_BUFFERSIZE;
-		GOO_PORT_GET_DEFINITION (port)->nBufferCountActual = 2;
+		GOO_PORT_GET_DEFINITION (port)->nBufferCountActual = OUTPUT_NUM_BUFFERS;
 		GOO_PORT_GET_DEFINITION (port)->format.audio.eEncoding =
 			OMX_AUDIO_CodingPCM;


[nm] Add nm() function

[nm] Add nm() function

This function is going to be the core of the program. At this moment
it does almost nothing, but at least it opens the file.

--- nm/main.c
+++ nm/main.c
@@ -1,17 +1,38 @@
 static char sccsid[] = "@(#) ./nm/main.c";

+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>

 #include "../inc/arg.h"
 #include "../inc/scc.h"
+#include "../inc/myro.h"

 char *argv0;
+int radix = 16;
+
+void
+nm(char *fname)
+{
+	FILE *fp;
+	struct myrohdr hdr;
+
+	if ((fp = fopen(fname, "rb")) == NULL)
+		goto file_error;
+	if (readhdr(fp, &hdr) == EOF)
+		goto file_error;
+	if (strncmp(hdr.magic, MYROMAGIC, MYROMAGIC_SIZ))
+		die("nm: %s: File format not recognized", fname);
+
+file_error:
+	die("nm: %s: %s", fname, strerror(errno));
+}

 void
 usage(void)
 {
-	fputs("nm [-APv][-efox][ -g| -u][-t format] file...\n", stderr);
+	fputs("nm [-APv][ -g| -u][-t format] file...\n", stderr);
 	exit(1);
 }

@@ -20,18 +41,21 @@
 {
 	ARGBEGIN {
 	case 'A':
-	case 'e':
-	case 'f':
 	case 'g':
-	case 'o':
 	case 'u':
 	case 'v':
-	case 'x':
 	/* case 't': */
 		;
 	default:
 		usage();
 	} ARGEND

+	if (argc == 0) {
+		nm("a.out");
+	} else {
+		while (argc-- > 0)
+			nm(*++argv);
+	}
+
 	return 0;
 }


Update Stack.h

Update Stack.h

--- include/Stack.h
+++ include/Stack.h
@@ -71,13 +71,12 @@
 	    int size=array_size_*2+(array_size_ == 0);
 		T * array_new=new_copy(array_,size,count_);
 		delete[] array_;
-
 		array_ = array_new;
-		array_size_ = size;
-
+		array_size_=size;
 	}

-		array_[++count_] = value;
+		array_[count_] = value;
+		++count_;
 };

 template <typename T>


Update Stack.h

Update Stack.h

--- include/Stack.h
+++ include/Stack.h
@@ -191,7 +191,7 @@
 }

 template <typename T>
-class stack : private allocator<T>
+class stack :
 {
 public:
 	explicit
@@ -295,5 +295,5 @@
 template<typename T>
 auto stack<T>::throw_is_empty()const->void
 {
-	std::cout << "EMPTY" << std::endl;
-}
+	throw std::logic_error();
+}


Update Stack.h

Update Stack.h

--- include/Stack.h
+++ include/Stack.h
@@ -18,6 +18,7 @@
     size_t count_;
 };

+template <typename T>
 allocator<T>::allocator(size_t size):size_(size),count_(0)
 {
 	if (size==0)


Lib: fix socket leak when sockfd == 0

Lib: fix socket leak when sockfd == 0

amqp_open_socket_inner will leak the socket when sockfd == 0.

Fixes CID: 1383631 caught by Coverity.

--- librabbitmq/amqp_socket.c
+++ librabbitmq/amqp_socket.c
@@ -498,7 +498,7 @@
   for (addr = address_list; addr; addr = addr->ai_next) {
     sockfd = connect_socket(addr, deadline);

-    if (sockfd > 0) {
+    if (sockfd >= 0) {
       last_error = AMQP_STATUS_OK;
       break;
     } else if (sockfd == AMQP_STATUS_TIMEOUT) {


imem: fix cast warning

imem: fix cast warning

--- modules/access/imem-access.c
+++ modules/access/imem-access.c
@@ -106,7 +106,7 @@
     return VLC_SUCCESS;
 }

-static int open_cb_default(void *opaque, void **datap, size_t *sizep)
+static int open_cb_default(void *opaque, void **datap, uint64_t *sizep)
 {
     *datap = opaque;
     (void) sizep;


access_filter_dump: use key-action

access_filter_dump: use key-action

--- modules/access_filter/dump.c
+++ modules/access_filter/dump.c
@@ -121,7 +121,7 @@
     }
     p_sys->tmp_max = ((int64_t)var_CreateGetInteger (access, "dump-margin")) << 20;

-    var_AddCallback (access->p_libvlc, "key-pressed", KeyHandler, access);
+    var_AddCallback (access->p_libvlc, "key-action", KeyHandler, access);

     return VLC_SUCCESS;
 }
@@ -135,7 +135,7 @@
     access_t *access = (access_t *)obj;
     access_sys_t *p_sys = access->p_sys;

-    var_DelCallback (access->p_libvlc, "key-pressed", KeyHandler, access);
+    var_DelCallback (access->p_libvlc, "key-action", KeyHandler, access);

     if (p_sys->stream != NULL)
         fclose (p_sys->stream);
@@ -327,16 +327,7 @@
     (void)oldval;
     (void)obj;

-    for (struct hotkey *key = access->p_libvlc->p_hotkeys;
-         key->psz_action != NULL; key++)
-    {
-        if (key->i_key == newval.i_int)
-        {
-            if (key->i_action == ACTIONID_DUMP)
-                Trigger ((access_t *)data);
-            break;
-        }
-    }
-
+    if (newval.i_int == ACTIONID_DUMP)
+        Trigger (access);
     return VLC_SUCCESS;
 }


access_out_file: add the sync option, only if O_SYNC is defined.

--- modules/access_output/file.c
+++ modules/access_output/file.c
@@ -75,8 +75,10 @@
     add_shortcut( "file", "stream" )
     add_bool( SOUT_CFG_PREFIX "append", false, APPEND_TEXT,APPEND_LONGTEXT,
               true )
+#ifdef O_SYNC
     add_bool( SOUT_CFG_PREFIX "sync", false, SYNC_TEXT,SYNC_LONGTEXT,
               false )
+#endif
     set_callbacks( Open, Close )
 vlc_module_end ()

@@ -85,7 +87,11 @@
  * Exported prototypes
  *****************************************************************************/
 static const char *const ppsz_sout_options[] = {
-    "append", "sync", NULL
+    "append",
+#ifdef O_SYNC
+    "sync",
+#endif
+    NULL
 };

 static ssize_t Write( sout_access_out_t *, block_t * );
@@ -105,7 +111,6 @@
 {
     sout_access_out_t   *p_access = (sout_access_out_t*)p_this;
     int                 fd;
-    bool                sync;

     config_ChainParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );

@@ -116,7 +121,6 @@
     }

     bool append = var_GetBool( p_access, SOUT_CFG_PREFIX "append" );
-    sync = var_GetBool( p_access, SOUT_CFG_PREFIX "sync" );

     if( !strcmp( p_access->psz_path, "-" ) )
     {
@@ -138,9 +142,9 @@

         fd = vlc_open( psz_tmp, O_RDWR | O_CREAT | O_LARGEFILE |
 #ifdef O_SYNC
-                        (sync ? O_SYNC : 0) |
-#endif
-                        (append ? 0 : O_TRUNC), 0666 );
+                (var_GetBool( p_access, SOUT_CFG_PREFIX "sync" ) ? O_SYNC : 0) |
+#endif
+                (append ? 0 : O_TRUNC), 0666 );
         free( psz_tmp );
     }